SwiftUI source code

Pub Date: 2023-08-11

import Accessibility
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import CoreTransferable
import Darwin
import DeveloperToolsSupport
import Foundation
import OSLog
import Observation
import Symbols
import UIKit
import UniformTypeIdentifiers
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
import os
import os.log
import os.signpost
/// A type to generate an `AXChartDescriptor` object that you use to provide
/// information about a chart and its data for an accessible experience
/// in VoiceOver or other assistive technologies.
///
/// Note that you may use the `@Environment` property wrapper inside the
/// implementation of your `AXChartDescriptorRepresentable`, in which case you
/// should implement `updateChartDescriptor`, which will be called when the
/// `Environment` changes.
///
/// For example, to provide accessibility for a view that represents a chart,
/// you would first declare your chart descriptor representable type:
///
///     struct MyChartDescriptorRepresentable: AXChartDescriptorRepresentable {
///         func makeChartDescriptor() -> AXChartDescriptor {
///             // Build and return your `AXChartDescriptor` here.
///         }
///
///         func updateChartDescriptor(_ descriptor: AXChartDescriptor) {
///             // Update your chart descriptor with any new values.
///         }
///     }
///
/// Then, provide an instance of your `AXChartDescriptorRepresentable` type to
/// your view using the `accessibilityChartDescriptor` modifier:
///
///     var body: some View {
///         MyChartView()
///             .accessibilityChartDescriptor(MyChartDescriptorRepresentable())
///     }
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public protocol AXChartDescriptorRepresentable {
/// Create the `AXChartDescriptor` for this view, and return it.
///
/// This will be called once per identity of your `View`. It will not be run
/// again unless the identity of your `View` changes. If you need to
/// update the `AXChartDescriptor` based on changes in your `View`, or in
/// the `Environment`, implement `updateChartDescriptor`.
/// This method will only be called if / when accessibility needs the
/// `AXChartDescriptor` of your view, for VoiceOver.
func makeChartDescriptor() -> AXChartDescriptor
/// Update the existing `AXChartDescriptor` for your view, based on changes
/// in your view or in the `Environment`.
///
/// This will be called as needed, when accessibility needs your
/// `AXChartDescriptor` for VoiceOver. It will only be called if the inputs
/// to your views, or a relevant part of the `Environment`, have changed.
func updateChartDescriptor(_ descriptor: AXChartDescriptor)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AXChartDescriptorRepresentable {
/// Update the existing `AXChartDescriptor` for your view, based on changes
/// in your view or in the `Environment`.
///
/// This will be called as needed, when accessibility needs your
/// `AXChartDescriptor` for VoiceOver. It will only be called if the inputs
/// to your views, or a relevant part of the `Environment`, have changed.
public func updateChartDescriptor(_ descriptor: AXChartDescriptor)
}
/// The structure that defines the kinds of available accessibility actions.
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct AccessibilityActionKind : Equatable, Sendable {
/// The value that represents the default accessibility action.
public static let `default`: AccessibilityActionKind
/// The value that represents an action that cancels a pending accessibility action.
public static let escape: AccessibilityActionKind
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
public static let magicTap: AccessibilityActionKind
public init(named name: Text)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityActionKind, b: AccessibilityActionKind) -> Bool
}
/// A directional indicator you use when making an accessibility adjustment.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum AccessibilityAdjustmentDirection : Sendable {
case increment
case decrement
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityAdjustmentDirection, b: AccessibilityAdjustmentDirection) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AccessibilityAdjustmentDirection : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AccessibilityAdjustmentDirection : Hashable {
}
/// A view modifier that adds accessibility properties to the view
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct AccessibilityAttachmentModifier : ViewModifier {
/// The type of view representing the body.
public typealias Body = Never
}
/// Defines the behavior for the child elements of the new parent element.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct AccessibilityChildBehavior : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: AccessibilityChildBehavior, rhs: AccessibilityChildBehavior) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AccessibilityChildBehavior {
/// Any child accessibility elements become hidden.
///
/// Use this behavior when you want a view represented by
/// a single accessibility element. The new accessibility element
/// has no initial properties. So you will need to use other
/// accessibility modifiers, such as ``View/accessibilityLabel(_:)-5f0zj``,
/// to begin making it accessible.
///
///     var body: some View {
///         VStack {
///             Button("Previous Page", action: goBack)
///             Text("\(pageNumber)")
///             Button("Next Page", action: goForward)
///         }
///         .accessibilityElement(children: .ignore)
///         .accessibilityValue("Page \(pageNumber) of \(pages.count)")
///         .accessibilityAdjustableAction { action in
///             if action == .increment {
///                 goForward()
///             } else {
///                 goBack()
///             }
///         }
///     }
///
/// Before using the  ``AccessibilityChildBehavior/ignore``behavior, consider
/// using the ``AccessibilityChildBehavior/combine`` behavior.
///
/// - Note: A new accessibility element is always created.
public static let ignore: AccessibilityChildBehavior
/// Any child accessibility elements become children of the new
/// accessibility element.
///
/// Use this behavior when you want a view to be an accessibility
/// container. An accessibility container groups child accessibility
/// elements which improves navigation. For example, all children
/// of an accessibility container are navigated in order before
/// navigating through the next accessibility container.
///
///     var body: some View {
///         ScrollView {
///             VStack {
///                 HStack {
///                     ForEach(users) { user in
///                         UserCell(user)
///                     }
///                 }
///                 .accessibilityElement(children: .contain)
///                 .accessibilityLabel("Users")
///
///                 VStack {
///                     ForEach(messages) { message in
///                         MessageCell(message)
///                     }
///                 }
///                 .accessibilityElement(children: .contain)
///                 .accessibilityLabel("Messages")
///             }
///         }
///     }
///
/// A new accessibility element is created when:
/// * The view contains multiple or zero accessibility elements
/// * The view contains a single accessibility element with no children
///
/// - Note: If an accessibility element is not created, the
///         ``AccessibilityChildBehavior`` of the existing
///         accessibility element is modified.
public static let contain: AccessibilityChildBehavior
/// Any child accessibility element's properties are merged
/// into the new accessibility element.
///
/// Use this behavior when you want a view represented by
/// a single accessibility element. The new accessibility element
/// merges properties from all non-hidden children. Some
/// properties may be transformed or ignored to achieve the
/// ideal combined result. For example, not all of ``AccessibilityTraits``
/// are merged and a ``AccessibilityActionKind/default`` action
/// may become a named action (``AccessibilityActionKind/init(named:)``).
///
///     struct UserCell: View {
///         var user: User
///
///         var body: some View {
///             VStack {
///                 Image(user.image)
///                 Text(user.name)
///                 Button("Options", action: showOptions)
///             }
///             .accessibilityElement(children: .combine)
///         }
///     }
///
/// A new accessibility element is created when:
/// * The view contains multiple or zero accessibility elements
/// * The view wraps a ``UIViewRepresentable``/``NSViewRepresentable``.
///
/// - Note: If an accessibility element is not created, the
///         ``AccessibilityChildBehavior`` of the existing
///         accessibility element is modified.
public static let combine: AccessibilityChildBehavior
}
/// Key used to specify the identifier and label associated with
/// an entry of additional accessibility information.
///
/// Use `AccessibilityCustomContentKey` and the associated modifiers taking
/// this value as a parameter in order to simplify clearing or replacing
/// entries of additional information that are manipulated from multiple places
/// in your code.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AccessibilityCustomContentKey {
/// Create an `AccessibilityCustomContentKey` with the specified label and
/// identifier.
///
/// - Parameter label: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter id: String used to identify the additional information entry
///   to SwiftUI. Adding an entry will replace any previous value with the
///   same identifier.
public init(_ label: Text, id: String)
/// Create an `AccessibilityCustomContentKey` with the specified label and
/// identifier.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter id: String used to identify the additional
///   information entry to SwiftUI. Adding an entry will replace any previous
///   value with the same identifier.
public init(_ labelKey: LocalizedStringKey, id: String)
/// Create an `AccessibilityCustomContentKey` with the specified label.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation". This will also be used as the identifier.
public init(_ labelKey: LocalizedStringKey)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityCustomContentKey : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityCustomContentKey, b: AccessibilityCustomContentKey) -> Bool
}
/// An option set that defines the functionality of a view's direct touch area.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct AccessibilityDirectTouchOptions : OptionSet, Sendable {
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: AccessibilityDirectTouchOptions.RawValue
/// Create a set of direct touch options
public init(rawValue: AccessibilityDirectTouchOptions.RawValue)
/// Allows a direct touch area to immediately receive touch events without
/// an assitive technology, such as VoiceOver, speaking. Appropriate for
/// apps that provide direct audio feedback on touch that would conflict
/// with speech feedback.
public static let silentOnTouch: AccessibilityDirectTouchOptions
/// Prevents touch passthrough with the direct touch area until an
/// assistive technology, such as VoiceOver, has activated the direct
/// touch area through a user action, for example a double tap.
public static let requiresActivation: AccessibilityDirectTouchOptions
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = AccessibilityDirectTouchOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = AccessibilityDirectTouchOptions
}
/// A property wrapper type that can read and write a value that SwiftUI updates
/// as the focus of any active accessibility technology, such as VoiceOver,
/// changes.
///
/// Use this capability to request that VoiceOver or other accessibility
/// technologies programmatically focus on a specific element, or to determine
/// whether VoiceOver or other accessibility technologies are focused on
/// particular elements. Use ``View/accessibilityFocused(_:equals:)`` or
/// ``View/accessibilityFocused(_:)`` in conjunction with this property
/// wrapper to identify accessibility elements for which you want to get
/// or set accessibility focus. When accessibility focus enters the modified accessibility element,
/// the framework updates the wrapped value of this property to match a given
/// prototype value. When accessibility focus leaves, SwiftUI resets the wrapped value
/// of an optional property to `nil` or the wrapped value of a Boolean property to `false`.
/// Setting the property's value programmatically has the reverse effect, causing
/// accessibility focus to move to whichever accessibility element is associated with the updated value.
///
///  In the example below, when `notification` changes, and its  `isPriority` property
///  is `true`, the accessibility focus moves to the notification `Text` element above the rest of the
///  view's content:
///
///     struct CustomNotification: Equatable {
///         var text: String
///         var isPriority: Bool
///     }
///
///     struct ContentView: View {
///         @Binding var notification: CustomNotification?
///         @AccessibilityFocusState var isNotificationFocused: Bool
///
///         var body: some View {
///             VStack {
///                 if let notification = self.notification {
///                     Text(notification.text)
///                         .accessibilityFocused($isNotificationFocused)
///                 }
///                 Text("The main content for this view.")
///             }
///             .onChange(of: notification) { notification in
///                 if (notification?.isPriority == true)  {
///                     isNotificationFocused = true
///                 }
///             }
///
///         }
///     }
///
/// To allow for cases where accessibility focus is completely absent from the
/// tree of accessibility elements, or accessibility technologies are not
/// active, the wrapped value must be either optional or Boolean.
///
/// Some initializers of `AccessibilityFocusState` also allow specifying
/// accessibility technologies, determining to which types of accessibility
/// focus this binding applies. If you specify no accessibility technologies,
/// SwiftUI uses an aggregate of any and all active accessibility technologies.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@propertyWrapper @frozen public struct AccessibilityFocusState<Value> : DynamicProperty where Value : Hashable {
@propertyWrapper @frozen public struct Binding {
/// The underlying value referenced by the bound property.
public var wrappedValue: Value { get nonmutating set }
/// The currently focused element.
public var projectedValue: AccessibilityFocusState<Value>.Binding { get }
}
/// The current state value, taking into account whatever bindings might be
/// in effect due to the current location of focus.
///
/// When focus is not in any view that is bound to this state, the wrapped
/// value will be `nil` (for optional-typed state) or `false` (for `Bool`-
/// typed state).
public var wrappedValue: Value { get nonmutating set }
/// A projection of the state value that can be used to establish bindings between view content
/// and accessibility focus placement.
///
/// Use `projectedValue` in conjunction with
/// ``SwiftUI/View/accessibilityFocused(_:equals:)`` to establish
/// bindings between view content and accessibility focus placement.
public var projectedValue: AccessibilityFocusState<Value>.Binding { get }
/// Creates a new accessibility focus state for a Boolean value.
public init() where Value == Bool
/// Creates a new accessibility focus state for a Boolean value, using the accessibility
/// technologies you specify.
///
/// - Parameters:
///   - technologies: One of the available ``AccessibilityTechnologies``.
public init(for technologies: AccessibilityTechnologies) where Value == Bool
/// Creates a new accessibility focus state of the type you provide.
public init<T>() where Value == T?, T : Hashable
/// Creates a new accessibility focus state of the type and
/// using the accessibility technologies you specify.
///
/// - Parameter technologies: One or more of the available
///  ``AccessibilityTechnologies``.
public init<T>(for technologies: AccessibilityTechnologies) where Value == T?, T : Hashable
}
/// The hierarchy of a heading in relation other headings.
///
/// Assistive technologies can use this to improve a users navigation
/// through multiple headings. When users navigate through top level
/// headings they expect the content for each heading to be unrelated.
///
/// For example, you can categorize a list of available products into sections,
/// like Fruits and Vegetables. With only top level headings, this list requires no
/// heading hierarchy, and you use the ``unspecified`` heading level. On the other hand, if sections
/// contain subsections, like if the Fruits section has subsections for varieties of Apples,
/// Pears, and so on, you apply the ``h1`` level to Fruits and Vegetables, and the ``h2``
/// level to Apples and Pears.
///
/// Except for ``h1``, be sure to precede all leveled headings by another heading with a level
/// that's one less.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public enum AccessibilityHeadingLevel : UInt {
/// A heading without a hierarchy.
case unspecified
/// Level 1 heading.
case h1
/// Level 2 heading.
case h2
/// Level 3 heading.
case h3
/// Level 4 heading.
case h4
/// Level 5 heading.
case h5
/// Level 6 heading.
case h6
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: UInt)
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: UInt { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityHeadingLevel : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityHeadingLevel : Hashable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityHeadingLevel : RawRepresentable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityHeadingLevel : Sendable {
}
/// The role of an accessibility element in a label / content pair.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public enum AccessibilityLabeledPairRole {
/// This element represents the label part of the label / content pair.
///
/// For example, it might be the explanatory text to the left of a control,
/// describing what the control does.
case label
/// This element represents the content part of the label / content pair.
///
/// For example, it might be the custom control itself.
case content
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityLabeledPairRole, b: AccessibilityLabeledPairRole) -> Bool
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AccessibilityLabeledPairRole : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AccessibilityLabeledPairRole : Sendable {
}
/// Content within an accessibility rotor.
///
/// Generally generated from control flow constructs like `ForEach` and `if`, and
/// `AccessibilityRotorEntry`.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public protocol AccessibilityRotorContent {
/// The type for the internal content of this `AccessibilityRotorContent`.
associatedtype Body : AccessibilityRotorContent
/// The internal content of this `AccessibilityRotorContent`.
@AccessibilityRotorContentBuilder var body: Self.Body { get }
}
/// Result builder you use to generate rotor entry content.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@resultBuilder public struct AccessibilityRotorContentBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : AccessibilityRotorContent
public static func buildBlock<Content>(_ content: Content) -> some AccessibilityRotorContent where Content : AccessibilityRotorContent
public static func buildIf<Content>(_ content: Content?) -> some AccessibilityRotorContent where Content : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent, C5 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent, C5 : AccessibilityRotorContent, C6 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent, C5 : AccessibilityRotorContent, C6 : AccessibilityRotorContent, C7 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent, C5 : AccessibilityRotorContent, C6 : AccessibilityRotorContent, C7 : AccessibilityRotorContent, C8 : AccessibilityRotorContent
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some AccessibilityRotorContent where C0 : AccessibilityRotorContent, C1 : AccessibilityRotorContent, C2 : AccessibilityRotorContent, C3 : AccessibilityRotorContent, C4 : AccessibilityRotorContent, C5 : AccessibilityRotorContent, C6 : AccessibilityRotorContent, C7 : AccessibilityRotorContent, C8 : AccessibilityRotorContent, C9 : AccessibilityRotorContent
}
/// A struct representing an entry in an Accessibility Rotor.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// An entry in a Rotor may contain a label to identify the entry to the user,
/// and identifier used to determine which Accessibility element the Rotor entry
/// should navigate to, as well as an optional range used for entries that
/// navigate to a specific position in the text of their associated
/// Accessibility element. An entry can also specify a handler to be
/// called before the entry is navigated to, to do any manual work needed to
/// bring the Accessibility element on-screen.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs") {
///         // Not all the `MessageView`s are generated at once, but the model
///         // knows about all the messages.
///         ForEach(messages) { message in
///             // If the Message is from a VIP, make a Rotor entry for it.
///             if message.isVIP {
///                 AccessibilityRotorEntry(message.subject, id: message.id)
///             }
///         }
///     }
///
/// An entry may also be created using an optional namespace, for situations
/// where there are multiple Accessibility elements within a ForEach iteration
/// or where a `ScrollView` is not present. In this case, the `prepare` closure
/// may be needed in order to scroll the element into position using
/// `ScrollViewReader`. The same namespace should be passed to calls to
/// `accessibilityRotorEntry(id:in:)` to tag the Accessibility elements
/// associated with this entry.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs. The Rotor entries are associated with the content text of the message,
/// which is one of the two views within the ForEach that generate Accessibility
/// elements. That view is tagged with `accessibilityRotorEntry(id:in:)` so that
/// it can be found by the `AccessibilityRotorEntry`, and `ScrollViewReader` is
/// used with the `prepare` closure to scroll it into position.
///
///     struct MessageListView: View {
///         @Namespace var namespace
///
///         var body: some View {
///             ScrollViewReader { scroller in
///                  ScrollView {
///                     LazyVStack {
///                         ForEach(allMessages) { message in
///                             VStack {
///                                 Text(message.subject)
///                                 // Tag this `Text` as an element associated
///                                 // with a Rotor entry.
///                                 Text(message.content)
///                                     .accessibilityRotorEntry(
///                                         "\(message.id)_content",
///                                         in: namespace
///                                     )
///                             }
///                         }
///                     }
///                 }
///                 .accessibilityElement(children: .contain)
///                 .accessibilityRotor("VIP Messages") {
///                     ForEach(vipMessages) { vipMessage in
///                         // The Rotor entry points to a specific ID we
///                         // defined within a given `ForEach` iteration,
///                         // not to the entire `ForEach` iteration.
///                         AccessibilityRotorEntry(vipMessage.subject,
///                             id: "\(vipMessage.id)_content", in: namespace)
///                         {
///                             // But the ID we give to `ScrollViewReader`
///                             // matches the one used in the `ForEach`, which
///                             // is the identifier for the whole iteration
///                             // and what `ScrollViewReader` requires.
///                             scroller.scrollTo(vipMessage.id)
///                         }
///                     }
///                 }
///             }
///         }
///     }
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AccessibilityRotorEntry<ID> where ID : Hashable {
/// Create a Rotor entry with a specific label and identifier, with an
/// optional range.
/// - Parameters:
///   - label: Localized string used to show this Rotor entry
///     to users.
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier should be used within a `scrollView`,
///     either in a `ForEach` or using an `id` call.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     either label or accessibility value of the associated element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element on-screen if it isn't already, and SwiftUI
///     is not able to automatically scroll to it.
public init(_ label: Text, id: ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {})
/// Create a Rotor entry with a specific label, identifier and namespace,
/// and with an optional range.
/// - Parameters:
///   - label: Localized string used to show this Rotor entry
///     to users.
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier and namespace should match a call to
///     `accessibilityRotorEntry(id:in)`.
///   - namespace: Namespace for this identifier. Should match a call
///     to `accessibilityRotorEntry(id:in)`.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     accessibility label or accessibility value of the associated
///     element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This should be used to
///     bring the Accessibility element on-screen, if scrolling is needed to
///     get to it.
public init(_ label: Text, id: ID, in namespace: Namespace.ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {})
/// Create a Rotor entry with a specific label and range. This Rotor entry
/// will be associated with the Accessibility element that owns the Rotor.
/// - Parameters:
///   - label: Optional localized string used to show this Rotor entry
///     to users. If no label is specified, the Rotor entry will be labeled
///     based on the text at that range.
///   - range: Range of text associated with this Rotor
///     entry.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element or text on-screen if it isn't already,
///     and SwiftUI not able to automatically scroll to it.
public init(_ label: Text? = nil, textRange: Range<String.Index>, prepare: @escaping (() -> Void) = {}) where ID == Never
/// Create a Rotor entry with a specific label and identifier, with an
/// optional range.
/// - Parameters:
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier should be used within a `scrollView`,
///     either in a `ForEach` or using an `id` call.
///   - label: Localized string used to show this Rotor entry
///     to users.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     accessibility label or accessibility value of the associated
///     element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element on-screen if it isn't already, and SwiftUI
///     is not able to automatically scroll to it.
public init(_ labelKey: LocalizedStringKey, id: ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {})
/// Create a Rotor entry with a specific label and identifier, with an
/// optional range.
/// - Parameters:
///   - label: Localized string used to show this Rotor entry
///     to users.
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier should be used within a `scrollView`,
///     either in a `ForEach` or using an `id` call.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     accessibility label or accessibility value of the associated
///     element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element on-screen if it isn't already, and SwiftUI
///     is not able to automatically scroll to it.
public init<L>(_ label: L, id: ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {}) where L : StringProtocol
/// Create a Rotor entry with a specific label, identifier and namespace,
/// and with an optional range.
/// - Parameters:
///   - labelKey: Localized string used to show this Rotor entry
///     to users.
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier and namespace should match a call to
///     `accessibilityRotorEntry(id:in)`.
///   - namespace: Namespace for this identifier. Should match a call
///     to `accessibilityRotorEntry(id:in)`.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     accessibility label or accessibility value of the associated
///     element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This should be used to
///     bring the Accessibility element on-screen, if scrolling is needed to
///     get to it.
public init(_ labelKey: LocalizedStringKey, id: ID, in namespace: Namespace.ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {})
/// Create a Rotor entry with a specific label, identifier and namespace,
/// and with an optional range.
/// - Parameters:
///   - label: Localized string used to show this Rotor entry
///     to users.
///   - id: Used to find the UI element associated with this
///     Rotor entry. This identifier and namespace should match a call to
///     `accessibilityRotorEntry(id:in)`.
///   - namespace: Namespace for this identifier. Should match a call
///     to `accessibilityRotorEntry(id:in)`.
///   - textRange: Optional range of text associated with this Rotor
///     entry. This should be a range within text that is set as the
///     accessibility label or accessibility value of the associated
///     element.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This should be used to
///     bring the Accessibility element on-screen, if scrolling is needed to
///     get to it.
public init<L>(_ label: L, _ id: ID, in namespace: Namespace.ID, textRange: Range<String.Index>? = nil, prepare: @escaping (() -> Void) = {}) where L : StringProtocol
/// Create a Rotor entry with a specific label and range. This Rotor entry
/// will be associated with the Accessibility element that owns the Rotor.
/// - Parameters:
///   - labelKey: Localized string used to show this Rotor entry
///     to users. If no label is specified, the Rotor entry will be labeled
///     based on the text at that range.
///   - range: Range of text associated with this Rotor
///     entry.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element or text on-screen if it isn't already,
///     and SwiftUI not able to automatically scroll to it.
public init(_ labelKey: LocalizedStringKey, textRange: Range<String.Index>, prepare: @escaping (() -> Void) = {})
/// Create a Rotor entry with a specific label and range. This Rotor entry
/// will be associated with the Accessibility element that owns the Rotor.
/// - Parameters:
///   - label: Localized string used to show this Rotor entry
///     to users. If no label is specified, the Rotor entry will be labeled
///     based on the text at that range.
///   - range: Range of text associated with this Rotor
///     entry.
///   - prepare: Optional closure to run before a Rotor entry
///     is navigated to, to prepare the UI as needed. This can be used to
///     bring the UI element or text on-screen if it isn't already,
///     and SwiftUI not able to automatically scroll to it.
public init<L>(_ label: L, textRange: Range<String.Index>, prepare: @escaping (() -> Void) = {}) where ID == Never, L : StringProtocol
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AccessibilityRotorEntry : AccessibilityRotorContent {
/// The internal content of this `AccessibilityRotorContent`.
public var body: Never { get }
/// The type for the internal content of this `AccessibilityRotorContent`.
public typealias Body = Never
}
/// Designates a Rotor that replaces one of the automatic, system-provided
/// Rotors with a developer-provided Rotor.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AccessibilitySystemRotor : Sendable {
/// System Rotors allowing users to iterate through links or visited links.
public static func links(visited: Bool) -> AccessibilitySystemRotor
/// System Rotor allowing users to iterate through all links.
public static var links: AccessibilitySystemRotor { get }
/// System Rotors allowing users to iterate through all headings, of various
/// heading levels.
public static func headings(level: AccessibilityHeadingLevel) -> AccessibilitySystemRotor
/// System Rotor allowing users to iterate through all headings.
public static var headings: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all the ranges of
/// bolded text.
public static var boldText: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all the ranges of
/// italicized text.
public static var italicText: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all the ranges of
/// underlined text.
public static var underlineText: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all the ranges of
/// mis-spelled words.
public static var misspelledWords: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all images.
public static var images: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all text fields.
public static var textFields: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all tables.
public static var tables: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all lists.
public static var lists: AccessibilitySystemRotor { get }
/// System Rotor allowing users to iterate through all landmarks.
public static var landmarks: AccessibilitySystemRotor { get }
}
/// Accessibility technologies available to the system.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AccessibilityTechnologies : SetAlgebra, Sendable {
/// The value that represents the VoiceOver screen reader, allowing use
/// of the system without seeing the screen visually.
public static var voiceOver: AccessibilityTechnologies
/// The value that represents a Switch Control, allowing the use of the
/// entire system using controller buttons, a breath-controlled switch or similar hardware.
public static var switchControl: AccessibilityTechnologies
/// Creates a new accessibility technologies structure with an empy accessibility technology set.
public init()
/// Returns a new set with the elements of both this and the given set.
///
/// In the following example, the `attendeesAndVisitors` set is made up
/// of the elements of the `attendees` and `visitors` sets:
///
///     let attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors = ["Marcia", "Nathaniel"]
///     let attendeesAndVisitors = attendees.union(visitors)
///     print(attendeesAndVisitors)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     let initialIndices = Set(0..<5)
///     let expandedIndices = initialIndices.union([2, 3, 6, 7])
///     print(expandedIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set with the unique elements of this set and `other`.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func union(_ other: AccessibilityTechnologies) -> AccessibilityTechnologies
/// Adds the elements of the given set to the set.
///
/// In the following example, the elements of the `visitors` set are added to
/// the `attendees` set:
///
///     var attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors: Set = ["Diana", "Marcia", "Nathaniel"]
///     attendees.formUnion(visitors)
///     print(attendees)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     var initialIndices = Set(0..<5)
///     initialIndices.formUnion([2, 3, 6, 7])
///     print(initialIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formUnion(_ other: AccessibilityTechnologies)
/// Returns a new set with the elements that are common to both this set and
/// the given set.
///
/// In the following example, the `bothNeighborsAndEmployees` set is made up
/// of the elements that are in *both* the `employees` and `neighbors` sets.
/// Elements that are in only one or the other are left out of the result of
/// the intersection.
///
///     let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     let bothNeighborsAndEmployees = employees.intersection(neighbors)
///     print(bothNeighborsAndEmployees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func intersection(_ other: AccessibilityTechnologies) -> AccessibilityTechnologies
/// Removes the elements of this set that aren't also in the given set.
///
/// In the following example, the elements of the `employees` set that are
/// not also members of the `neighbors` set are removed. In particular, the
/// names `"Alicia"`, `"Chris"`, and `"Diana"` are removed.
///
///     var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     employees.formIntersection(neighbors)
///     print(employees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formIntersection(_ other: AccessibilityTechnologies)
/// Returns a new set with the elements that are either in this set or in the
/// given set, but not in both.
///
/// In the following example, the `eitherNeighborsOrEmployees` set is made up
/// of the elements of the `employees` and `neighbors` sets that are not in
/// both `employees` *and* `neighbors`. In particular, the names `"Bethany"`
/// and `"Eric"` do not appear in `eitherNeighborsOrEmployees`.
///
///     let employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors)
///     print(eitherNeighborsOrEmployees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
public func symmetricDifference(_ other: AccessibilityTechnologies) -> AccessibilityTechnologies
/// Removes the elements of the set that are also in the given set and adds
/// the members of the given set that are not already in the set.
///
/// In the following example, the elements of the `employees` set that are
/// also members of `neighbors` are removed from `employees`, while the
/// elements of `neighbors` that are not members of `employees` are added to
/// `employees`. In particular, the names `"Bethany"` and `"Eric"` are
/// removed from `employees` while the name `"Forlani"` is added.
///
///     var employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     employees.formSymmetricDifference(neighbors)
///     print(employees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type.
public mutating func formSymmetricDifference(_ other: AccessibilityTechnologies)
/// Returns a Boolean value that indicates whether the given element exists
/// in the set.
///
/// This example uses the `contains(_:)` method to test whether an integer is
/// a member of a set of prime numbers.
///
///     let primes: Set = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
///     let x = 5
///     if primes.contains(x) {
///         print("\(x) is prime!")
///     } else {
///         print("\(x). Not prime.")
///     }
///     // Prints "5 is prime!"
///
/// - Parameter member: An element to look for in the set.
/// - Returns: `true` if `member` exists in the set; otherwise, `false`.
public func contains(_ member: AccessibilityTechnologies) -> Bool
/// Inserts the given element in the set if it is not already present.
///
/// If an element equal to `newMember` is already contained in the set, this
/// method has no effect. In this example, a new element is inserted into
/// `classDays`, a set of days of the week. When an existing element is
/// inserted, the `classDays` set does not change.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.wednesday, .friday]
///     print(classDays.insert(.monday))
///     // Prints "(true, .monday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
///     print(classDays.insert(.friday))
///     // Prints "(false, .friday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: `(true, newMember)` if `newMember` was not contained in the
///   set. If an element equal to `newMember` was already contained in the
///   set, the method returns `(false, oldMember)`, where `oldMember` is the
///   element that was equal to `newMember`. In some cases, `oldMember` may
///   be distinguishable from `newMember` by identity comparison or some
///   other means.
public mutating func insert(_ newMember: AccessibilityTechnologies) -> (inserted: Bool, memberAfterInsert: AccessibilityTechnologies)
/// Removes the given element and any elements subsumed by the given element.
///
/// - Parameter member: The element of the set to remove.
/// - Returns: For ordinary sets, an element equal to `member` if `member` is
///   contained in the set; otherwise, `nil`. In some cases, a returned
///   element may be distinguishable from `member` by identity comparison
///   or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the set
///   and `[member]`, or `nil` if the intersection is empty.
public mutating func remove(_ member: AccessibilityTechnologies) -> AccessibilityTechnologies?
/// Inserts the given element into the set unconditionally.
///
/// If an element equal to `newMember` is already contained in the set,
/// `newMember` replaces the existing element. In this example, an existing
/// element is inserted into `classDays`, a set of days of the week.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.monday, .wednesday, .friday]
///     print(classDays.update(with: .monday))
///     // Prints "Optional(.monday)"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: For ordinary sets, an element equal to `newMember` if the set
///   already contained such a member; otherwise, `nil`. In some cases, the
///   returned element may be distinguishable from `newMember` by identity
///   comparison or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the
///   set and `[newMember]`, or `nil` if the intersection is empty.
public mutating func update(with newMember: AccessibilityTechnologies) -> AccessibilityTechnologies?
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityTechnologies, b: AccessibilityTechnologies) -> Bool
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = AccessibilityTechnologies
/// A type for which the conforming type provides a containment test.
public typealias Element = AccessibilityTechnologies
}
/// Textual context that assistive technologies can use to improve the
/// presentation of spoken text.
///
/// Use an `AccessibilityTextContentType` value when setting the accessibility text content
/// type of a view using the ``View/accessibilityTextContentType(_:)`` modifier.
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AccessibilityTextContentType : Sendable {
/// A type that represents generic text that has no specific type.
public static let plain: AccessibilityTextContentType
/// A type that represents text used for input, like in the Terminal app.
public static let console: AccessibilityTextContentType
/// A type that represents text used by a file browser, like in the Finder app in macOS.
public static let fileSystem: AccessibilityTextContentType
/// A type that represents text used in a message, like in the Messages app.
public static let messaging: AccessibilityTextContentType
/// A type that represents text used in a story or poem, like in the Books app.
public static let narrative: AccessibilityTextContentType
/// A type that represents text used in source code, like in Swift Playgrounds.
public static let sourceCode: AccessibilityTextContentType
/// A type that represents text used in a grid of data, like in the Numbers app.
public static let spreadsheet: AccessibilityTextContentType
/// A type that represents text used in a document, like in the Pages app.
public static let wordProcessing: AccessibilityTextContentType
}
/// A set of accessibility traits that describe how an element behaves.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct AccessibilityTraits : SetAlgebra, Sendable {
/// The accessibility element is a button.
public static let isButton: AccessibilityTraits
/// The accessibility element is a header that divides content into
/// sections, like the title of a navigation bar.
public static let isHeader: AccessibilityTraits
/// The accessibility element is currently selected.
public static let isSelected: AccessibilityTraits
/// The accessibility element is a link.
public static let isLink: AccessibilityTraits
/// The accessibility element is a search field.
public static let isSearchField: AccessibilityTraits
/// The accessibility element is an image.
public static let isImage: AccessibilityTraits
/// The accessibility element plays its own sound when activated.
public static let playsSound: AccessibilityTraits
/// The accessibility element behaves as a keyboard key.
public static let isKeyboardKey: AccessibilityTraits
/// The accessibility element is a static text that cannot be
/// modified by the user.
public static let isStaticText: AccessibilityTraits
/// The accessibility element provides summary information when the
/// application starts.
///
/// Use this trait to characterize an accessibility element that provides
/// a summary of current conditions, settings, or state, like the
/// temperature in the Weather app.
public static let isSummaryElement: AccessibilityTraits
/// The accessibility element frequently updates its label or value.
///
/// Use this trait when you want an assistive technology to poll for
/// changes when it needs updated information. For example, you might use
/// this trait to characterize the readout of a stopwatch.
public static let updatesFrequently: AccessibilityTraits
/// The accessibility element starts a media session when it is activated.
///
/// Use this trait to silence the audio output of an assistive technology,
/// such as VoiceOver, during a media session that should not be interrupted.
/// For example, you might use this trait to silence VoiceOver speech while
/// the user is recording audio.
public static let startsMediaSession: AccessibilityTraits
/// The accessibility element allows direct touch interaction for
/// VoiceOver users.
public static let allowsDirectInteraction: AccessibilityTraits
/// The accessibility element causes an automatic page turn when VoiceOver
/// finishes reading the text within it.
public static let causesPageTurn: AccessibilityTraits
/// The accessibility element is modal.
///
/// Use this trait to restrict which accessibility elements an assistive
/// technology can navigate. When a modal accessibility element is visible,
/// sibling accessibility elements that are not modal are ignored.
public static let isModal: AccessibilityTraits
/// The accessibility element is a toggle.
@available(macOS 14.0, iOS 17.0, tvOS 17.0, watchOS 10.0, *)
public static let isToggle: AccessibilityTraits
/// Creates an empty set.
///
/// This initializer is equivalent to initializing with an empty array
/// literal. For example, you create an empty `Set` instance with either
/// this initializer or with an empty array literal.
///
///     var emptySet = Set<Int>()
///     print(emptySet.isEmpty)
///     // Prints "true"
///
///     emptySet = []
///     print(emptySet.isEmpty)
///     // Prints "true"
public init()
/// Returns a new set with the elements of both this and the given set.
///
/// In the following example, the `attendeesAndVisitors` set is made up
/// of the elements of the `attendees` and `visitors` sets:
///
///     let attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors = ["Marcia", "Nathaniel"]
///     let attendeesAndVisitors = attendees.union(visitors)
///     print(attendeesAndVisitors)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     let initialIndices = Set(0..<5)
///     let expandedIndices = initialIndices.union([2, 3, 6, 7])
///     print(expandedIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set with the unique elements of this set and `other`.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func union(_ other: AccessibilityTraits) -> AccessibilityTraits
/// Adds the elements of the given set to the set.
///
/// In the following example, the elements of the `visitors` set are added to
/// the `attendees` set:
///
///     var attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors: Set = ["Diana", "Marcia", "Nathaniel"]
///     attendees.formUnion(visitors)
///     print(attendees)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     var initialIndices = Set(0..<5)
///     initialIndices.formUnion([2, 3, 6, 7])
///     print(initialIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formUnion(_ other: AccessibilityTraits)
/// Returns a new set with the elements that are common to both this set and
/// the given set.
///
/// In the following example, the `bothNeighborsAndEmployees` set is made up
/// of the elements that are in *both* the `employees` and `neighbors` sets.
/// Elements that are in only one or the other are left out of the result of
/// the intersection.
///
///     let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     let bothNeighborsAndEmployees = employees.intersection(neighbors)
///     print(bothNeighborsAndEmployees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func intersection(_ other: AccessibilityTraits) -> AccessibilityTraits
/// Removes the elements of this set that aren't also in the given set.
///
/// In the following example, the elements of the `employees` set that are
/// not also members of the `neighbors` set are removed. In particular, the
/// names `"Alicia"`, `"Chris"`, and `"Diana"` are removed.
///
///     var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     employees.formIntersection(neighbors)
///     print(employees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formIntersection(_ other: AccessibilityTraits)
/// Returns a new set with the elements that are either in this set or in the
/// given set, but not in both.
///
/// In the following example, the `eitherNeighborsOrEmployees` set is made up
/// of the elements of the `employees` and `neighbors` sets that are not in
/// both `employees` *and* `neighbors`. In particular, the names `"Bethany"`
/// and `"Eric"` do not appear in `eitherNeighborsOrEmployees`.
///
///     let employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors)
///     print(eitherNeighborsOrEmployees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
public func symmetricDifference(_ other: AccessibilityTraits) -> AccessibilityTraits
/// Removes the elements of the set that are also in the given set and adds
/// the members of the given set that are not already in the set.
///
/// In the following example, the elements of the `employees` set that are
/// also members of `neighbors` are removed from `employees`, while the
/// elements of `neighbors` that are not members of `employees` are added to
/// `employees`. In particular, the names `"Bethany"` and `"Eric"` are
/// removed from `employees` while the name `"Forlani"` is added.
///
///     var employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     employees.formSymmetricDifference(neighbors)
///     print(employees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type.
public mutating func formSymmetricDifference(_ other: AccessibilityTraits)
/// Returns a Boolean value that indicates whether the given element exists
/// in the set.
///
/// This example uses the `contains(_:)` method to test whether an integer is
/// a member of a set of prime numbers.
///
///     let primes: Set = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
///     let x = 5
///     if primes.contains(x) {
///         print("\(x) is prime!")
///     } else {
///         print("\(x). Not prime.")
///     }
///     // Prints "5 is prime!"
///
/// - Parameter member: An element to look for in the set.
/// - Returns: `true` if `member` exists in the set; otherwise, `false`.
public func contains(_ member: AccessibilityTraits) -> Bool
/// Inserts the given element in the set if it is not already present.
///
/// If an element equal to `newMember` is already contained in the set, this
/// method has no effect. In this example, a new element is inserted into
/// `classDays`, a set of days of the week. When an existing element is
/// inserted, the `classDays` set does not change.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.wednesday, .friday]
///     print(classDays.insert(.monday))
///     // Prints "(true, .monday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
///     print(classDays.insert(.friday))
///     // Prints "(false, .friday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: `(true, newMember)` if `newMember` was not contained in the
///   set. If an element equal to `newMember` was already contained in the
///   set, the method returns `(false, oldMember)`, where `oldMember` is the
///   element that was equal to `newMember`. In some cases, `oldMember` may
///   be distinguishable from `newMember` by identity comparison or some
///   other means.
public mutating func insert(_ newMember: AccessibilityTraits) -> (inserted: Bool, memberAfterInsert: AccessibilityTraits)
/// Removes the given element and any elements subsumed by the given element.
///
/// - Parameter member: The element of the set to remove.
/// - Returns: For ordinary sets, an element equal to `member` if `member` is
///   contained in the set; otherwise, `nil`. In some cases, a returned
///   element may be distinguishable from `member` by identity comparison
///   or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the set
///   and `[member]`, or `nil` if the intersection is empty.
public mutating func remove(_ member: AccessibilityTraits) -> AccessibilityTraits?
/// Inserts the given element into the set unconditionally.
///
/// If an element equal to `newMember` is already contained in the set,
/// `newMember` replaces the existing element. In this example, an existing
/// element is inserted into `classDays`, a set of days of the week.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.monday, .wednesday, .friday]
///     print(classDays.update(with: .monday))
///     // Prints "Optional(.monday)"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: For ordinary sets, an element equal to `newMember` if the set
///   already contained such a member; otherwise, `nil`. In some cases, the
///   returned element may be distinguishable from `newMember` by identity
///   comparison or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the
///   set and `[newMember]`, or `nil` if the intersection is empty.
public mutating func update(with newMember: AccessibilityTraits) -> AccessibilityTraits?
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityTraits, b: AccessibilityTraits) -> Bool
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = AccessibilityTraits
/// A type for which the conforming type provides a containment test.
public typealias Element = AccessibilityTraits
}
/// Position and direction information of a zoom gesture that someone performs
/// with an assistive technology like VoiceOver.
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
public struct AccessibilityZoomGestureAction {
/// A direction that matches the movement of a zoom gesture performed
/// by an assistive technology, such as a swipe up and down in Voiceover's
/// zoom rotor.
@frozen public enum Direction {
/// The gesture direction that represents zooming in.
case zoomIn
/// The gesture direction that represents zooming out.
case zoomOut
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AccessibilityZoomGestureAction.Direction, b: AccessibilityZoomGestureAction.Direction) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// The zoom gesture's direction.
public let direction: AccessibilityZoomGestureAction.Direction
/// The zoom gesture's activation point, normalized to the accessibility
/// element's frame.
public let location: UnitPoint
/// The zoom gesture's activation point within the window's coordinate
/// space.
public let point: CGPoint
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
extension AccessibilityZoomGestureAction.Direction : Equatable {
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
extension AccessibilityZoomGestureAction.Direction : Hashable {
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
extension AccessibilityZoomGestureAction.Direction : Sendable {
}
/// A gauge style that displays a closed ring that's partially filled in to
/// indicate the gauge's current value.
///
/// Use ``GaugeStyle/accessoryCircularCapacity`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct AccessoryCircularCapacityGaugeStyle : GaugeStyle {
/// Creates an accessory circular capacity gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: AccessoryCircularCapacityGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// A gauge style that displays an open ring with a marker that appears at a
/// point along the ring to indicate the gauge's current value.
///
/// Use ``GaugeStyle/accessoryCircular`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct AccessoryCircularGaugeStyle : GaugeStyle {
/// Creates an accessory circular gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: AccessoryCircularGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// A gauge style that displays bar that fills from leading to trailing
/// edges as the gauge's current value increases.
///
/// Use ``GaugeStyle/accessoryLinearCapacity`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct AccessoryLinearCapacityGaugeStyle : GaugeStyle {
/// Creates an accessory linear capacity gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: AccessoryLinearCapacityGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// A gauge style that displays bar with a marker that appears at a
/// point along the bar to indicate the gauge's current value.
///
/// Use ``GaugeStyle/accessoryLinear`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct AccessoryLinearGaugeStyle : GaugeStyle {
/// Creates an accessory linear gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: AccessoryLinearGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// A representation of an action sheet presentation.
///
/// Use an action sheet when you want the user to make a choice between two
/// or more options, in response to their own action. If you want the user to
/// act in response to the state of the app or the system, rather than a user
/// action, use an ``Alert`` instead.
///
/// You show an action sheet by using the
/// ``View/actionSheet(isPresented:content:)`` view modifier to create an
/// action sheet, which then appears whenever the bound `isPresented` value is
/// `true`. The `content` closure you provide to this modifier produces a
/// customized instance of the `ActionSheet` type. To supply the options, create
/// instances of ``ActionSheet/Button`` to distinguish between ordinary options,
/// destructive options, and cancellation of the user's original action.
///
/// The action sheet handles its own dismissal by setting the bound
/// `isPresented` value back to `false` when the user taps a button in the
/// action sheet.
///
/// The following example creates an action sheet with three options: a Cancel
/// button, a destructive button, and a default button. The second and third of
/// these call methods are named `overwriteWorkout` and `appendWorkout`,
/// respectively.
///
///     @State private var showActionSheet = false
///     var body: some View {
///         Button("Tap to show action sheet") {
///             showActionSheet = true
///         }
///         .actionSheet(isPresented: $showActionSheet) {
///             ActionSheet(title: Text("Resume Workout Recording"),
///                         message: Text("Choose a destination for workout data"),
///                         buttons: [
///                             .cancel(),
///                             .destructive(
///                                 Text("Overwrite Current Workout"),
///                                 action: overwriteWorkout
///                             ),
///                             .default(
///                                 Text("Append to Current Workout"),
///                                 action: appendWorkout
///                             )
///                         ]
///             )
///         }
///     }
///
/// The system may interpret the order of items as they appear in the `buttons`
/// array to accommodate platform conventions. In this example, the Cancel
/// button is the first member of the array, but the action sheet puts it in its
/// standard position at the bottom of the sheet.
///
/// ![An action sheet with the title Resume Workout Recording in bold text and
/// the message Choose a destination for workout data in smaller text. Below
/// the text, three buttons: a destructive Overwrite Current Workout button in
/// red, a default-styled Overwrite Current Workout button, and a Cancel button,
/// farther below and set off in its own button
/// group.](SwiftUI-ActionSheet-cancel-and-destructive.png)
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `View.confirmationDialog(title:isPresented:titleVisibility:presenting::actions:)`instead.")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `View.confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `View.confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use `View.confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
public struct ActionSheet {
/// Creates an action sheet with the provided buttons.
/// - Parameters:
///   - title: The title of the action sheet.
///   - message: The message to display in the body of the action sheet.
///   - buttons: The buttons to show in the action sheet.
public init(title: Text, message: Text? = nil, buttons: [ActionSheet.Button] = [.cancel()])
/// A button representing an operation of an action sheet presentation.
///
/// The ``ActionSheet`` button is type-aliased to the ``Alert`` button type,
/// which provides default, cancel, and destructive styles.
public typealias Button = Alert.Button
}
/// A representation of an alert presentation.
///
/// Use an alert when you want the user to act in response to the state of the
/// app or the system. If you want the user to make a choice in response to
/// their own action, use an ``ActionSheet`` instead.
///
/// You show an alert by using the ``View/alert(isPresented:content:)`` view
/// modifier to create an alert, which then appears whenever the bound
/// `isPresented` value is `true`. The `content` closure you provide to this
/// modifer produces a customized instance of the `Alert` type.
///
/// In the following example, a button presents a simple alert when
/// tapped, by updating a local `showAlert` property that binds to the alert.
///
///     @State private var showAlert = false
///     var body: some View {
///         Button("Tap to show alert") {
///             showAlert = true
///         }
///         .alert(isPresented: $showAlert) {
///             Alert(
///                 title: Text("Current Location Not Available"),
///                 message: Text("Your current location can’t be " +
///                                 "determined at this time.")
///             )
///         }
///     }
///
/// ![A default alert dialog with the title Current Location Not Available in bold
/// text, the message your current location can’t be determined at this time in
/// smaller text, and a default OK button.](SwiftUI-Alert-OK.png)
///
/// To customize the alert, add instances of the ``Alert/Button`` type, which
/// provides standardized buttons for common tasks like canceling and performing
/// destructive actions. The following example uses two buttons: a default
/// button labeled "Try Again" that calls a `saveWorkoutData` method,
/// and a "destructive" button that calls a `deleteWorkoutData` method.
///
///     @State private var showAlert = false
///     var body: some View {
///         Button("Tap to show alert") {
///             showAlert = true
///         }
///         .alert(isPresented: $showAlert) {
///             Alert(
///                 title: Text("Unable to Save Workout Data"),
///                 message: Text("The connection to the server was lost."),
///                 primaryButton: .default(
///                     Text("Try Again"),
///                     action: saveWorkoutData
///                 ),
///                 secondaryButton: .destructive(
///                     Text("Delete"),
///                     action: deleteWorkoutData
///                 )
///             )
///         }
///     }
///
/// ![An alert dialog with the title, Unable to Save Workout Data in bold text, and
/// the message, The connection to the server was lost, in smaller text. Below
/// the text, two buttons: a default button with Try Again in blue text, and a
/// button with Delete in red text.](SwiftUI-Alert-default-and-destructive.png)
///
/// The alert handles its own dismissal when the user taps one of the buttons in the alert, by setting
/// the bound `isPresented` value back to `false`.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `View.alert(title:isPresented:presenting::actions:) instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use `View.alert(title:isPresented:presenting::actions:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `View.alert(title:isPresented:presenting::actions:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `View.alert(title:isPresented:presenting::actions:) instead.")
public struct Alert {
/// Creates an alert with one button.
/// - Parameters:
///   - title: The title of the alert.
///   - message: The message to display in the body of the alert.
///   - dismissButton: The button that dismisses the alert.
public init(title: Text, message: Text? = nil, dismissButton: Alert.Button? = nil)
/// Creates an alert with two buttons.
///
/// The system determines the visual ordering of the buttons.
/// - Parameters:
///   - title: The title of the alert.
///   - message: The message to display in the body of the alert.
///   - primaryButton: The first button to show in the alert.
///   - secondaryButton: The second button to show in the alert.
public init(title: Text, message: Text? = nil, primaryButton: Alert.Button, secondaryButton: Alert.Button)
/// A button representing an operation of an alert presentation.
public struct Button {
/// Creates an alert button with the default style.
/// - Parameters:
///   - label: The text to display on the button.
///   - action: A closure to execute when the user taps or presses the
///   button.
/// - Returns: An alert button with the default style.
public static func `default`(_ label: Text, action: (() -> Void)? = {}) -> Alert.Button
/// Creates an alert button that indicates cancellation, with a custom
/// label.
/// - Parameters:
///   - label: The text to display on the button.
///   - action: A closure to execute when the user taps or presses the
///   button.
/// - Returns: An alert button that indicates cancellation.
public static func cancel(_ label: Text, action: (() -> Void)? = {}) -> Alert.Button
/// Creates an alert button that indicates cancellation, with a
/// system-provided label.
///
/// The system automatically chooses locale-appropriate text for the
/// button's label.
/// - Parameter action: A closure to execute when the user taps or presses the
///   button.
/// - Returns: An alert button that indicates cancellation.
public static func cancel(_ action: (() -> Void)? = {}) -> Alert.Button
/// Creates an alert button with a style that indicates a destructive
/// action.
/// - Parameters:
///   - label: The text to display on the button.
///   - action: A closure to execute when the user taps or presses the
///   button.
/// - Returns: An alert button that indicates a destructive action.
public static func destructive(_ label: Text, action: (() -> Void)? = {}) -> Alert.Button
}
}
/// An alignment in both axes.
///
/// An `Alignment` contains a ``HorizontalAlignment`` guide and a
/// ``VerticalAlignment`` guide. Specify an alignment to direct the behavior of
/// certain layout containers and modifiers, like when you place views in a
/// ``ZStack``, or layer a view in front of or behind another view using
/// ``View/overlay(alignment:content:)`` or
/// ``View/background(alignment:content:)``, respectively. During layout,
/// SwiftUI brings the specified guides of the affected views together,
/// aligning the views.
///
/// SwiftUI provides a set of built-in alignments that represent common
/// combinations of the built-in horizontal and vertical alignment guides.
/// The blue boxes in the following diagram demonstrate the alignment named
/// by each box's label, relative to the background view:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A variety of blue
/// boxes are overlaid atop the square. Each contains the name of a built-in
/// alignment, and is aligned with the square in a way that matches the
/// alignment name. For example, the box lableled center appears at the
/// center of the square.](Alignment-1-iOS)
///
/// The following code generates the diagram above, where each blue box appears
/// in an overlay that's configured with a different alignment:
///
///     struct AlignmentGallery: View {
///         var body: some View {
///             BackgroundView()
///                 .overlay(alignment: .topLeading) { box(".topLeading") }
///                 .overlay(alignment: .top) { box(".top") }
///                 .overlay(alignment: .topTrailing) { box(".topTrailing") }
///                 .overlay(alignment: .leading) { box(".leading") }
///                 .overlay(alignment: .center) { box(".center") }
///                 .overlay(alignment: .trailing) { box(".trailing") }
///                 .overlay(alignment: .bottomLeading) { box(".bottomLeading") }
///                 .overlay(alignment: .bottom) { box(".bottom") }
///                 .overlay(alignment: .bottomTrailing) { box(".bottomTrailing") }
///                 .overlay(alignment: .leadingLastTextBaseline) { box(".leadingLastTextBaseline") }
///                 .overlay(alignment: .trailingFirstTextBaseline) { box(".trailingFirstTextBaseline") }
///         }
///
///         private func box(_ name: String) -> some View {
///             Text(name)
///                 .font(.system(.caption, design: .monospaced))
///                 .padding(2)
///                 .foregroundColor(.white)
///                 .background(.blue.opacity(0.8), in: Rectangle())
///         }
///     }
///
///     private struct BackgroundView: View {
///         var body: some View {
///             Grid(horizontalSpacing: 0, verticalSpacing: 0) {
///                 GridRow {
///                     Text("Some text in an upper quadrant")
///                     Color.gray.opacity(0.3)
///                 }
///                 GridRow {
///                     Color.gray.opacity(0.3)
///                     Text("More text in a lower quadrant")
///                 }
///             }
///             .aspectRatio(1, contentMode: .fit)
///             .foregroundColor(.secondary)
///             .border(.gray)
///         }
///     }
///
/// To avoid crowding, the alignment diagram shows only two of the available
/// text baseline alignments. The others align as their names imply. Notice that
/// the first text baseline alignment aligns with the top-most line of text in
/// the background view, while the last text baseline aligns with the
/// bottom-most line. For more information about text baseline alignment, see
/// ``VerticalAlignment``.
///
/// In a left-to-right language like English, the leading and trailing
/// alignments appear on the left and right edges, respectively. SwiftUI
/// reverses these in right-to-left language environments. For more
/// information, see ``HorizontalAlignment``.
///
/// ### Custom alignment
///
/// You can create custom alignments --- which you typically do to make use
/// of custom horizontal or vertical guides --- by using the
/// ``init(horizontal:vertical:)`` initializer. For example, you can combine
/// a custom vertical guide called `firstThird` with the built-in horizontal
/// ``HorizontalAlignment/center`` guide, and use it to configure a ``ZStack``:
///
///     ZStack(alignment: Alignment(horizontal: .center, vertical: .firstThird)) {
///         // ...
///     }
///
/// For more information about creating custom guides, including the code
/// that creates the custom `firstThird` alignment in the example above,
/// see ``AlignmentID``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Alignment : Equatable {
/// The alignment on the horizontal axis.
///
/// Set this value when you initialize an alignment using the
/// ``init(horizontal:vertical:)`` method. Use one of the built-in
/// ``HorizontalAlignment`` guides, like ``HorizontalAlignment/center``,
/// or a custom guide that you create.
///
/// For information about creating custom guides, see ``AlignmentID``.
public var horizontal: HorizontalAlignment
/// The alignment on the vertical axis.
///
/// Set this value when you initialize an alignment using the
/// ``init(horizontal:vertical:)`` method. Use one of the built-in
/// ``VerticalAlignment`` guides, like ``VerticalAlignment/center``,
/// or a custom guide that you create.
///
/// For information about creating custom guides, see ``AlignmentID``.
public var vertical: VerticalAlignment
/// Creates a custom alignment value with the specified horizontal
/// and vertical alignment guides.
///
/// SwiftUI provides a variety of built-in alignments that combine built-in
/// ``HorizontalAlignment`` and ``VerticalAlignment`` guides. Use this
/// initializer to create a custom alignment that makes use
/// of a custom horizontal or vertical guide, or both.
///
/// For example, you can combine a custom vertical guide called
/// `firstThird` with the built-in ``HorizontalAlignment/center``
/// guide, and use it to configure a ``ZStack``:
///
///     ZStack(alignment: Alignment(horizontal: .center, vertical: .firstThird)) {
///         // ...
///     }
///
/// For more information about creating custom guides, including the code
/// that creates the custom `firstThird` alignment in the example above,
/// see ``AlignmentID``.
///
/// - Parameters:
///   - horizontal: The alignment on the horizontal axis.
///   - vertical: The alignment on the vertical axis.
@inlinable public init(horizontal: HorizontalAlignment, vertical: VerticalAlignment)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Alignment, b: Alignment) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Alignment {
/// A guide that marks the center of the view.
///
/// This alignment combines the ``HorizontalAlignment/center``
/// horizontal guide and the ``VerticalAlignment/center``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, Center, appears at the center of the
/// square.](Alignment-center-1-iOS)
public static let center: Alignment
/// A guide that marks the leading edge of the view.
///
/// This alignment combines the ``HorizontalAlignment/leading``
/// horizontal guide and the ``VerticalAlignment/center``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, Leading, appears on the left edge of the
/// square, centered vertically.](Alignment-leading-1-iOS)
public static let leading: Alignment
/// A guide that marks the trailing edge of the view.
///
/// This alignment combines the ``HorizontalAlignment/trailing``
/// horizontal guide and the ``VerticalAlignment/center``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, Trailing, appears on the right edge of the
/// square, centered vertically.](Alignment-trailing-1-iOS)
public static let trailing: Alignment
/// A guide that marks the top edge of the view.
///
/// This alignment combines the ``HorizontalAlignment/center``
/// horizontal guide and the ``VerticalAlignment/top``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, Top, appears on the top edge of the
/// square, centered horizontally.](Alignment-top-1-iOS)
public static let top: Alignment
/// A guide that marks the bottom edge of the view.
///
/// This alignment combines the ``HorizontalAlignment/center``
/// horizontal guide and the ``VerticalAlignment/bottom``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, Bottom, appears on the bottom edge of the
/// square, centered horizontally.](Alignment-bottom-1-iOS)
public static let bottom: Alignment
/// A guide that marks the top and leading edges of the view.
///
/// This alignment combines the ``HorizontalAlignment/leading``
/// horizontal guide and the ``VerticalAlignment/top``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, topLeading, appears in the upper-left corner of
/// the square.](Alignment-topLeading-1-iOS)
public static let topLeading: Alignment
/// A guide that marks the top and trailing edges of the view.
///
/// This alignment combines the ``HorizontalAlignment/trailing``
/// horizontal guide and the ``VerticalAlignment/top``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, topTrailing, appears in the upper-right corner of
/// the square.](Alignment-topTrailing-1-iOS)
public static let topTrailing: Alignment
/// A guide that marks the bottom and leading edges of the view.
///
/// This alignment combines the ``HorizontalAlignment/leading``
/// horizontal guide and the ``VerticalAlignment/bottom``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, bottomLeading, appears in the lower-left corner of
/// the square.](Alignment-bottomLeading-1-iOS)
public static let bottomLeading: Alignment
/// A guide that marks the bottom and trailing edges of the view.
///
/// This alignment combines the ``HorizontalAlignment/trailing``
/// horizontal guide and the ``VerticalAlignment/bottom``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, bottomTrailing, appears in the lower-right corner of
/// the square.](Alignment-bottomTrailing-1-iOS)
public static let bottomTrailing: Alignment
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Alignment {
/// A guide that marks the top-most text baseline in a view.
///
/// This alignment combines the ``HorizontalAlignment/center``
/// horizontal guide and the ``VerticalAlignment/firstTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, centerFirstTextBaseline, appears aligned with, and
/// partially overlapping, the first line of the text in the upper quadrant,
/// centered horizontally.](Alignment-centerFirstTextBaseline-1-iOS)
public static var centerFirstTextBaseline: Alignment { get }
/// A guide that marks the bottom-most text baseline in a view.
///
/// This alignment combines the ``HorizontalAlignment/center``
/// horizontal guide and the ``VerticalAlignment/lastTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, centerLastTextBaseline, appears aligned with, and
/// partially overlapping, the last line of the text in the lower quadrant,
/// centered horizontally.](Alignment-centerLastTextBaseline-1-iOS)
public static var centerLastTextBaseline: Alignment { get }
/// A guide that marks the leading edge and top-most text baseline in a
/// view.
///
/// This alignment combines the ``HorizontalAlignment/leading``
/// horizontal guide and the ``VerticalAlignment/firstTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, leadingFirstTextBaseline, appears aligned with, and
/// partially overlapping, the first line of the text in the upper quadrant.
/// The box aligns with the left edge of the
/// square.](Alignment-leadingFirstTextBaseline-1-iOS)
public static var leadingFirstTextBaseline: Alignment { get }
/// A guide that marks the leading edge and bottom-most text baseline
/// in a view.
///
/// This alignment combines the ``HorizontalAlignment/leading``
/// horizontal guide and the ``VerticalAlignment/lastTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, leadingLastTextBaseline, appears aligned with the
/// last line of the text in the lower quadrant. The box aligns with the
/// left edge of the square.](Alignment-leadingLastTextBaseline-1-iOS)
public static var leadingLastTextBaseline: Alignment { get }
/// A guide that marks the trailing edge and top-most text baseline in
/// a view.
///
/// This alignment combines the ``HorizontalAlignment/trailing``
/// horizontal guide and the ``VerticalAlignment/firstTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, trailingFirstTextBaseline, appears aligned with the
/// first line of the text in the upper quadrant. The box aligns with the
/// right edge of the square.](Alignment-trailingFirstTextBaseline-1-iOS)
public static var trailingFirstTextBaseline: Alignment { get }
/// A guide that marks the trailing edge and bottom-most text baseline
/// in a view.
///
/// This alignment combines the ``HorizontalAlignment/trailing``
/// horizontal guide and the ``VerticalAlignment/lastTextBaseline``
/// vertical guide:
///
/// ![A square that's divided into four equal quadrants. The upper-
/// left quadrant contains the text, Some text in an upper quadrant. The
/// lower-right quadrant contains the text, More text in a lower quadrant.
/// In both cases, the text is split over two lines. A blue box that
/// contains the text, trailingLastTextBaseline, appears aligned with the
/// last line of the text in the lower quadrant. The box aligns with the
/// right edge of the square.](Alignment-trailingLastTextBaseline-1-iOS)
public static var trailingLastTextBaseline: Alignment { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Alignment : Sendable {
}
/// A type that you use to create custom alignment guides.
///
/// Every built-in alignment guide that ``VerticalAlignment`` or
/// ``HorizontalAlignment`` defines as a static property, like
/// ``VerticalAlignment/top`` or ``HorizontalAlignment/leading``, has a
/// unique alignment identifier type that produces the default offset for
/// that guide. To create a custom alignment guide, define your own alignment
/// identifier as a type that conforms to the `AlignmentID` protocol, and
/// implement the required ``AlignmentID/defaultValue(in:)`` method:
///
///     private struct FirstThirdAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.height / 3
///         }
///     }
///
/// When implementing the method, calculate the guide's default offset
/// from the view's origin. If it's helpful, you can use information from the
/// ``ViewDimensions`` input in the calculation. This parameter provides context
/// about the specific view that's using the guide. The above example creates an
/// identifier called `FirstThirdAlignment` and calculates a default value
/// that's one-third of the height of the aligned view.
///
/// Use the identifier's type to create a static property in an extension of
/// one of the alignment guide types, like ``VerticalAlignment``:
///
///     extension VerticalAlignment {
///         static let firstThird = VerticalAlignment(FirstThirdAlignment.self)
///     }
///
/// You can apply your custom guide like any of the built-in guides. For
/// example, you can use an ``HStack`` to align its views at one-third
/// of their height using the guide defined above:
///
///     struct StripesGroup: View {
///         var body: some View {
///             HStack(alignment: .firstThird, spacing: 1) {
///                 HorizontalStripes().frame(height: 60)
///                 HorizontalStripes().frame(height: 120)
///                 HorizontalStripes().frame(height: 90)
///             }
///         }
///     }
///
///     struct HorizontalStripes: View {
///         var body: some View {
///             VStack(spacing: 1) {
///                 ForEach(0..<3) { _ in Color.blue }
///             }
///         }
///     }
///
/// Because each set of stripes has three equal, vertically stacked
/// rectangles, they align at the bottom edge of the top rectangle. This
/// corresponds in each case to a third of the overall height, as
/// measured from the origin at the top of each set of stripes:
///
/// ![Three vertical stacks of rectangles, arranged in a row.
/// The rectangles in each stack have the same height as each other, but
/// different heights than the rectangles in the other stacks. The bottom edges
/// of the top-most rectangle in each stack are aligned with each
/// other.](AlignmentId-1-iOS)
///
/// You can also use the ``View/alignmentGuide(_:computeValue:)-6y3u2`` view
/// modifier to alter the behavior of your custom guide for a view, as you
/// might alter a built-in guide. For example, you can change
/// one of the stacks of stripes from the previous example to align its
/// `firstThird` guide at two thirds of the height instead:
///
///     struct StripesGroupModified: View {
///         var body: some View {
///             HStack(alignment: .firstThird, spacing: 1) {
///                 HorizontalStripes().frame(height: 60)
///                 HorizontalStripes().frame(height: 120)
///                 HorizontalStripes().frame(height: 90)
///                     .alignmentGuide(.firstThird) { context in
///                         2 * context.height / 3
///                     }
///             }
///         }
///     }
///
/// The modified guide calculation causes the affected view to place the
/// bottom edge of its middle rectangle on the `firstThird` guide, which aligns
/// with the bottom edge of the top rectangle in the other two groups:
///
/// ![Three vertical stacks of rectangles, arranged in a row.
/// The rectangles in each stack have the same height as each other, but
/// different heights than the rectangles in the other stacks. The bottom edges
/// of the top-most rectangle in the first two stacks are aligned with each
/// other, and with the bottom edge of the middle rectangle in the third
/// stack.](AlignmentId-2-iOS)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol AlignmentID {
/// Calculates a default value for the corresponding guide in the specified
/// context.
///
/// Implement this method when you create a type that conforms to the
/// ``AlignmentID`` protocol. Use the method to calculate the default
/// offset of the corresponding alignment guide. SwiftUI interprets the
/// value that you return as an offset in the coordinate space of the
/// view that's being laid out. For example, you can use the context to
/// return a value that's one-third of the height of the view:
///
///     private struct FirstThirdAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.height / 3
///         }
///     }
///
/// You can override the default value that this method returns for a
/// particular guide by adding the
/// ``View/alignmentGuide(_:computeValue:)-9mdoh`` view modifier to a
/// particular view.
///
/// - Parameter context: The context of the view that you apply
///   the alignment guide to. The context gives you the view's dimensions,
///   as well as the values of other alignment guides that apply to the
///   view, including both built-in and custom guides. You can use any of
///   these values, if helpful, to calculate the value for your custom
///   guide.
///
/// - Returns: The offset of the guide from the origin in the
///   view's coordinate space.
static func defaultValue(in context: ViewDimensions) -> CGFloat
}
/// An opaque value derived from an anchor source and a particular view.
///
/// You can convert the anchor to a `Value` in the coordinate space of a target
/// view by using a ``GeometryProxy`` to specify the target view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Anchor<Value> {
/// A type-erased geometry value that produces an anchored value of a given
/// type.
///
/// SwiftUI passes anchored geometry values around the view tree via
/// preference keys. It then converts them back into the local coordinate
/// space using a ``GeometryProxy`` value.
@frozen public struct Source {
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor : Sendable where Value : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Anchor : Equatable where Value : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: Anchor<Value>, rhs: Anchor<Value>) -> Bool
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Anchor : Hashable where Value : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor.Source : Sendable where Value : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor.Source {
public init<T>(_ array: [Anchor<T>.Source]) where Value == [T]
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor.Source {
public init<T>(_ anchor: Anchor<T>.Source?) where Value == T?
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor.Source where Value == CGPoint {
public static func point(_ p: CGPoint) -> Anchor<Value>.Source
public static func unitPoint(_ p: UnitPoint) -> Anchor<Value>.Source
public static var topLeading: Anchor<CGPoint>.Source { get }
public static var top: Anchor<CGPoint>.Source { get }
public static var topTrailing: Anchor<CGPoint>.Source { get }
public static var leading: Anchor<CGPoint>.Source { get }
public static var center: Anchor<CGPoint>.Source { get }
public static var trailing: Anchor<CGPoint>.Source { get }
public static var bottomLeading: Anchor<CGPoint>.Source { get }
public static var bottom: Anchor<CGPoint>.Source { get }
public static var bottomTrailing: Anchor<CGPoint>.Source { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Anchor.Source where Value == CGRect {
/// Returns an anchor source rect defined by `r` in the current view.
public static func rect(_ r: CGRect) -> Anchor<Value>.Source
/// An anchor source rect defined as the entire bounding rect of the current
/// view.
public static var bounds: Anchor<CGRect>.Source { get }
}
/// A geometric angle whose value you access in either radians or degrees.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Angle {
public var radians: Double
@inlinable public var degrees: Double
@inlinable public init()
@inlinable public init(radians: Double)
@inlinable public init(degrees: Double)
@inlinable public static func radians(_ radians: Double) -> Angle
@inlinable public static func degrees(_ degrees: Double) -> Angle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Angle : Hashable, Comparable {
/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
@inlinable public static func < (lhs: Angle, rhs: Angle) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Angle, b: Angle) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Angle : Animatable {
/// The data to animate.
public var animatableData: Double
@inlinable public static var zero: Angle { get }
/// The type defining the data to animate.
public typealias AnimatableData = Double
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Angle : Sendable {
}
/// An angular gradient.
///
/// An angular gradient is also known as a "conic" gradient. This gradient
/// applies the color function as the angle changes, relative to a center
/// point and defined start and end angles. If `endAngle - startAngle > 2π`,
/// the gradient only draws the last complete turn. If
/// `endAngle - startAngle < 2π`, the gradient fills the missing area with
/// the colors defined by gradient locations one and zero, transitioning
/// between the two halfway across the missing area. The gradient maps the
/// unit space center point into the bounding rectangle of each shape filled
/// with the gradient.
///
/// When using an angular gradient as a shape style, you can also use
/// ``ShapeStyle/angularGradient(_:center:startAngle:endAngle:)-378tu``,
/// ``ShapeStyle/conicGradient(_:center:angle:)-e0rd``, or similar methods.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct AngularGradient : ShapeStyle, View, Sendable {
/// Creates an angular gradient.
public init(gradient: Gradient, center: UnitPoint, startAngle: Angle = .zero, endAngle: Angle = .zero)
/// Creates an angular gradient from a collection of colors.
public init(colors: [Color], center: UnitPoint, startAngle: Angle, endAngle: Angle)
/// Creates an angular gradient from a collection of color stops.
public init(stops: [Gradient.Stop], center: UnitPoint, startAngle: Angle, endAngle: Angle)
/// Creates a conic gradient that completes a full turn.
public init(gradient: Gradient, center: UnitPoint, angle: Angle = .zero)
/// Creates a conic gradient from a collection of colors that completes
/// a full turn.
public init(colors: [Color], center: UnitPoint, angle: Angle = .zero)
/// Creates a conic gradient from a collection of color stops that
/// completes a full turn.
public init(stops: [Gradient.Stop], center: UnitPoint, angle: Angle = .zero)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A type that describes how to animate a property of a view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol Animatable {
/// The type defining the data to animate.
associatedtype AnimatableData : VectorArithmetic
/// The data to animate.
var animatableData: Self.AnimatableData { get set }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animatable where Self : VectorArithmetic {
/// The data to animate.
public var animatableData: Self
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animatable where Self.AnimatableData == EmptyAnimatableData {
/// The data to animate.
public var animatableData: EmptyAnimatableData
}
/// A modifier that can create another modifier with animation.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use Animatable directly")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use Animatable directly")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use Animatable directly")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use Animatable directly")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use Animatable directly")
public protocol AnimatableModifier : Animatable, ViewModifier {
}
/// A pair of animatable values, which is itself animatable.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct AnimatablePair<First, Second> : VectorArithmetic where First : VectorArithmetic, Second : VectorArithmetic {
/// The first value.
public var first: First
/// The second value.
public var second: Second
/// Creates an animated pair with the provided values.
@inlinable public init(_ first: First, _ second: Second)
/// The zero value.
///
/// Zero is the identity element for addition. For any value,
/// `x + .zero == x` and `.zero + x == x`.
public static var zero: AnimatablePair<First, Second> { get }
/// Adds two values and stores the result in the left-hand-side variable.
///
/// - Parameters:
///   - lhs: The first value to add.
///   - rhs: The second value to add.
public static func += (lhs: inout AnimatablePair<First, Second>, rhs: AnimatablePair<First, Second>)
/// Subtracts the second value from the first and stores the difference in the
/// left-hand-side variable.
///
/// - Parameters:
///   - lhs: A numeric value.
///   - rhs: The value to subtract from `lhs`.
public static func -= (lhs: inout AnimatablePair<First, Second>, rhs: AnimatablePair<First, Second>)
/// Adds two values and produces their sum.
///
/// The addition operator (`+`) calculates the sum of its two arguments. For
/// example:
///
///     1 + 2                   // 3
///     -10 + 15                // 5
///     -15 + -5                // -20
///     21.5 + 3.25             // 24.75
///
/// You cannot use `+` with arguments of different types. To add values of
/// different types, convert one of the values to the other value's type.
///
///     let x: Int8 = 21
///     let y: Int = 1000000
///     Int(x) + y              // 1000021
///
/// - Parameters:
///   - lhs: The first value to add.
///   - rhs: The second value to add.
public static func + (lhs: AnimatablePair<First, Second>, rhs: AnimatablePair<First, Second>) -> AnimatablePair<First, Second>
/// Subtracts one value from another and produces their difference.
///
/// The subtraction operator (`-`) calculates the difference of its two
/// arguments. For example:
///
///     8 - 3                   // 5
///     -10 - 5                 // -15
///     100 - -5                // 105
///     10.5 - 100.0            // -89.5
///
/// You cannot use `-` with arguments of different types. To subtract values
/// of different types, convert one of the values to the other value's type.
///
///     let x: UInt8 = 21
///     let y: UInt = 1000000
///     y - UInt(x)             // 999979
///
/// - Parameters:
///   - lhs: A numeric value.
///   - rhs: The value to subtract from `lhs`.
public static func - (lhs: AnimatablePair<First, Second>, rhs: AnimatablePair<First, Second>) -> AnimatablePair<First, Second>
/// Multiplies each component of this value by the given value.
public mutating func scale(by rhs: Double)
/// The dot-product of this animated pair with itself.
public var magnitudeSquared: Double { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AnimatablePair<First, Second>, b: AnimatablePair<First, Second>) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnimatablePair : Sendable where First : Sendable, Second : Sendable {
}
/// The way a view changes over time to create a smooth visual transition from
/// one state to another.
///
/// An `Animation` provides a visual transition of a view when a state value
/// changes from one value to another. The characteristics of this transition
/// vary according to the animation type. For instance, a ``linear`` animation
/// provides a mechanical feel to the animation because its speed is consistent
/// from start to finish. In contrast, an animation that uses easing, like
/// ``easeOut``, offers a more natural feel by varying the acceleration
/// of the animation.
///
/// To apply an animation to a view, add the ``View/animation(_:value:)``
/// modifier, and specify both an animation type and the value to animate. For
/// instance, the ``Circle`` view in the following code performs an
/// ``easeIn`` animation each time the state variable `scale` changes:
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scaleEffect(scale)
///                     .animation(.easeIn, value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///             .padding()
///         }
///
/// @Video(source: "animation-01-overview-easein.mp4", poster: "animation-01-overview-easein.png", alt: "A video that shows a circle enlarging then shrinking to its original size using an ease-in animation.")
///
/// When the value of `scale` changes, the modifier
/// ``View/scaleEffect(_:anchor:)-pmi7`` resizes ``Circle`` according to the
/// new value. SwiftUI can animate the transition between sizes because
/// ``Circle`` conforms to the ``Shape`` protocol. Shapes in SwiftUI conform to
/// the ``Animatable`` protocol, which describes how to animate a property of a
/// view.
///
/// In addition to adding an animation to a view, you can also configure the
/// animation by applying animation modifiers to the animation type. For
/// example, you can:
///
/// - Delay the start of the animation by using the ``delay(_:)`` modifier.
/// - Repeat the animation by using the ``repeatCount(_:autoreverses:)`` or
/// ``repeatForever(autoreverses:)`` modifiers.
/// - Change the speed of the animation by using the ``speed(_:)`` modifier.
///
/// For example, the ``Circle`` view in the following code repeats
/// the ``easeIn`` animation three times by using the
/// ``repeatCount(_:autoreverses:)`` modifier:
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scaleEffect(scale)
///                     .animation(.easeIn.repeatCount(3), value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///             .padding()
///         }
///     }
///
/// @Video(source: "animation-02-overview-easein-repeat.mp4", poster: "animation-02-overview-easein-repeat.png", alt: "A video that shows a circle that repeats the ease-in animation three times: enlarging, then shrinking, then enlarging again. The animation reverses causing the circle to shrink, then enlarge, then shrink to its original size.")
///
/// A view can also perform an animation when a binding value changes. To
/// specify the animation type on a binding, call its ``Binding/animation(_:)``
/// method. For example, the view in the following code performs a
/// ``linear`` animation, moving the box truck between the leading and trailing
/// edges of the view. The truck moves each time a person clicks the ``Toggle``
/// control, which changes the value of the `$isTrailing` binding.
///
///     struct ContentView: View {
///         @State private var isTrailing = false
///
///         var body: some View {
///            VStack(alignment: isTrailing ? .trailing : .leading) {
///                 Image(systemName: "box.truck")
///                     .font(.system(size: 64))
///
///                 Toggle("Move to trailing edge",
///                        isOn: $isTrailing.animation(.linear))
///             }
///         }
///     }
///
/// @Video(source: "animation-03-overview-binding.mp4", poster: "animation-03-overview-binding.png", alt: "A video that shows a box truck that moves from the leading edge of a view to the trailing edge. The box truck then returns to the view's leading edge.")
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Animation : Equatable, Sendable {
/// Create an `Animation` that contains the specified custom animation.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init<A>(_ base: A) where A : CustomAnimation
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: Animation, rhs: Animation) -> Bool
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Animation : Hashable {
/// Calculates the current value of the animation.
///
/// - Returns: The current value of the animation, or `nil` if the animation has finished.
public func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic
/// Calculates the current velocity of the animation.
///
/// - Returns: The current velocity of the animation, or `nil` if the the velocity isn't available.
public func velocity<V>(value: V, time: TimeInterval, context: AnimationContext<V>) -> V? where V : VectorArithmetic
/// Returns a Boolean value that indicates whether the current animation
/// should merge with a previous animation.
public func shouldMerge<V>(previous: Animation, value: V, time: TimeInterval, context: inout AnimationContext<V>) -> Bool where V : VectorArithmetic
public var base: CustomAnimation { get }
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation : CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable {
/// A textual representation of this instance.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(describing:)`
/// initializer. This initializer works with any type, and uses the custom
/// `description` property for types that conform to
/// `CustomStringConvertible`:
///
///     struct Point: CustomStringConvertible {
///         let x: Int, y: Int
///
///         var description: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(describing: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `description` property.
public var description: String { get }
/// A textual representation of this instance, suitable for debugging.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(reflecting:)`
/// initializer. This initializer works with any type, and uses the custom
/// `debugDescription` property for types that conform to
/// `CustomDebugStringConvertible`:
///
///     struct Point: CustomDebugStringConvertible {
///         let x: Int, y: Int
///
///         var debugDescription: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(reflecting: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `debugDescription` property.
public var debugDescription: String { get }
/// The custom mirror for this instance.
///
/// If this type has value semantics, the mirror should be unaffected by
/// subsequent mutations of the instance.
public var customMirror: Mirror { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Animation {
/// A persistent spring animation.
///
/// When mixed with other `spring()`
/// or `interactiveSpring()` animations on the same property, each
/// animation will be replaced by their successor, preserving
/// velocity from one animation to the next. Optionally blends the
/// duration values between springs over a time period.
public static func spring(_ spring: Spring, blendDuration: TimeInterval = 0.0) -> Animation
/// An interpolating spring animation that uses a damped spring
/// model to produce values in the range of one to zero.
///
/// These vales are used to interpolate within the `[from, to]` range
/// of the animated
/// property. Preserves velocity across overlapping animations by
/// adding the effects of each animation.
public static func interpolatingSpring(_ spring: Spring, initialVelocity: Double = 0.0) -> Animation
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Animation {
/// Creates a new animation with speed controlled by the given curve.
///
/// - Parameters:
///   - timingCurve: A curve that describes the speed of the
///     animation over its duration.
///   - duration: The duration of the animation, in seconds.
public static func timingCurve(_ curve: UnitCurve, duration: TimeInterval) -> Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// Repeats the animation for a specific number of times.
///
/// Use this method to repeat the animation a specific number of times. For
/// example, in the following code, the animation moves a truck from one
/// edge of the view to the other edge. It repeats this animation three
/// times.
///
///     struct ContentView: View {
///         @State private var driveForward = true
///
///         private var driveAnimation: Animation {
///             .easeInOut
///             .repeatCount(3, autoreverses: true)
///             .speed(0.5)
///         }
///
///         var body: some View {
///             VStack(alignment: driveForward ? .leading : .trailing, spacing: 40) {
///                 Image(systemName: "box.truck")
///                     .font(.system(size: 48))
///                     .animation(driveAnimation, value: driveForward)
///
///                 HStack {
///                     Spacer()
///                     Button("Animate") {
///                         driveForward.toggle()
///                     }
///                     Spacer()
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-16-repeat-count.mp4", poster: "animation-16-repeat-count.png", alt: "A video that shows a box truck moving from the leading edge of a view to the trailing edge, and back again before looping in the opposite direction.")
///
/// The first time the animation runs, the truck moves from the leading
/// edge to the trailing edge of the view. The second time the animation
/// runs, the truck moves from the trailing edge to the leading edge
/// because `autoreverse` is `true`. If `autoreverse` were `false`, the
/// truck would jump back to leading edge before moving to the trailing
/// edge. The third time the animation runs, the truck moves from the
/// leading to the trailing edge of the view.
///
/// - Parameters:
///   - repeatCount: The number of times that the animation repeats. Each
///   repeated sequence starts at the beginning when `autoreverse` is
///  `false`.
///   - autoreverses: A Boolean value that indicates whether the animation
///   sequence plays in reverse after playing forward. Autoreverse counts
///   towards the `repeatCount`. For instance, a `repeatCount` of one plays
///   the animation forward once, but it doesn’t play in reverse even if
///   `autoreverse` is `true`. When `autoreverse` is `true` and
///   `repeatCount` is `2`, the animation moves forward, then reverses, then
///   stops.
/// - Returns: An animation that repeats for specific number of times.
public func repeatCount(_ repeatCount: Int, autoreverses: Bool = true) -> Animation
/// Repeats the animation for the lifespan of the view containing the
/// animation.
///
/// Use this method to repeat the animation until the instance of the view
/// no longer exists, or the view’s explicit or structural identity
/// changes. For example, the following code continuously rotates a
/// gear symbol for the lifespan of the view.
///
///     struct ContentView: View {
///         @State private var rotationDegrees = 0.0
///
///         private var animation: Animation {
///             .linear
///             .speed(0.1)
///             .repeatForever(autoreverses: false)
///         }
///
///         var body: some View {
///             Image(systemName: "gear")
///                 .font(.system(size: 86))
///                 .rotationEffect(.degrees(rotationDegrees))
///                 .onAppear {
///                     withAnimation(animation) {
///                         rotationDegrees = 360.0
///                     }
///                 }
///         }
///     }
///
/// @Video(source: "animation-17-repeat-forever.mp4", poster: "animation-17-repeat-forever.png", alt: "A video that shows a gear that continuously rotates clockwise.")
///
/// - Parameter autoreverses: A Boolean value that indicates whether the
/// animation sequence plays in reverse after playing forward.
/// - Returns: An animation that continuously repeats.
public func repeatForever(autoreverses: Bool = true) -> Animation
}
extension Animation {
/// Causes the animation to report logical completion after the specified
/// duration, if it has not already logically completed.
///
/// Note that the indicated duration will not cause the animation to
/// continue running after the base animation has fully completed.
///
/// If the animation is removed before the given duration is reached,
/// logical completion will be reported immediately.
///
/// - Parameters:
///   - duration: The duration after which the animation should  report
///     that it is logically complete.
/// - Returns: An animation that reports logical completion after the
///   given duration.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func logicallyComplete(after duration: TimeInterval) -> Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// An animation with a specified duration that combines the behaviors of
/// in and out easing animations.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. An ease in and out animation
/// starts slowly, increasing its speed towards the halfway point, and
/// finally decreasing the speed towards the end of the animation.
///
/// Use `easeInOut(duration:)` when you want to specify the time it takes
/// for the animation to complete. Otherwise, use ``easeInOut`` to perform
/// the animation for a default length of time.
///
/// The following code shows an example of animating the size changes of
/// a ``Circle`` using an ease in and out animation with a duration of
/// one second.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeInOut(duration: 1.0), value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-13-easeineaseout-duration.mp4", poster: "animation-13-easeineaseout-duration.png", alt: "A video that shows a circle enlarging for one second, then shrinking for another second to its original size using an ease-in ease-out animation.")
///
/// - Parameter duration: The length of time, expressed in seconds, that
/// the animation takes to complete.
///
/// - Returns: An ease-in ease-out animation with a specified duration.
public static func easeInOut(duration: TimeInterval) -> Animation
/// An animation that combines the behaviors of in and out easing
/// animations.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. An ease in and out animation
/// starts slowly, increasing its speed towards the halfway point, and
/// finally decreasing the speed towards the end of the animation.
///
/// The `easeInOut` animation has a default duration of 0.35 seconds. To
/// specify the duration, use the ``easeInOut(duration:)`` method.
///
/// The following code shows an example of animating the size changes of a
/// ``Circle`` using an ease in and out animation.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeInOut, value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-12-easeineaseout.mp4", poster: "animation-12-easeineaseout.png", alt: "A video that shows a circle enlarging, then shrinking to its original size using an ease-in ease-out animation.")
///
/// - Returns: An ease-in ease-out animation with the default duration.
public static var easeInOut: Animation { get }
/// An animation with a specified duration that starts slowly and then
/// increases speed towards the end of the movement.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. With an ease in animation, the
/// motion starts slowly and increases its speed towards the end.
///
/// Use `easeIn(duration:)` when you want to specify the time it takes
/// for the animation to complete. Otherwise, use ``easeIn`` to perform the
/// animation for a default length of time.
///
/// The following code shows an example of animating the size changes of
/// a ``Circle`` using an ease in animation with a duration of one
/// second.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeIn(duration: 1.0), value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-09-easein-duration.mp4", poster: "animation-09-easein-duration.png", alt: "A video that shows a circle enlarging for one second, then shrinking for another second to its original size using an ease-in animation.")
///
/// - Parameter duration: The length of time, expressed in seconds, that
/// the animation takes to complete.
///
/// - Returns: An ease-in animation with a specified duration.
public static func easeIn(duration: TimeInterval) -> Animation
/// An animation that starts slowly and then increases speed towards the
/// end of the movement.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. With an ease in animation, the
/// motion starts slowly and increases its speed towards the end.
///
/// The `easeIn` animation has a default duration of 0.35 seconds. To
/// specify a different duration, use ``easeIn(duration:)``.
///
/// The following code shows an example of animating the size changes of
/// a ``Circle`` using the ease in animation.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeIn, value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-08-easein.mp4", poster: "animation-08-easein.png", alt: "A video that shows a circle enlarging, then shrinking to its original size using an ease-in animation.")
///
/// - Returns: An ease-in animation with the default duration.
public static var easeIn: Animation { get }
/// An animation with a specified duration that starts quickly and then
/// slows towards the end of the movement.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. With an ease out animation, the
/// motion starts quickly and decreases its speed towards the end.
///
/// Use `easeOut(duration:)` when you want to specify the time it takes
/// for the animation to complete. Otherwise, use ``easeOut`` to perform
/// the animation for a default length of time.
///
/// The following code shows an example of animating the size changes of
/// a ``Circle`` using an ease out animation with a duration of one
/// second.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeOut(duration: 1.0), value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-09-easein-duration.mp4", poster: "animation-09-easein-duration.png", alt: "A video that shows a circle enlarging for one second, then shrinking for another second to its original size using an ease-in animation.")
///
/// - Parameter duration: The length of time, expressed in seconds, that
/// the animation takes to complete.
///
/// - Returns: An ease-out animation with a specified duration.
public static func easeOut(duration: TimeInterval) -> Animation
/// An animation that starts quickly and then slows towards the end of the
/// movement.
///
/// An easing animation provides motion with a natural feel by varying
/// the acceleration and deceleration of the animation, which matches
/// how things tend to move in reality. With an ease out animation, the
/// motion starts quickly and decreases its speed towards the end.
///
/// The `easeOut` animation has a default duration of 0.35 seconds. To
/// specify a different duration, use ``easeOut(duration:)``.
///
/// The following code shows an example of animating the size changes of
/// a ``Circle`` using an ease out animation.
///
///     struct ContentView: View {
///         @State private var scale = 0.5
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scale(scale)
///                     .animation(.easeOut, value: scale)
///                 HStack {
///                     Button("+") { scale += 0.1 }
///                     Button("-") { scale -= 0.1 }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-10-easeout.mp4", poster: "animation-10-easeout.png", alt: "A video that shows a circle enlarging, then shrinking to its original size using an ease-out animation.")
///
/// - Returns: An ease-out animation with the default duration.
public static var easeOut: Animation { get }
/// An animation that moves at a constant speed during a specified
/// duration.
///
/// A linear animation provides a mechanical feel to the motion because its
/// speed is consistent from start to finish of the animation. This
/// constant speed makes a linear animation ideal for animating the
/// movement of objects where changes in the speed might feel awkward, such
/// as with an activity indicator.
///
/// Use `linear(duration:)` when you want to specify the time it takes
/// for the animation to complete. Otherwise, use ``linear`` to perform the
/// animation for a default length of time.
///
/// The following code shows an example of using linear animation with a
/// duration of two seconds to animate the movement of a circle as it moves
/// between the leading and trailing edges of the view. The color of the
/// circle also animates from red to blue as it moves across the view.
///
///     struct ContentView: View {
///         @State private var isActive = false
///
///         var body: some View {
///             VStack(alignment: isActive ? .trailing : .leading) {
///                 Circle()
///                     .fill(isActive ? Color.red : Color.blue)
///                     .frame(width: 50, height: 50)
///
///                 Button("Animate") {
///                     withAnimation(.linear(duration: 2.0)) {
///                         isActive.toggle()
///                     }
///                 }
///                 .frame(maxWidth: .infinity)
///             }
///         }
///     }
///
/// @Video(source: "animation-07-linear-duration.mp4", poster: "animation-07-linear-duration.png", alt: "A video that shows a circle moving from the leading edge of the view to the trailing edge. The color of the circle also changes from red to blue as it moves across the view. Then the circle moves from the trailing edge back to the leading edge while also changing colors from blue to red.")
///
/// - Parameter duration: The length of time, expressed in seconds, that
/// the animation takes to complete.
///
/// - Returns: A linear animation with a specified duration.
public static func linear(duration: TimeInterval) -> Animation
/// An animation that moves at a constant speed.
///
/// A linear animation provides a mechanical feel to the motion because its
/// speed is consistent from start to finish of the animation. This
/// constant speed makes a linear animation ideal for animating the
/// movement of objects where changes in the speed might feel awkward, such
/// as with an activity indicator.
///
/// The following code shows an example of using linear animation to
/// animate the movement of a circle as it moves between the leading and
/// trailing edges of the view. The circle also animates its color change
/// as it moves across the view.
///
///     struct ContentView: View {
///         @State private var isActive = false
///
///         var body: some View {
///             VStack(alignment: isActive ? .trailing : .leading) {
///                 Circle()
///                     .fill(isActive ? Color.red : Color.blue)
///                     .frame(width: 50, height: 50)
///
///                 Button("Animate") {
///                     withAnimation(.linear) {
///                         isActive.toggle()
///                     }
///                 }
///                 .frame(maxWidth: .infinity)
///             }
///         }
///     }
///
/// @Video(source: "animation-06-linear.mp4", poster: "animation-06-linear.png", alt: "A video that shows a circle moving from the leading edge of the view to the trailing edge. The color of the circle also changes from red to blue as it moves across the view. Then the circle moves from the trailing edge back to the leading edge while also changing colors from blue to red.")
///
/// The `linear` animation has a default duration of 0.35 seconds. To
/// specify a different duration, use ``linear(duration:)``.
///
/// - Returns: A linear animation with the default duration.
public static var linear: Animation { get }
/// An animation created from a cubic Bézier timing curve.
///
/// Use this method to create a timing curve based on the control points of
/// a cubic Bézier curve. A cubic Bézier timing curve consists of a line
/// whose starting point is `(0, 0)` and whose end point is `(1, 1)`. Two
/// additional control points, `(p1x, p1y)` and `(p2x, p2y)`, define the
/// shape of the curve.
///
/// The slope of the line defines the speed of the animation at that point
/// in time. A steep slopes causes the animation to appear to run faster,
/// while a shallower slope appears to run slower. The following
/// illustration shows a timing curve where the animation starts and
/// finishes fast, but appears slower through the middle section of the
/// animation.
///
/// ![An illustration of an XY graph that shows the path of a Bézier timing curve that an animation frame follows over time. The horizontal x-axis has a label with the text Time, and a label with the text Frame appears along the vertical y-axis. The path begins at the graph's origin, labeled as (0.0, 0.0). The path moves upwards, forming a concave down shape. At the point of inflection, the path continues upwards, forming a concave up shape. A label with the text First control point (p1x, p1y) appears above the path. Extending from the label is a dotted line pointing to the position (0.1, 0.75) on the graph. Another label with the text Second control point (p2x, p2y) appears below the path. A dotted line extends from the label to the (0.85, 0.35) position on the graph.](Animation-timingCurve-1)
///
/// The following code uses the timing curve from the previous
/// illustration to animate a ``Circle`` as its size changes.
///
///     struct ContentView: View {
///         @State private var scale = 1.0
///
///         var body: some View {
///             VStack {
///                 Circle()
///                     .scaleEffect(scale)
///                     .animation(
///                         .timingCurve(0.1, 0.75, 0.85, 0.35, duration: 2.0),
///                         value: scale)
///
///                 Button("Animate") {
///                     if scale == 1.0 {
///                         scale = 0.25
///                     } else {
///                         scale = 1.0
///                     }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-14-timing-curve.mp4", poster: "animation-14-timing-curve.png", alt: "A video that shows a circle shrinking then growing to its original size using a timing curve animation. The first control point of the time curve is (0.1, 0.75) and the second is (0.85, 0.35).")
///
/// - Parameters:
///   - p1x: The x-coordinate of the first control point of the cubic
///     Bézier curve.
///   - p1y: The y-coordinate of the first control point of the cubic
///     Bézier curve.
///   - p2x: The x-coordinate of the second control point of the cubic
///     Bézier curve.
///   - p2y: The y-coordinate of the second control point of the cubic
///     Bézier curve.
///   - duration: The length of time, expressed in seconds, the animation
///     takes to complete.
/// - Returns: A cubic Bézier timing curve animation.
public static func timingCurve(_ p1x: Double, _ p1y: Double, _ p2x: Double, _ p2y: Double, duration: TimeInterval = 0.35) -> Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// A default animation instance.
///
/// The `default` animation is ``spring(response:dampingFraction:blendDuration:)``
/// with:
///
/// - `response` equal to `0.55`
/// - `dampingFraction` equal to `1.0`
/// - `blendDuration` equal to `0.0`
///
/// Prior to iOS 17, macOS 14, tvOS 17, and watchOS 10, the `default`
/// animation is ``easeInOut``.
///
/// The global function
/// ``withAnimation(_:_:)`` uses the default animation if you don't
/// provide one. For instance, the following code listing shows
/// an example of using the `default` animation to flip the text "Hello"
/// each time someone clicks the Animate button.
///
///     struct ContentView: View {
///         @State private var degrees = Double.zero
///
///         var body: some View {
///             VStack {
///                 Spacer()
///                 Text("Hello")
///                     .font(.largeTitle)
///                     .rotation3DEffect(.degrees(degrees), axis: (x: 0, y: 1, z: 0))
///
///                 Spacer()
///                 Button("Animate") {
///                     withAnimation {
///                         degrees = (degrees == .zero) ? 180 : .zero
///                     }
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-04-default-flip.mp4", poster: "animation-04-default-flip.png", alt: "A video that shows the word Hello flip horizontally so that its letters appear backwards. Then it flips in reverse so that the word Hello appears correctly.")
///
/// To use the `default` animation when adding the ``View/animation(_:value:)``
/// view modifier, specify it explicitly as the animation type. For
/// instance, the following code shows an example of the `default`
/// animation to spin the text "Hello" each time someone clicks the Animate
/// button.
///
///     struct ContentView: View {
///         @State private var degrees = Double.zero
///
///         var body: some View {
///             VStack {
///                 Spacer()
///                 Text("Hello")
///                     .font(.largeTitle)
///                     .rotationEffect(.degrees(degrees))
///                     .animation(.default, value: degrees)
///
///                 Spacer()
///                 Button("Animate") {
///                     degrees = (degrees == .zero) ? 360 : .zero
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-05-default-spin.mp4", poster: "animation-05-default-spin.png", alt: "A video that shows the word Hello spinning clockwise for one full rotation, that is, 360 degrees. Then Hello spins counterclockwise for one full rotation.")
///
/// A `default` animation instance is only equal to other `default`
/// animation instances (using `==`), and not equal to other animation
/// instances even when the animations are identical. For example, if you
/// create an animation using the ``spring(response:dampingFraction:blendDuration:)``
/// modifier with the same parameter values that `default` uses, the
/// animation isn't equal to `default`. This behavior lets you
/// differentiate between animations that you intentionally choose and
/// those that use the `default` animation.
public static let `default`: Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// An interpolating spring animation that uses a damped spring
/// model to produce values in the range [0, 1] that are then used
/// to interpolate within the [from, to] range of the animated
/// property. Preserves velocity across overlapping animations by
/// adding the effects of each animation.
///
/// - Parameters:
///   - mass: The mass of the object attached to the spring.
///   - stiffness: The stiffness of the spring.
///   - damping: The spring damping value.
///   - initialVelocity: the initial velocity of the spring, as
///     a value in the range [0, 1] representing the magnitude of
///     the value being animated.
/// - Returns: a spring animation.
public static func interpolatingSpring(mass: Double = 1.0, stiffness: Double, damping: Double, initialVelocity: Double = 0.0) -> Animation
/// An interpolating spring animation that uses a damped spring
/// model to produce values in the range [0, 1] that are then used
/// to interpolate within the [from, to] range of the animated
/// property. Preserves velocity across overlapping animations by
/// adding the effects of each animation.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - bounce: How bouncy the spring should be. A value of 0 indicates
///     no bounces (a critically damped spring), positive values indicate
///     increasing amounts of bounciness up to a maximum of 1.0
///     (corresponding to undamped oscillation), and negative values
///     indicate overdamped springs with a minimum value of -1.0.
///   - initialVelocity: the initial velocity of the spring, as
///     a value in the range [0, 1] representing the magnitude of
///     the value being animated.
/// - Returns: a spring animation.
public static func interpolatingSpring(duration: TimeInterval = 0.5, bounce: Double = 0.0, initialVelocity: Double = 0.0) -> Animation
/// An interpolating spring animation that uses a damped spring
/// model to produce values in the range [0, 1] that are then used
/// to interpolate within the [from, to] range of the animated
/// property. Preserves velocity across overlapping animations by
/// adding the effects of each animation.
///
/// This uses the default parameter values.
public static var interpolatingSpring: Animation { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// Delays the start of the animation by the specified number of seconds.
///
/// Use this method to delay the start of an animation. For example, the
/// following code animates the height change of two capsules.
/// Animation of the first ``Capsule`` begins immediately. However,
/// animation of the second one doesn't begin until a half second later.
///
///     struct ContentView: View {
///         @State private var adjustBy = 100.0
///
///         var body: some View {
///             VStack(spacing: 40) {
///                 HStack(alignment: .bottom) {
///                     Capsule()
///                         .frame(width: 50, height: 175 - adjustBy)
///                         .animation(.easeInOut, value: adjustBy)
///                     Capsule()
///                         .frame(width: 50, height: 175 + adjustBy)
///                         .animation(.easeInOut.delay(0.5), value: adjustBy)
///                 }
///
///                 Button("Animate") {
///                     adjustBy *= -1
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-15-delay.mp4", poster: "animation-15-delay.png", alt: "A video that shows two capsules side by side that animate using the ease-in ease-out animation. The capsule on the left is short, while the capsule on the right is tall. As they animate, the short capsule grows upwards to match the height of the tall capsule. Then the tall capsule shrinks to match the original height of the short capsule. Then the capsule on the left shrinks to its original height, followed by the capsule on the right growing to its original height.")
///
/// - Parameter delay: The number of seconds to delay the start of the
/// animation.
/// - Returns: An animation with a delayed start.
public func delay(_ delay: TimeInterval) -> Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// Changes the duration of an animation by adjusting its speed.
///
/// Setting the speed of an animation changes the duration of the animation
/// by a factor of `speed`. A higher speed value causes a faster animation
/// sequence due to a shorter duration. For example, a one-second animation
/// with a speed of `2.0` completes in half the time (half a second).
///
///     struct ContentView: View {
///         @State private var adjustBy = 100.0
///
///         private var oneSecondAnimation: Animation {
///            .easeInOut(duration: 1.0)
///         }
///
///         var body: some View {
///             VStack(spacing: 40) {
///                 HStack(alignment: .bottom) {
///                     Capsule()
///                         .frame(width: 50, height: 175 - adjustBy)
///                     Capsule()
///                         .frame(width: 50, height: 175 + adjustBy)
///                 }
///                 .animation(oneSecondAnimation.speed(2.0), value: adjustBy)
///
///                 Button("Animate") {
///                     adjustBy *= -1
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-18-speed.mp4", poster: "animation-18-speed.png", alt: "A video that shows two capsules side by side that animate using the ease-in ease-out animation. The capsule on the left is short, while the capsule on the right is tall. They animate for half a second with the short capsule growing upwards to match the height of the tall capsule. Then the tall capsule shrinks to match the original height of the short capsule. For another half second, the capsule on the left shrinks to its original height, followed by the capsule on the right growing to its original height.")
///
/// Setting `speed` to a lower number slows the animation, extending its
/// duration. For example, a one-second animation with a speed of `0.25`
/// takes four seconds to complete.
///
///     struct ContentView: View {
///         @State private var adjustBy = 100.0
///
///         private var oneSecondAnimation: Animation {
///            .easeInOut(duration: 1.0)
///         }
///
///         var body: some View {
///             VStack(spacing: 40) {
///                 HStack(alignment: .bottom) {
///                     Capsule()
///                         .frame(width: 50, height: 175 - adjustBy)
///                     Capsule()
///                         .frame(width: 50, height: 175 + adjustBy)
///                 }
///                 .animation(oneSecondAnimation.speed(0.25), value: adjustBy)
///
///                 Button("Animate") {
///                     adjustBy *= -1
///                 }
///             }
///         }
///     }
///
/// @Video(source: "animation-19-speed-slow.mp4", poster: "animation-19-speed-slow.png", alt: "A video that shows two capsules side by side that animate using the ease-in ease-out animation. The capsule on the left is short, while the right-side capsule is tall. They animate for four seconds with the short capsule growing upwards to match the height of the tall capsule. Then the tall capsule shrinks to match the original height of the short capsule. For another four seconds, the capsule on the left shrinks to its original height, followed by the capsule on the right growing to its original height.")
///
/// - Parameter speed: The speed at which SwiftUI performs the animation.
/// - Returns: An animation with the adjusted speed.
public func speed(_ speed: Double) -> Animation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Animation {
/// A persistent spring animation. When mixed with other `spring()`
/// or `interactiveSpring()` animations on the same property, each
/// animation will be replaced by their successor, preserving
/// velocity from one animation to the next. Optionally blends the
/// duration values between springs over a time period.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - bounce: How bouncy the spring should be. A value of 0 indicates
///     no bounces (a critically damped spring), positive values indicate
///     increasing amounts of bounciness up to a maximum of 1.0
///     (corresponding to undamped oscillation), and negative values
///     indicate overdamped springs with a minimum value of -1.0.
///   - blendDuration: The duration in seconds over which to
///     interpolate changes to the duration.
/// - Returns: a spring animation.
public static func spring(duration: TimeInterval = 0.5, bounce: Double = 0.0, blendDuration: Double = 0) -> Animation
/// A persistent spring animation. When mixed with other `spring()`
/// or `interactiveSpring()` animations on the same property, each
/// animation will be replaced by their successor, preserving
/// velocity from one animation to the next. Optionally blends the
/// response values between springs over a time period.
///
/// - Parameters:
///   - response: The stiffness of the spring, defined as an
///     approximate duration in seconds. A value of zero requests
///     an infinitely-stiff spring, suitable for driving
///     interactive animations.
///   - dampingFraction: The amount of drag applied to the value
///     being animated, as a fraction of an estimate of amount
///     needed to produce critical damping.
///   - blendDuration: The duration in seconds over which to
///     interpolate changes to the response value of the spring.
/// - Returns: a spring animation.
public static func spring(response: Double = 0.5, dampingFraction: Double = 0.825, blendDuration: TimeInterval = 0) -> Animation
/// A persistent spring animation. When mixed with other `spring()`
/// or `interactiveSpring()` animations on the same property, each
/// animation will be replaced by their successor, preserving
/// velocity from one animation to the next. Optionally blends the
/// response values between springs over a time period.
///
/// This uses the default parameter values.
public static var spring: Animation { get }
/// A convenience for a `spring` animation with a lower
/// `response` value, intended for driving interactive animations.
public static func interactiveSpring(response: Double = 0.15, dampingFraction: Double = 0.86, blendDuration: TimeInterval = 0.25) -> Animation
/// A convenience for a `spring` animation with a lower
/// `duration` value, intended for driving interactive animations.
///
/// This uses the default parameter values.
public static var interactiveSpring: Animation { get }
/// A convenience for a `spring` animation with a lower
/// `response` value, intended for driving interactive animations.
public static func interactiveSpring(duration: TimeInterval = 0.15, extraBounce: Double = 0.0, blendDuration: TimeInterval = 0.25) -> Animation
/// A smooth spring animation with a predefined duration and no bounce.
public static var smooth: Animation { get }
/// A smooth spring animation with a predefined duration and no bounce
/// that can be tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounce should be added to the base
///     bounce of 0.
///   - blendDuration: The duration in seconds over which to interpolate
///     changes to the duration.
public static func smooth(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Animation
/// A spring animation with a predefined duration and small amount of
/// bounce that feels more snappy.
public static var snappy: Animation { get }
/// A spring animation with a predefined duration and small amount of
/// bounce that feels more snappy and can be tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounce should be added to the base
///     bounce of 0.15.
///   - blendDuration: The duration in seconds over which to interpolate
///     changes to the duration.
public static func snappy(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Animation
/// A spring animation with a predefined duration and higher amount of
/// bounce.
public static var bouncy: Animation { get }
/// A spring animation with a predefined duration and higher amount of
/// bounce that can be tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounce should be added to the base
///     bounce of 0.3.
///   - blendDuration: The duration in seconds over which to interpolate
///     changes to the duration.
public static func bouncy(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Animation
}
/// The criteria that determines when an animation is considered finished.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct AnimationCompletionCriteria : Hashable, Sendable {
/// The animation has logically completed, but may still be in its long
/// tail.
///
/// If a subsequent change occurs that creates additional animations on
/// properties with `logicallyComplete` completion callbacks registered,
/// then those callbacks will fire when the animations from the change that
/// they were registered with logically complete, ignoring the new
/// animations.
public static let logicallyComplete: AnimationCompletionCriteria
/// The entire animation is finished and will now be removed.
///
/// If a subsequent change occurs that creates additional animations on
/// properties with `removed` completion callbacks registered, then those
/// callbacks will only fire when *all* of the created animations are
/// complete.
public static let removed: AnimationCompletionCriteria
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: AnimationCompletionCriteria, b: AnimationCompletionCriteria) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Contextual values that a custom animation can use to manage state and
/// access a view's environment.
///
/// The system provides an `AnimationContext` to a ``CustomAnimation`` instance
/// so that the animation can store and retrieve values in an instance of
/// ``AnimationState``. To access these values, use the context's
/// ``AnimationContext/state`` property.
///
/// For more convenient access to state, create an ``AnimationStateKey`` and
/// extend `AnimationContext` to include a computed property that gets and
/// sets the ``AnimationState`` value. Then use this property instead of
/// ``AnimationContext/state`` to retrieve the state of a custom animation. For
/// example, the following code creates an animation state key named
/// `PausableState`. Then the code extends `AnimationContext` to include the
/// `pausableState` property:
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         var paused = false
///         var pauseTime: TimeInterval = 0.0
///
///         static var defaultValue: Self { .init() }
///     }
///
///     extension AnimationContext {
///         fileprivate var pausableState: PausableState<Value> {
///             get { state[PausableState<Value>.self] }
///             set { state[PausableState<Value>.self] = newValue }
///         }
///     }
///
/// To access the pausable state, the custom animation `PausableAnimation` uses
/// the `pausableState` property instead of the ``AnimationContext/state``
/// property:
///
///     struct PausableAnimation: CustomAnimation {
///         let base: Animation
///
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let paused = context.environment.animationPaused
///
///             let pausableState = context.pausableState
///             var pauseTime = pausableState.pauseTime
///             if pausableState.paused != paused {
///                 pauseTime = time - pauseTime
///                 context.pausableState = PausableState(paused: paused, pauseTime: pauseTime)
///             }
///
///             let effectiveTime = paused ? pauseTime : time - pauseTime
///             let result = base.animate(value: value, time: effectiveTime, context: &context)
///             return result
///         }
///     }
///
/// The animation can also retrieve environment values of the view that created
/// the animation. To retrieve a view's environment value, use the context's
/// ``AnimationContext/environment`` property. For instance, the following code
/// creates a custom ``EnvironmentKey`` named `AnimationPausedKey`, and the
/// view `PausableAnimationView` uses the key to store the paused state:
///
///     struct AnimationPausedKey: EnvironmentKey {
///         static let defaultValue = false
///     }
///
///     extension EnvironmentValues {
///         var animationPaused: Bool {
///             get { self[AnimationPausedKey.self] }
///             set { self[AnimationPausedKey.self] = newValue }
///         }
///     }
///
///     struct PausableAnimationView: View {
///         @State private var paused = false
///
///         var body: some View {
///             VStack {
///                 ...
///             }
///             .environment(\.animationPaused, paused)
///         }
///     }
///
/// Then the custom animation `PausableAnimation` retrieves the paused state
/// from the view's environment using the ``AnimationContext/environment``
/// property:
///
///     struct PausableAnimation: CustomAnimation {
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let paused = context.environment.animationPaused
///             ...
///         }
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct AnimationContext<Value> where Value : VectorArithmetic {
/// The current state of a custom animation.
///
/// An instance of ``CustomAnimation`` uses this property to read and
/// write state values as the animation runs.
///
/// An alternative to using the `state` property in a custom animation is
/// to create an ``AnimationStateKey`` type and extend ``AnimationContext``
/// with a custom property that returns the state as a custom type. For
/// example, the following code creates a state key named `PausableState`.
/// It's convenient to store state values in the key type, so the
/// `PausableState` structure includes properties for the stored state
/// values `paused` and `pauseTime`.
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         var paused = false
///         var pauseTime: TimeInterval = 0.0
///
///         static var defaultValue: Self { .init() }
///     }
///
/// To provide access the pausable state, the following code extends
/// `AnimationContext` to include the `pausableState` property. This
/// property returns an instance of the custom `PausableState` structure
/// stored in ``AnimationContext/state``, and it can also store a new
/// `PausableState` instance in `state`.
///
///     extension AnimationContext {
///         fileprivate var pausableState: PausableState<Value> {
///             get { state[PausableState<Value>.self] }
///             set { state[PausableState<Value>.self] = newValue }
///         }
///     }
///
/// Now a custom animation can use the `pausableState` property instead of
/// the ``AnimationContext/state`` property as a convenient way to read and
/// write state values as the animation runs.
///
///     struct PausableAnimation: CustomAnimation {
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let pausableState = context.pausableState
///             var pauseTime = pausableState.pauseTime
///             ...
///         }
///     }
///
public var state: AnimationState<Value>
/// Set this to `true` to indicate that an animation is logically complete.
///
/// This controls when AnimationCompletionCriteria.logicallyComplete
/// completion callbacks are fired. This should be set to `true` at most
/// once in the life of an animation, changing back to `false` later will be
/// ignored. If this is never set to `true`, the behavior is equivalent to
/// if this had been set to `true` just as the animation finished (by
/// returning `nil`).
public var isLogicallyComplete: Bool
/// The current environment of the view that created the custom animation.
///
/// An instance of ``CustomAnimation`` uses this property to read
/// environment values from the view that created the animation. To learn
/// more about environment values including how to define custom
/// environment values, see ``EnvironmentValues``.
public var environment: EnvironmentValues { get }
/// Creates a new context from another one with a state that you provide.
///
/// Use this method to create a new context that contains the state that
/// you provide and view environment values from the original context.
///
/// - Parameter state: The initial state for the new context.
/// - Returns: A new context that contains the specified state.
public func withState<T>(_ state: AnimationState<T>) -> AnimationContext<T> where T : VectorArithmetic
}
/// A container that stores the state for a custom animation.
///
/// An ``AnimationContext`` uses this type to store state for a
/// ``CustomAnimation``. To retrieve the stored state of a context, you can
/// use the ``AnimationContext/state`` property. However, a more convenient
/// way to access the animation state is to define an ``AnimationStateKey``
/// and extend ``AnimationContext`` with a computed property that gets
/// and sets the animation state, as shown in the following code:
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         static var defaultValue: Self { .init() }
///     }
///
///     extension AnimationContext {
///         fileprivate var pausableState: PausableState<Value> {
///             get { state[PausableState<Value>.self] }
///             set { state[PausableState<Value>.self] = newValue }
///         }
///     }
///
/// When creating an ``AnimationStateKey``, it's convenient to define the
/// state values that your custom animation needs. For example, the following
/// code adds the properties `paused` and `pauseTime` to the `PausableState`
/// animation state key:
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         var paused = false
///         var pauseTime: TimeInterval = 0.0
///
///         static var defaultValue: Self { .init() }
///     }
///
/// To access the pausable state in a `PausableAnimation`, the follow code
/// calls `pausableState` instead of using the context's
/// ``AnimationContext/state`` property. And because the animation state key
/// `PausableState` defines properties for state values, the custom animation
/// can read and write those values.
///
///     struct PausableAnimation: CustomAnimation {
///         let base: Animation
///
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let paused = context.environment.animationPaused
///
///             let pausableState = context.pausableState
///             var pauseTime = pausableState.pauseTime
///             if pausableState.paused != paused {
///                 pauseTime = time - pauseTime
///                 context.pausableState = PausableState(paused: paused, pauseTime: pauseTime)
///             }
///
///             let effectiveTime = paused ? pauseTime : time - pauseTime
///             let result = base.animate(value: value, time: effectiveTime, context: &context)
///             return result
///         }
///     }
///
/// ### Storing state for secondary animations
///
/// A custom animation can also use `AnimationState` to store the state of a
/// secondary animation. For example, the following code creates an
/// ``AnimationStateKey`` that includes the property `secondaryState`, which a
/// custom animation can use to store other state:
///
///     private struct TargetState<Value: VectorArithmetic>: AnimationStateKey {
///         var timeDelta = 0.0
///         var valueDelta = Value.zero
///         var secondaryState: AnimationState<Value>? = .init()
///
///         static var defaultValue: Self { .init() }
///     }
///
///     extension AnimationContext {
///         fileprivate var targetState: TargetState<Value> {
///             get { state[TargetState<Value>.self] }
///             set { state[TargetState<Value>.self] = newValue }
///         }
///     }
///
/// The custom animation `TargetAnimation` uses `TargetState` to store state
/// data in `secondaryState` for another animation that runs as part of the
/// target animation.
///
///     struct TargetAnimation: CustomAnimation {
///         var base: Animation
///         var secondary: Animation
///
///         func animate<V: VectorArithmetic>(value: V, time: Double, context: inout AnimationContext<V>) -> V? {
///             var targetValue = value
///             if let secondaryState = context.targetState.secondaryState {
///                 var secondaryContext = context
///                 secondaryContext.state = secondaryState
///                 let secondaryValue = value - context.targetState.valueDelta
///                 let result = secondary.animate(
///                     value: secondaryValue, time: time - context.targetState.timeDelta,
///                     context: &secondaryContext)
///                 if let result = result {
///                     context.targetState.secondaryState = secondaryContext.state
///                     targetValue = result + context.targetState.valueDelta
///                 } else {
///                     context.targetState.secondaryState = nil
///                 }
///             }
///             let result = base.animate(value: targetValue, time: time, context: &context)
///             if let result = result {
///                 targetValue = result
///             } else if context.targetState.secondaryState == nil {
///                 return nil
///             }
///             return targetValue
///     }
///
///         func shouldMerge<V: VectorArithmetic>(previous: Animation, value: V, time: Double, context: inout AnimationContext<V>) -> Bool {
///             guard let previous = previous.base as? Self else { return false }
///             var secondaryContext = context
///             if let secondaryState = context.targetState.secondaryState {
///                 secondaryContext.state = secondaryState
///                 context.targetState.valueDelta = secondary.animate(
///                     value: value, time: time - context.targetState.timeDelta,
///                     context: &secondaryContext) ?? value
///             } else {
///                 context.targetState.valueDelta = value
///             }
///             // Reset the target each time a merge occurs.
///             context.targetState.secondaryState = .init()
///             context.targetState.timeDelta = time
///             return base.shouldMerge(
///                 previous: previous.base, value: value, time: time,
///                 context: &context)
///         }
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct AnimationState<Value> where Value : VectorArithmetic {
/// Create an empty state container.
///
/// You don't typically create an instance of ``AnimationState`` directly.
/// Instead, the ``AnimationContext`` provides the animation state to an
/// instance of ``CustomAnimation``.
public init()
/// Accesses the state for a custom key.
///
/// Create a custom animation state value by defining a key that conforms
/// to the ``AnimationStateKey`` protocol and provide the
/// ``AnimationStateKey/defaultValue`` for the key. Also include properties
/// to read and write state values that your ``CustomAnimation`` uses. For
/// example, the following code defines a key named `PausableState` that
/// has two state values, `paused` and `pauseTime`:
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         var paused = false
///         var pauseTime: TimeInterval = 0.0
///
///         static var defaultValue: Self { .init() }
///     }
///
/// Use that key with the subscript operator of the ``AnimationState``
/// structure to get and set a value for the key. For more convenient
/// access to the key value, extend ``AnimationContext`` with a computed
/// property that gets and sets the key's value.
///
///     extension AnimationContext {
///         fileprivate var pausableState: PausableState<Value> {
///             get { state[PausableState<Value>.self] }
///             set { state[PausableState<Value>.self] = newValue }
///         }
///     }
///
/// To access the state values in a ``CustomAnimation``, call the custom
/// computed property, then read and write the state values that the
/// custom ``AnimationStateKey`` provides.
///
///     struct PausableAnimation: CustomAnimation {
///         let base: Animation
///
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let paused = context.environment.animationPaused
///
///             let pausableState = context.pausableState
///             var pauseTime = pausableState.pauseTime
///             if pausableState.paused != paused {
///                 pauseTime = time - pauseTime
///                 context.pausableState = PausableState(paused: paused, pauseTime: pauseTime)
///             }
///
///             let effectiveTime = paused ? pauseTime : time - pauseTime
///             let result = base.animate(value: value, time: effectiveTime, context: &context)
///             return result
///         }
///     }
public subscript<K>(key: K.Type) -> K.Value where K : AnimationStateKey
}
/// A key for accessing animation state values.
///
/// To access animation state from an ``AnimationContext`` in a custom
/// animation, create an `AnimationStateKey`. For example, the following
/// code creates an animation state key named `PausableState` and sets the
/// value for the required ``defaultValue`` property. The code also defines
/// properties for state values that the custom animation needs when
/// calculating animation values. Keeping the state values in the animation
/// state key makes it more convenient to read and write those values in the
/// implementation of a ``CustomAnimation``.
///
///     private struct PausableState<Value: VectorArithmetic>: AnimationStateKey {
///         var paused = false
///         var pauseTime: TimeInterval = 0.0
///
///         static var defaultValue: Self { .init() }
///     }
///
/// To make accessing the value of the animation state key more convenient,
/// define a property for it by extending ``AnimationContext``:
///
///     extension AnimationContext {
///         fileprivate var pausableState: PausableState<Value> {
///             get { state[PausableState<Value>.self] }
///             set { state[PausableState<Value>.self] = newValue }
///         }
///     }
///
/// Then, you can read and write your state in an instance of `CustomAnimation`
/// using the ``AnimationContext``:
///
///     struct PausableAnimation: CustomAnimation {
///         let base: Animation
///
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             let paused = context.environment.animationPaused
///
///             let pausableState = context.pausableState
///             var pauseTime = pausableState.pauseTime
///             if pausableState.paused != paused {
///                 pauseTime = time - pauseTime
///                 context.pausableState = PausableState(paused: paused, pauseTime: pauseTime)
///             }
///
///             let effectiveTime = paused ? pauseTime : time - pauseTime
///             let result = base.animate(value: value, time: effectiveTime, context: &context)
///             return result
///         }
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol AnimationStateKey {
/// The associated type representing the type of the animation state key's
/// value.
associatedtype Value
/// The default value for the animation state key.
static var defaultValue: Self.Value { get }
}
/// A pausable schedule of dates updating at a frequency no more quickly than
/// the provided interval.
///
/// You can also use ``TimelineSchedule/animation(minimumInterval:paused:)`` to
/// construct this schedule.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AnimationTimelineSchedule : TimelineSchedule, Sendable {
/// Create a pausable schedule of dates updating at a frequency no more
/// quickly than the provided interval.
///
/// - Parameters:
///     - minimumInterval: The minimum interval to update the schedule at.
///     Pass nil to let the system pick an appropriate update interval.
///     - paused: If the schedule should stop generating updates.
public init(minimumInterval: Double? = nil, paused: Bool = false)
/// Returns entries at the frequency of the animation schedule.
///
/// When in `.lowFrequency` mode, return no entries, effectively pausing the animation.
public func entries(from start: Date, mode: TimelineScheduleMode) -> AnimationTimelineSchedule.Entries
/// The sequence of dates within a schedule.
///
/// The ``TimelineSchedule/entries(from:mode:)`` method returns a value
/// of this type, which is a
/// <doc://com.apple.documentation/documentation/Swift/Sequence>
/// of dates in ascending order. A ``TimelineView`` that you create with a
/// schedule updates its content at the moments in time corresponding to
/// the dates included in the sequence.
public struct Entries : Sequence, IteratorProtocol, Sendable {
/// Advances to the next element and returns it, or `nil` if no next element
/// exists.
///
/// Repeatedly calling this method returns, in order, all the elements of the
/// underlying sequence. As soon as the sequence has run out of elements, all
/// subsequent calls return `nil`.
///
/// You must not call this method if any other copy of this iterator has been
/// advanced with a call to its `next()` method.
///
/// The following example shows how an iterator can be used explicitly to
/// emulate a `for`-`in` loop. First, retrieve a sequence's iterator, and
/// then call the iterator's `next()` method until it returns `nil`.
///
///     let numbers = [2, 3, 5, 7]
///     var numbersIterator = numbers.makeIterator()
///
///     while let num = numbersIterator.next() {
///         print(num)
///     }
///     // Prints "2"
///     // Prints "3"
///     // Prints "5"
///     // Prints "7"
///
/// - Returns: The next element in the underlying sequence, if a next element
///   exists; otherwise, `nil`.
public mutating func next() -> Date?
/// A type representing the sequence's elements.
public typealias Element = Date
/// A type that provides the sequence's iteration interface and
/// encapsulates its iteration state.
public typealias Iterator = AnimationTimelineSchedule.Entries
}
}
/// A type-erased gesture.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct AnyGesture<Value> : Gesture {
/// Creates an instance from another gesture.
///
/// - Parameter gesture: A gesture that you use to create a new gesture.
public init<T>(_ gesture: T) where Value == T.Value, T : Gesture
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A color gradient.
///
/// When used as a ``ShapeStyle``, this type draws a linear gradient
/// with start-point [0.5, 0] and end-point [0.5, 1].
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct AnyGradient : Hashable, ShapeStyle, Sendable {
/// Creates a new instance from the specified gradient.
public init(_ gradient: Gradient)
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: AnyGradient, rhs: AnyGradient) -> Bool
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension AnyGradient {
/// Returns a version of the gradient that will use a specified
/// color space for interpolating between its colors.
///
///     Rectangle().fill(.linearGradient(
///         colors: [.white, .blue]).colorSpace(.perceptual))
///
/// - Parameters:
///   - space: The color space the new gradient will use to
///     interpolate its constituent colors.
///
/// - Returns: A new gradient that interpolates its colors in the
///   specified color space.
///
public func colorSpace(_ space: Gradient.ColorSpace) -> AnyGradient
}
/// A type-erased instance of the layout protocol.
///
/// Use an `AnyLayout` instance to enable dynamically changing the
/// type of a layout container without destroying the state of the subviews.
/// For example, you can create a layout that changes between horizontal and
/// vertical layouts based on the current Dynamic Type setting:
///
///     struct DynamicLayoutExample: View {
///         @Environment(\.dynamicTypeSize) var dynamicTypeSize
///
///         var body: some View {
///             let layout = dynamicTypeSize <= .medium ?
///                 AnyLayout(HStackLayout()) : AnyLayout(VStackLayout())
///
///             layout {
///                 Text("First label")
///                 Text("Second label")
///             }
///         }
///     }
///
/// The types that you use with `AnyLayout` must conform to the ``Layout``
/// protocol. The above example chooses between the ``HStackLayout`` and
/// ``VStackLayout`` types, which are versions of the built-in ``HStack``
/// and ``VStack`` containers that conform to the protocol. You can also
/// use custom layout types that you define.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct AnyLayout : Layout {
/// Creates a type-erased value that wraps the specified layout.
///
/// You can switch between type-erased layouts without losing the state
/// of the subviews.
public init<L>(_ layout: L) where L : Layout
/// Cached values associated with the layout instance.
///
/// If you create a cache for your custom layout, you can use
/// a type alias to define this type as your data storage type.
/// Alternatively, you can refer to the data storage type directly in all
/// the places where you work with the cache.
///
/// See ``makeCache(subviews:)-23agy`` for more information.
public struct Cache {
}
/// The type defining the data to animate.
public typealias AnimatableData
/// Creates and initializes a cache for a layout instance.
///
/// You can optionally use a cache to preserve calculated values across
/// calls to a layout container's methods. Many layout types don't need
/// a cache, because SwiftUI automatically reuses both the results of
/// calls into the layout and the values that the layout reads from its
/// subviews. Rely on the protocol's default implementation of this method
/// if you don't need a cache.
///
/// However you might find a cache useful when:
///
/// - The layout container repeats complex, intermediate calculations
/// across calls like ``sizeThatFits(proposal:subviews:cache:)``,
/// ``placeSubviews(in:proposal:subviews:cache:)``, and
/// ``explicitAlignment(of:in:proposal:subviews:cache:)-8ofeu``.
/// You might be able to improve performance by calculating values
/// once and storing them in a cache.
/// - The layout container reads many ``LayoutValueKey`` values from
/// subviews. It might be more efficient to do that once and store the
/// results in the cache, rather than rereading the subviews' values before
/// each layout call.
/// - You want to maintain working storage, like temporary Swift arrays,
/// across calls into the layout, to minimize the number of allocation
/// events.
///
/// Only implement a cache if profiling shows that it improves performance.
///
/// ### Initialize a cache
///
/// Implement the `makeCache(subviews:)` method to create a cache.
/// You can add computed values to the cache right away, using information
/// from the `subviews` input parameter, or you can do that later. The
/// methods of the ``Layout`` protocol that can access the cache
/// take the cache as an in-out parameter, which enables you to modify
/// the cache anywhere that you can read it.
///
/// You can use any storage type that makes sense for your layout
/// algorithm, but be sure that you only store data that you derive
/// from the layout and its subviews (lazily, if possible). For this to
/// work correctly, SwiftUI needs to be able to call this method to
/// recreate the cache without changing the layout result.
///
/// When you return a cache from this method, you implicitly define a type
/// for your cache. Be sure to either make the type of the `cache`
/// parameters on your other ``Layout`` protocol methods match, or use
/// a type alias to define the ``Cache`` associated type.
///
/// ### Update the cache
///
/// If the layout container or any of its subviews change, SwiftUI
/// calls the ``updateCache(_:subviews:)-9hkj9`` method so you can
/// modify or invalidate the contents of the
/// cache. The default implementation of that method calls the
/// `makeCache(subviews:)` method to recreate the cache, but you can
/// provide your own implementation of the update method to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
///
/// - Returns: Storage for calculated data that you share among
///   the methods of your custom layout container.
public func makeCache(subviews: AnyLayout.Subviews) -> AnyLayout.Cache
/// Updates the layout's cache when something changes.
///
/// If your custom layout container creates a cache by implementing the
/// ``makeCache(subviews:)-23agy`` method, SwiftUI calls the update method
/// when your layout or its subviews change, giving you an opportunity
/// to modify or invalidate the contents of the cache.
/// The method's default implementation recreates the
/// cache by calling the ``makeCache(subviews:)-23agy`` method,
/// but you can provide your own implementation to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - cache: Storage for calculated data that you share among
///     the methods of your custom layout container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
public func updateCache(_ cache: inout AnyLayout.Cache, subviews: AnyLayout.Subviews)
/// Returns the preferred spacing values of the composite view.
///
/// Implement this method to provide custom spacing preferences
/// for a layout container. The value you return affects
/// the spacing around the container, but it doesn't affect how the
/// container arranges subviews relative to one another inside the
/// container.
///
/// Create a custom ``ViewSpacing`` instance for your container by
/// initializing one with default values, and then merging that with
/// spacing instances of certain subviews. For example, if you define
/// a basic vertical stack that places subviews in a column, you could
/// use the spacing preferences of the subview edges that make
/// contact with the container's edges:
///
///     extension BasicVStack {
///         func spacing(subviews: Subviews, cache: inout ()) -> ViewSpacing {
///             var spacing = ViewSpacing()
///
///             for index in subviews.indices {
///                 var edges: Edge.Set = [.leading, .trailing]
///                 if index == 0 { edges.formUnion(.top) }
///                 if index == subviews.count - 1 { edges.formUnion(.bottom) }
///                 spacing.formUnion(subviews[index].spacing, edges: edges)
///             }
///
///             return spacing
///         }
///     }
///
/// In the above example, the first and last subviews contribute to the
/// spacing above and below the container, respectively, while all subviews
/// affect the spacing on the leading and trailing edges.
///
/// If you don't implement this method, the protocol provides a default
/// implementation, namely ``Layout/spacing(subviews:cache:)-1z0gt``,
/// that merges the spacing preferences across all subviews on all edges.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much spacing the container prefers around it.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A ``ViewSpacing`` instance that describes the preferred
///   spacing around the container view.
public func spacing(subviews: AnyLayout.Subviews, cache: inout AnyLayout.Cache) -> ViewSpacing
/// Returns the size of the composite view, given a proposed size
/// and the view's subviews.
///
/// Implement this method to tell your custom layout container's parent
/// view how much space the container needs for a set of subviews, given
/// a size proposal. The parent might call this method more than once
/// during a layout pass with different proposed sizes to test the
/// flexibility of the container, using proposals like:
///
/// * The ``ProposedViewSize/zero`` proposal; respond with the
///   layout's minimum size.
/// * The ``ProposedViewSize/infinity`` proposal; respond with the
///   layout's maximum size.
/// * The ``ProposedViewSize/unspecified`` proposal; respond with the
///   layout's ideal size.
///
/// The parent might also choose to test flexibility in one dimension at a
/// time. For example, a horizontal stack might propose a fixed height and
/// an infinite width, and then the same height with a zero width.
///
/// The following example calculates the size for a basic vertical stack
/// that places views in a column, with no spacing between the views:
///
///     private struct BasicVStack: Layout {
///         func sizeThatFits(
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGSize {
///             subviews.reduce(CGSize.zero) { result, subview in
///                 let size = subview.sizeThatFits(.unspecified)
///                 return CGSize(
///                     width: max(result.width, size.width),
///                     height: result.height + size.height)
///             }
///         }
///
///         // This layout also needs a placeSubviews() implementation.
///     }
///
/// The implementation asks each subview for its ideal size by calling the
/// ``LayoutSubview/sizeThatFits(_:)`` method with an
/// ``ProposedViewSize/unspecified`` proposed size.
/// It then reduces these values into a single size that represents
/// the maximum subview width and the sum of subview heights.
/// Because this example isn't flexible, it ignores its size proposal
/// input and always returns the same value for a given set of subviews.
///
/// SwiftUI views choose their own size, so the layout engine always
/// uses a value that you return from this method as the actual size of the
/// composite view. That size factors into the construction of the `bounds`
/// input to the ``placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// - Parameters:
///   - proposal: A size proposal for the container. The container's parent
///     view that calls this method might call the method more than once
///     with different proposals to learn more about the container's
///     flexibility before deciding which proposal to use for placement.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much space the container needs to display them.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A size that indicates how much space the container
///   needs to arrange its subviews.
public func sizeThatFits(proposal: ProposedViewSize, subviews: AnyLayout.Subviews, cache: inout AnyLayout.Cache) -> CGSize
/// Assigns positions to each of the layout's subviews.
///
/// SwiftUI calls your implementation of this method to tell your
/// custom layout container to place its subviews. From this method, call
/// the ``LayoutSubview/place(at:anchor:proposal:)`` method on each
/// element in `subviews` to tell the subviews where to appear in the
/// user interface.
///
/// For example, you can create a basic vertical stack that places views
/// in a column, with views horizontally aligned on their leading edge:
///
///     struct BasicVStack: Layout {
///         func placeSubviews(
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) {
///             var point = bounds.origin
///             for subview in subviews {
///                 subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///                 point.y += subview.dimensions(in: .unspecified).height
///             }
///         }
///
///         // This layout also needs a sizeThatFits() implementation.
///     }
///
/// The example creates a placement point that starts at the origin of the
/// specified `bounds` input and uses that to place the first subview. It
/// then moves the point in the y dimension by the subview's height,
/// which it reads using the ``LayoutSubview/dimensions(in:)`` method.
/// This prepares the point for the next iteration of the loop. All
/// subview operations use an ``ProposedViewSize/unspecified`` size
/// proposal to indicate that subviews should use and report their ideal
/// size.
///
/// A more complex layout container might add space between subviews
/// according to their ``LayoutSubview/spacing`` preferences, or a
/// fixed space based on input configuration. For example, you can extend
/// the basic vertical stack's placement method to calculate the
/// preferred distances between adjacent subviews and store the results in
/// an array:
///
///     let spacing: [CGFloat] = subviews.indices.dropLast().map { index in
///         subviews[index].spacing.distance(
///             to: subviews[index + 1].spacing,
///             along: .vertical)
///     }
///
/// The spacing's ``ViewSpacing/distance(to:along:)`` method considers the
/// preferences of adjacent views on the edge where they meet. It returns
/// the smallest distance that satisfies both views' preferences for the
/// given edge. For example, if one view prefers at least `2` points on its
/// bottom edge, and the next view prefers at least `8` points on its top
/// edge, the distance method returns `8`, because that's the smallest
/// value that satisfies both preferences.
///
/// Update the placement calculations to use the spacing values:
///
///     var point = bounds.origin
///     for (index, subview) in subviews.enumerated() {
///         if index > 0 { point.y += spacing[index - 1] } // Add spacing.
///         subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///         point.y += subview.dimensions(in: .unspecified).height
///     }
///
/// Be sure that you use computations during placement that are consistent
/// with those in your implementation of other protocol methods for a given
/// set of inputs. For example, if you add spacing during placement,
/// make sure your implementation of
/// ``sizeThatFits(proposal:subviews:cache:)`` accounts for the extra space.
/// Similarly, if the sizing method returns different values for different
/// size proposals, make sure the placement method responds to its
/// `proposal` input in the same way.
///
/// - Parameters:
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///     Place all the container's subviews within the region.
///     The size of this region matches a size that your container
///     previously returned from a call to the
///     ``sizeThatFits(proposal:subviews:cache:)`` method.
///   - proposal: The size proposal from which the container generated the
///     size that the parent used to create the `bounds` parameter.
///     The parent might propose more than one size before calling the
///     placement method, but it always uses one of the proposals and the
///     corresponding returned size when placing the container.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. Use the proxies in the collection
///     to get information about the subviews and to tell the subviews
///     where to appear.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
public func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: AnyLayout.Subviews, cache: inout AnyLayout.Cache)
/// Returns the position of the specified horizontal alignment guide along
/// the x axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can indent the container's leading edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: HorizontalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .leading {
///                 return bounds.minX + 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``HorizontalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
public func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: AnyLayout.Subviews, cache: inout AnyLayout.Cache) -> CGFloat?
/// Returns the position of the specified vertical alignment guide along
/// the y axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can raise the container's bottom edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: VerticalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .bottom {
///                 return bounds.minY - 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``VerticalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
public func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: AnyLayout.Subviews, cache: inout AnyLayout.Cache) -> CGFloat?
/// The data to animate.
public var animatableData: AnyLayout.AnimatableData
}
/// A type-erased shape value.
///
/// You can use this type to dynamically switch between shape types:
///
///     struct MyClippedView: View {
///         var isCircular: Bool
///
///         var body: some View {
///             OtherView().clipShape(isCircular ?
///                 AnyShape(Circle()) : AnyShape(Capsule()))
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct AnyShape : Shape, @unchecked Sendable {
/// Create an any shape instance from a shape.
public init<S>(_ shape: S) where S : Shape
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// Returns the size of the view that will render the shape, given
/// a proposed size.
///
/// Implement this method to tell the container of the shape how
/// much space the shape needs to render itself, given a size
/// proposal.
///
/// See ``Layout/sizeThatFits(proposal:subviews:cache:)``
/// for more details about how the layout system chooses the size of
/// views.
///
/// - Parameters:
///   - proposal: A size proposal for the container.
///
/// - Returns: A size that indicates how much space the shape needs.
public func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
/// The type defining the data to animate.
public typealias AnimatableData
/// The data to animate.
public var animatableData: AnyShape.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
/// A type-erased ShapeStyle value.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public struct AnyShapeStyle : ShapeStyle {
/// Create an instance from `style`.
public init<S>(_ style: S) where S : ShapeStyle
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AnyShapeStyle.Storage : @unchecked Sendable {
}
/// A type-erased transition.
///
/// - See Also: `Transition`
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct AnyTransition {
/// Create an instance that type-erases `transition`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init<T>(_ transition: T) where T : Transition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// A transition that inserts by moving in from the leading edge, and
/// removes by moving out towards the trailing edge.
///
/// - SeeAlso: `AnyTransition.move(edge:)`
public static var slide: AnyTransition { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension AnyTransition {
/// Creates a transition that when added to a view will animate the
/// view's insertion by moving it in from the specified edge while
/// fading it in, and animate its removal by moving it out towards
/// the opposite edge and fading it out.
///
/// - Parameters:
///   - edge: the edge from which the view will be animated in.
///
/// - Returns: A transition that animates a view by moving and
///   fading it.
public static func push(from edge: Edge) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
public static func offset(_ offset: CGSize) -> AnyTransition
public static func offset(x: CGFloat = 0, y: CGFloat = 0) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Returns a transition that scales the view.
public static var scale: AnyTransition { get }
/// Returns a transition that scales the view by the specified amount.
public static func scale(scale: CGFloat, anchor: UnitPoint = .center) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// A transition from transparent to opaque on insertion, and from opaque to
/// transparent on removal.
public static let opacity: AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Combines this transition with another, returning a new transition that
/// is the result of both transitions being applied.
public func combined(with other: AnyTransition) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Returns a transition defined between an active modifier and an identity
/// modifier.
public static func modifier<E>(active: E, identity: E) -> AnyTransition where E : ViewModifier
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// A transition that returns the input view, unmodified, as the output
/// view.
public static let identity: AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Returns a transition that moves the view away, towards the specified
/// edge of the view.
public static func move(edge: Edge) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Provides a composite transition that uses a different transition for
/// insertion versus removal.
public static func asymmetric(insertion: AnyTransition, removal: AnyTransition) -> AnyTransition
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyTransition {
/// Attaches an animation to this transition.
public func animation(_ animation: Animation?) -> AnyTransition
}
/// A type-erased view.
///
/// An `AnyView` allows changing the type of view used in a given view
/// hierarchy. Whenever the type of view used with an `AnyView` changes, the old
/// hierarchy is destroyed and a new hierarchy is created for the new type.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct AnyView : View {
/// Create an instance that type-erases `view`.
public init<V>(_ view: V) where V : View
public init<V>(erasing view: V) where V : View
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type that represents the structure and behavior of an app.
///
/// Create an app by declaring a structure that conforms to the `App` protocol.
/// Implement the required ``SwiftUI/App/body-swift.property`` computed property
/// to define the app's content:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 Text("Hello, world!")
///             }
///         }
///     }
///
/// Precede the structure's declaration with the
/// [@main](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID626)
/// attribute to indicate that your custom `App` protocol conformer provides the
/// entry point into your app. The protocol provides a default implementation of
/// the ``SwiftUI/App/main()`` method that the system calls to launch your app.
/// You can have exactly one entry point among all of your app's files.
///
/// Compose the app's body from instances that conform to the ``SwiftUI/Scene``
/// protocol. Each scene contains the root view of a view hierarchy and has a
/// life cycle managed by the system. SwiftUI provides some concrete scene types
/// to handle common scenarios, like for displaying documents or settings. You
/// can also create custom scenes.
///
///     @main
///     struct Mail: App {
///         var body: some Scene {
///             WindowGroup {
///                 MailViewer()
///             }
///             Settings {
///                 SettingsView()
///             }
///         }
///     }
///
/// You can declare state in your app to share across all of its scenes. For
/// example, you can use the ``SwiftUI/StateObject`` attribute to initialize a
/// data model, and then provide that model on a view input as an
/// ``SwiftUI/ObservedObject`` or through the environment as an
/// ``SwiftUI/EnvironmentObject`` to scenes in the app:
///
///     @main
///     struct Mail: App {
///         @StateObject private var model = MailModel()
///
///         var body: some Scene {
///             WindowGroup {
///                 MailViewer()
///                     .environmentObject(model) // Passed through the environment.
///             }
///             Settings {
///                 SettingsView(model: model) // Passed as an observed object.
///             }
///         }
///     }
///
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol App {
/// The type of scene representing the content of the app.
///
/// When you create a custom app, Swift infers this type from your
/// implementation of the required ``SwiftUI/App/body-swift.property``
/// property.
associatedtype Body : Scene
/// The content and behavior of the app.
///
/// For any app that you create, provide a computed `body` property that
/// defines your app's scenes, which are instances that conform to the
/// ``SwiftUI/Scene`` protocol. For example, you can create a simple app
/// with a single scene containing a single view:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 Text("Hello, world!")
///             }
///         }
///     }
///
/// Swift infers the app's ``SwiftUI/App/Body-swift.associatedtype``
/// associated type based on the scene provided by the `body` property.
@SceneBuilder @MainActor var body: Self.Body { get }
/// Creates an instance of the app using the body that you define for its
/// content.
///
/// Swift synthesizes a default initializer for structures that don't
/// provide one. You typically rely on the default initializer for
/// your app.
@MainActor init()
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension App {
/// Initializes and runs the app.
///
/// If you precede your ``SwiftUI/App`` conformer's declaration with the
/// [@main](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID626)
/// attribute, the system calls the conformer's `main()` method to launch
/// the app. SwiftUI provides a
/// default implementation of the method that manages the launch process in
/// a platform-appropriate way.
@MainActor public static func main()
}
/// A property wrapper type that reflects a value from `UserDefaults` and
/// invalidates a view on a change in value in that user default.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen @propertyWrapper public struct AppStorage<Value> : DynamicProperty {
public var wrappedValue: Value { get nonmutating set }
public var projectedValue: Binding<Value> { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension AppStorage {
/// Creates a property that can save and restore table column state.
///
/// Table column state is typically not bound from a table directly to
/// `AppStorage`, but instead indirecting through `State` or `SceneStorage`,
/// and using the app storage value as its initial value kept up to date
/// on changes to the direct backing.
///
/// - Parameters:
///   - wrappedValue: The default value if table column state is not
///   available for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init<RowValue>(wrappedValue: Value = TableColumnCustomization<RowValue>(), _ key: String, store: UserDefaults? = nil) where Value == TableColumnCustomization<RowValue>, RowValue : Identifiable
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AppStorage {
/// Creates a property that can read and write to a boolean user default.
///
/// - Parameters:
///   - wrappedValue: The default value if a boolean value is not specified
///     for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == Bool
/// Creates a property that can read and write to an integer user default.
///
/// - Parameters:
///   - wrappedValue: The default value if an integer value is not specified
///     for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == Int
/// Creates a property that can read and write to a double user default.
///
/// - Parameters:
///   - wrappedValue: The default value if a double value is not specified
///     for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == Double
/// Creates a property that can read and write to a string user default.
///
/// - Parameters:
///   - wrappedValue: The default value if a string value is not specified
///     for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == String
/// Creates a property that can read and write to a url user default.
///
/// - Parameters:
///   - wrappedValue: The default value if a url value is not specified for
///     the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == URL
/// Creates a property that can read and write to a user default as data.
///
/// Avoid storing large data blobs in user defaults, such as image data,
/// as it can negatively affect performance of your app. On tvOS, a
/// `NSUserDefaultsSizeLimitExceededNotification` notification is posted
/// if the total user default size reaches 512kB.
///
/// - Parameters:
///   - wrappedValue: The default value if a data value is not specified for
///    the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value == Data
/// Creates a property that can read and write to an integer user default,
/// transforming that to `RawRepresentable` data type.
///
/// A common usage is with enumerations:
///
///    enum MyEnum: Int {
///        case a
///        case b
///        case c
///    }
///    struct MyView: View {
///        @AppStorage("MyEnumValue") private var value = MyEnum.a
///        var body: some View { ... }
///    }
///
/// - Parameters:
///   - wrappedValue: The default value if an integer value
///     is not specified for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value : RawRepresentable, Value.RawValue == Int
/// Creates a property that can read and write to a string user default,
/// transforming that to `RawRepresentable` data type.
///
/// A common usage is with enumerations:
///
///    enum MyEnum: String {
///        case a
///        case b
///        case c
///    }
///    struct MyView: View {
///        @AppStorage("MyEnumValue") private var value = MyEnum.a
///        var body: some View { ... }
///    }
///
/// - Parameters:
///   - wrappedValue: The default value if a string value
///     is not specified for the given key.
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value : RawRepresentable, Value.RawValue == String
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AppStorage where Value : ExpressibleByNilLiteral {
/// Creates a property that can read and write an Optional boolean user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == Bool?
/// Creates a property that can read and write an Optional integer user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == Int?
/// Creates a property that can read and write an Optional double user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == Double?
/// Creates a property that can read and write an Optional string user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == String?
/// Creates a property that can read and write an Optional URL user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == URL?
/// Creates a property that can read and write an Optional data user
/// default.
///
/// Defaults to nil if there is no restored value.
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init(_ key: String, store: UserDefaults? = nil) where Value == Data?
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension AppStorage {
/// Creates a property that can save and restore an Optional string,
/// transforming it to an Optional `RawRepresentable` data type.
///
/// Defaults to nil if there is no restored value
///
/// A common usage is with enumerations:
///
///     enum MyEnum: String {
///         case a
///         case b
///         case c
///     }
///     struct MyView: View {
///         @AppStorage("MyEnumValue") private var value: MyEnum?
///         var body: some View { ... }
///     }
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init<R>(_ key: String, store: UserDefaults? = nil) where Value == R?, R : RawRepresentable, R.RawValue == String
/// Creates a property that can save and restore an Optional integer,
/// transforming it to an Optional `RawRepresentable` data type.
///
/// Defaults to nil if there is no restored value
///
/// A common usage is with enumerations:
///
///     enum MyEnum: Int {
///         case a
///         case b
///         case c
///     }
///     struct MyView: View {
///         @AppStorage("MyEnumValue") private var value: MyEnum?
///         var body: some View { ... }
///     }
///
/// - Parameters:
///   - key: The key to read and write the value to in the user defaults
///     store.
///   - store: The user defaults store to read and write to. A value
///     of `nil` will use the user default store from the environment.
public init<R>(_ key: String, store: UserDefaults? = nil) where Value == R?, R : RawRepresentable, R.RawValue == Int
}
/// A composite `Transition` that uses a different transition for
/// insertion versus removal.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct AsymmetricTransition<Insertion, Removal> : Transition where Insertion : Transition, Removal : Transition {
/// The `Transition` defining the insertion phase of `self`.
public var insertion: Insertion
/// The `Transition` defining the removal phase of `self`.
public var removal: Removal
/// Creates a composite `Transition` that uses a different transition for
/// insertion versus removal.
public init(insertion: Insertion, removal: Removal)
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: AsymmetricTransition<Insertion, Removal>.Content, phase: TransitionPhase) -> some View
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
public static var properties: TransitionProperties { get }
/// The type of view representing the body.
public typealias Body = some View
}
/// A view that asynchronously loads and displays an image.
///
/// This view uses the shared
/// <doc://com.apple.documentation/documentation/Foundation/URLSession>
/// instance to load an image from the specified URL, and then display it.
/// For example, you can display an icon that's stored on a server:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png"))
///         .frame(width: 200, height: 200)
///
/// Until the image loads, the view displays a standard placeholder that
/// fills the available space. After the load completes successfully, the view
/// updates to display the image. In the example above, the icon is smaller
/// than the frame, and so appears smaller than the placeholder.
///
/// ![A diagram that shows a grey box on the left, the SwiftUI icon on the
/// right, and an arrow pointing from the first to the second. The icon
/// is about half the size of the grey box.](AsyncImage-1)
///
/// You can specify a custom placeholder using
/// ``init(url:scale:content:placeholder:)``. With this initializer, you can
/// also use the `content` parameter to manipulate the loaded image.
/// For example, you can add a modifier to make the loaded image resizable:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png")) { image in
///         image.resizable()
///     } placeholder: {
///         ProgressView()
///     }
///     .frame(width: 50, height: 50)
///
/// For this example, SwiftUI shows a ``ProgressView`` first, and then the
/// image scaled to fit in the specified frame:
///
/// ![A diagram that shows a progress view on the left, the SwiftUI icon on the
/// right, and an arrow pointing from the first to the second.](AsyncImage-2)
///
/// > Important: You can't apply image-specific modifiers, like
/// ``Image/resizable(capInsets:resizingMode:)``, directly to an `AsyncImage`.
/// Instead, apply them to the ``Image`` instance that your `content`
/// closure gets when defining the view's appearance.
///
/// To gain more control over the loading process, use the
/// ``init(url:scale:transaction:content:)`` initializer, which takes a
/// `content` closure that receives an ``AsyncImagePhase`` to indicate
/// the state of the loading operation. Return a view that's appropriate
/// for the current phase:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png")) { phase in
///         if let image = phase.image {
///             image // Displays the loaded image.
///         } else if phase.error != nil {
///             Color.red // Indicates an error.
///         } else {
///             Color.blue // Acts as a placeholder.
///         }
///     }
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct AsyncImage<Content> : View where Content : View {
/// Loads and displays an image from the specified URL.
///
/// Until the image loads, SwiftUI displays a default placeholder. When
/// the load operation completes successfully, SwiftUI updates the
/// view to show the loaded image. If the operation fails, SwiftUI
/// continues to display the placeholder. The following example loads
/// and displays an icon from an example server:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png"))
///
/// If you want to customize the placeholder or apply image-specific
/// modifiers --- like ``Image/resizable(capInsets:resizingMode:)`` ---
/// to the loaded image, use the ``init(url:scale:content:placeholder:)``
/// initializer instead.
///
/// - Parameters:
///   - url: The URL of the image to display.
///   - scale: The scale to use for the image. The default is `1`. Set a
///     different value when loading images designed for higher resolution
///     displays. For example, set a value of `2` for an image that you
///     would name with the `@2x` suffix if stored in a file on disk.
public init(url: URL?, scale: CGFloat = 1) where Content == Image
/// Loads and displays a modifiable image from the specified URL using
/// a custom placeholder until the image loads.
///
/// Until the image loads, SwiftUI displays the placeholder view that
/// you specify. When the load operation completes successfully, SwiftUI
/// updates the view to show content that you specify, which you
/// create using the loaded image. For example, you can show a green
/// placeholder, followed by a tiled version of the loaded image:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png")) { image in
///         image.resizable(resizingMode: .tile)
///     } placeholder: {
///         Color.green
///     }
///
/// If the load operation fails, SwiftUI continues to display the
/// placeholder. To be able to display a different view on a load error,
/// use the ``init(url:scale:transaction:content:)`` initializer instead.
///
/// - Parameters:
///   - url: The URL of the image to display.
///   - scale: The scale to use for the image. The default is `1`. Set a
///     different value when loading images designed for higher resolution
///     displays. For example, set a value of `2` for an image that you
///     would name with the `@2x` suffix if stored in a file on disk.
///   - content: A closure that takes the loaded image as an input, and
///     returns the view to show. You can return the image directly, or
///     modify it as needed before returning it.
///   - placeholder: A closure that returns the view to show until the
///     load operation completes successfully.
public init<I, P>(url: URL?, scale: CGFloat = 1, @ViewBuilder content: @escaping (Image) -> I, @ViewBuilder placeholder: @escaping () -> P) where Content == _ConditionalContent<I, P>, I : View, P : View
/// Loads and displays a modifiable image from the specified URL in phases.
///
/// If you set the asynchronous image's URL to `nil`, or after you set the
/// URL to a value but before the load operation completes, the phase is
/// ``AsyncImagePhase/empty``. After the operation completes, the phase
/// becomes either ``AsyncImagePhase/failure(_:)`` or
/// ``AsyncImagePhase/success(_:)``. In the first case, the phase's
/// ``AsyncImagePhase/error`` value indicates the reason for failure.
/// In the second case, the phase's ``AsyncImagePhase/image`` property
/// contains the loaded image. Use the phase to drive the output of the
/// `content` closure, which defines the view's appearance:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png")) { phase in
///         if let image = phase.image {
///             image // Displays the loaded image.
///         } else if phase.error != nil {
///             Color.red // Indicates an error.
///         } else {
///             Color.blue // Acts as a placeholder.
///         }
///     }
///
/// To add transitions when you change the URL, apply an identifier to the
/// ``AsyncImage``.
///
/// - Parameters:
///   - url: The URL of the image to display.
///   - scale: The scale to use for the image. The default is `1`. Set a
///     different value when loading images designed for higher resolution
///     displays. For example, set a value of `2` for an image that you
///     would name with the `@2x` suffix if stored in a file on disk.
///   - transaction: The transaction to use when the phase changes.
///   - content: A closure that takes the load phase as an input, and
///     returns the view to display for the specified phase.
public init(url: URL?, scale: CGFloat = 1, transaction: Transaction = Transaction(), @ViewBuilder content: @escaping (AsyncImagePhase) -> Content)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// The current phase of the asynchronous image loading operation.
///
/// When you create an ``AsyncImage`` instance with the
/// ``AsyncImage/init(url:scale:transaction:content:)`` initializer, you define
/// the appearance of the view using a `content` closure. SwiftUI calls the
/// closure with a phase value at different points during the load operation
/// to indicate the current state. Use the phase to decide what to draw.
/// For example, you can draw the loaded image if it exists, a view that
/// indicates an error, or a placeholder:
///
///     AsyncImage(url: URL(string: "https://example.com/icon.png")) { phase in
///         if let image = phase.image {
///             image // Displays the loaded image.
///         } else if phase.error != nil {
///             Color.red // Indicates an error.
///         } else {
///             Color.blue // Acts as a placeholder.
///         }
///     }
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public enum AsyncImagePhase : Sendable {
/// No image is loaded.
case empty
/// An image succesfully loaded.
case success(Image)
/// An image failed to load with an error.
case failure(Error)
/// The loaded image, if any.
///
/// If this value isn't `nil`, the image load operation has finished,
/// and you can use the image to update the view. You can use the image
/// directly, or you can modify it in some way. For example, you can add
/// a ``Image/resizable(capInsets:resizingMode:)`` modifier to make the
/// image resizable.
public var image: Image? { get }
/// The error that occurred when attempting to load an image, if any.
public var error: (Error)? { get }
}
/// The default control group style.
///
/// You can also use ``ControlGroupStyle/automatic`` to construct this style.
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct AutomaticControlGroupStyle : ControlGroupStyle {
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@MainActor public func makeBody(configuration: AutomaticControlGroupStyle.Configuration) -> some View
/// A view representing the body of a control group.
public typealias Body = some View
}
/// A disclosure group style that resolves its appearance automatically
/// based on the current context.
///
/// Use ``DisclosureGroupStyle/automatic`` to construct this style.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct AutomaticDisclosureGroupStyle : DisclosureGroupStyle {
/// Creates an automatic disclosure group style.
public init()
/// Creates a view that represents the body of a disclosure group.
///
/// SwiftUI calls this method for each instance of ``DisclosureGroup``
/// that you create within a view hierarchy where this style is the current
/// ``DisclosureGroupStyle``.
///
/// - Parameter configuration: The properties of the instance being created.
public func makeBody(configuration: AutomaticDisclosureGroupStyle.Configuration) -> some View
/// A view that represents the body of a disclosure group.
public typealias Body = some View
}
/// The default form style.
///
/// Use the ``FormStyle/automatic`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.automatic)
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct AutomaticFormStyle : FormStyle {
/// Creates a default form style.
///
/// Don't call this initializer directly. Instead, use the
/// ``FormStyle/automatic`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.automatic)
///
public init()
/// Creates a view that represents the body of a form.
///
/// - Parameter configuration: The properties of the form.
/// - Returns: A view that has behavior and appearance that enables it
///   to function as a ``Form``.
public func makeBody(configuration: AutomaticFormStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a form.
public typealias Body = some View
}
/// The default labeled content style.
///
/// Use ``LabeledContentStyle/automatic`` to construct this style.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct AutomaticLabeledContentStyle : LabeledContentStyle {
/// Creates an automatic labeled content style.
public init()
/// Creates a view that represents the body of labeled content.
public func makeBody(configuration: AutomaticLabeledContentStyle.Configuration) -> some View
/// A view that represents the appearance and behavior of labeled content.
public typealias Body = some View
}
/// A navigation split style that resolves its appearance automatically
/// based on the current context.
///
/// Use ``NavigationSplitViewStyle/automatic`` to construct this style.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct AutomaticNavigationSplitViewStyle : NavigationSplitViewStyle {
/// Creates an instance of the automatic navigation split view style.
///
/// Use ``NavigationSplitViewStyle/automatic`` to construct this style.
public init()
/// Creates a view that represents the body of a navigation split view.
///
/// SwiftUI calls this method for each instance of ``NavigationSplitView``,
/// where this style is the current ``NavigationSplitViewStyle``.
///
/// - Parameter configuration: The properties of the instance to create.
public func makeBody(configuration: AutomaticNavigationSplitViewStyle.Configuration) -> some View
/// A view that represents the body of a navigation split view.
public typealias Body = some View
}
/// The default table style in the current context.
///
/// You can also use ``TableStyle/automatic`` to construct this style.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct AutomaticTableStyle : TableStyle {
/// Creates a view that represents the body of a table.
///
/// The system calls this method for each ``Table`` instance in a view
/// hierarchy where this style is the current table style.
///
/// - Parameter configuration: The properties of the table.
public func makeBody(configuration: AutomaticTableStyle.Configuration) -> some View
/// A view that represents the body of a table.
public typealias Body = some View
}
/// The default text editor style, based on the text editor's context.
///
/// You can also use ``TextEditorStyle/automatic`` to construct this style.
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct AutomaticTextEditorStyle : TextEditorStyle {
/// Creates a view that represents the body of a text editor.
///
/// The system calls this method for each ``TextEditor`` instance in a view
/// hierarchy where this style is the current text editor style.
///
/// - Parameter configuration: The properties of the text editor.
public func makeBody(configuration: AutomaticTextEditorStyle.Configuration) -> AutomaticTextEditorStyle.Body
public init()
/// A view that represents the body of a text editor.
public struct Body : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
}
/// The horizontal or vertical dimension in a 2D coordinate system.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public enum Axis : Int8, CaseIterable {
/// The horizontal dimension.
case horizontal
/// The vertical dimension.
case vertical
/// An efficient set of axes.
@frozen public struct Set : OptionSet {
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = Axis.Set
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int8
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int8)
public static let horizontal: Axis.Set
public static let vertical: Axis.Set
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = Axis.Set.Element
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
}
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: Int8)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [Axis]
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
/// A collection of all values of this type.
public static var allCases: [Axis] { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int8 { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis : CustomStringConvertible {
/// A textual representation of this instance.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(describing:)`
/// initializer. This initializer works with any type, and uses the custom
/// `description` property for types that conform to
/// `CustomStringConvertible`:
///
///     struct Point: CustomStringConvertible {
///         let x: Int, y: Int
///
///         var description: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(describing: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `description` property.
public var description: String { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis : Hashable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis : RawRepresentable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Axis.Set : Sendable {
}
/// The prominence of backgrounds underneath other views.
///
/// Background prominence should influence foreground styling to maintain
/// sufficient contrast against the background. For example, selected rows in
/// a `List` and `Table` can have increased prominence backgrounds with
/// accent color fills when focused; the foreground content above the background
/// should be adjusted to reflect that level of prominence.
///
/// This can be read and written for views with the
/// `EnvironmentValues.backgroundProminence` property.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct BackgroundProminence : Hashable, Sendable {
/// The standard prominence of a background
///
/// This is the default level of prominence and doesn't require any
/// adjustment to achieve satisfactory contrast with the background.
public static let standard: BackgroundProminence
/// A more prominent background that likely requires some changes to the
/// views above it.
///
/// This is the level of prominence for more highly saturated and full
/// color backgrounds, such as focused/emphasized selected list rows.
/// Typically foreground content should take on monochrome styling to
/// have greater contrast against the background.
public static let increased: BackgroundProminence
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: BackgroundProminence, b: BackgroundProminence) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// The background style in the current context.
///
/// You can also use ``ShapeStyle/background`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public struct BackgroundStyle : ShapeStyle {
/// Creates a background style instance.
@inlinable public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// The kinds of background tasks that your app or extension can handle.
///
/// Use a value of this type with the ``Scene/backgroundTask(_:action:)`` scene
/// modifier to create a handler for background tasks that the system sends
/// to your app or extension. For example, you can use ``urlSession`` to define
/// an asynchronous closure that the system calls when it launches your app or
/// extension to handle a response from a background
/// <doc://com.apple.documentation/documentation/Foundation/URLSession>.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct BackgroundTask<Request, Response> : Sendable {
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension BackgroundTask {
/// A task that responds to background URL sessions.
public static var urlSession: BackgroundTask<String, Void> { get }
/// A task that responds to background URL sessions matching the given
/// identifier.
///
/// - Parameter identifier: The identifier to match.
///
/// - Returns: A background task that you can handle with your app or
///   extension.
public static func urlSession(_ identifier: String) -> BackgroundTask<Void, Void>
/// A task that responds to background URL sessions matching the given
/// predicate.
///
/// - Parameter matching: The predicate to match.
///
/// - Returns: A background task that you can handle with your app or
///   extension.
public static func urlSession(matching: @escaping @Sendable (String) -> Bool) -> BackgroundTask<String, Void>
/// A task that updates your app’s state in the background for a
/// matching identifier.
///
/// - Parameter matching: The identifier to match.
///
/// - Returns: A background task that you can handle with your app or
///   extension.
@available(macOS, unavailable)
public static func appRefresh(_ identifier: String) -> BackgroundTask<Void, Void>
}
/// The visual prominence of a badge.
///
/// Badges can be used for different kinds of information, from the
/// passive number of items in a container to the number of required
/// actions. The prominence of badges in Lists can be adjusted to reflect
/// this and be made to draw more or less attention to themselves.
///
/// Badges will default to `standard` prominence unless specified.
///
/// The following example shows a ``List`` displaying a list of folders
/// with an informational badge with lower prominence, showing the number
/// of items in the folder.
///
///     List(folders) { folder in
///         Text(folder.name)
///             .badge(folder.numberOfItems)
///     }
///     .badgeProminence(.decreased)
///
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct BadgeProminence : Hashable, Sendable {
/// The lowest level of prominence for a badge.
///
/// This level or prominence should be used for badges that display a value
/// of passive information that requires no user action, such as total
/// number of messages or content.
///
/// In lists on iOS and macOS, this results in badge labels being
/// displayed without any extra decoration. On iOS, this looks the same as
/// `.standard`.
///
///     List(folders) { folder in
///         Text(folder.name)
///             .badge(folder.numberOfItems)
///     }
///     .badgeProminence(.decreased)
///
public static let decreased: BadgeProminence
/// The standard level of prominence for a badge.
///
/// This level of prominence should be used for badges that display a value
/// that suggests user action, such as a count of unread messages or new
/// invitations.
///
/// In lists on macOS, this results in a badge label on a grayscale platter;
/// and in lists on iOS, this prominence of badge has no platter.
///
///     List(mailboxes) { mailbox in
///         Text(mailbox.name)
///             .badge(mailbox.numberOfUnreadMessages)
///     }
///     .badgeProminence(.standard)
///
public static let standard: BadgeProminence
/// The highest level of prominence for a badge.
///
/// This level of prominence should be used for badges that display a value
/// that requires user action, such as number of updates or account errors.
///
/// In lists on iOS and macOS, this results in badge labels being displayed
/// on a red platter.
///
///     ForEach(accounts) { account in
///         Text(account.userName)
///             .badge(account.setupErrors)
///             .badgeProminence(.increased)
///     }
///
public static let increased: BadgeProminence
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: BadgeProminence, b: BadgeProminence) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A navigation split style that reduces the size of the detail content
/// to make room when showing the leading column or columns.
///
/// Use ``NavigationSplitViewStyle/balanced`` to construct this style.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct BalancedNavigationSplitViewStyle : NavigationSplitViewStyle {
/// Creates an instance of ``BalancedNavigationSplitViewStyle``.
///
/// You can also use ``NavigationSplitViewStyle/balanced`` to construct this
/// style.
public init()
/// Creates a view that represents the body of a navigation split view.
///
/// SwiftUI calls this method for each instance of ``NavigationSplitView``,
/// where this style is the current ``NavigationSplitViewStyle``.
///
/// - Parameter configuration: The properties of the instance to create.
public func makeBody(configuration: BalancedNavigationSplitViewStyle.Configuration) -> some View
/// A view that represents the body of a navigation split view.
public typealias Body = some View
}
/// A property wrapper type that supports creating bindings to the mutable
/// properties of observable objects.
///
/// Use this property wrapper to create bindings to mutable properties of a
/// data model object that conforms to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol. For example, the following code wraps the `book` input with
/// `@Bindable`. Then it uses a ``TextField`` to change the `title` property of
/// a book, and a ``Toggle`` to change the `isAvailable` property, using the
/// `$` syntax to pass a binding for each property to those controls.
///
///     @Observable
///     class Book: Identifiable {
///         var title = "Sample Book Title"
///         var isAvailable = true
///     }
///
///     struct BookEditView: View {
///         @Bindable var book: Book
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Form {
///                 TextField("Title", text: $book.title)
///
///                 Toggle("Book is available", isOn: $book.isAvailable)
///
///                 Button("Close") {
///                     dismiss()
///                 }
///             }
///         }
///     }
///
/// You can use the `Bindable` property wrapper on properties and variables to
/// an <doc://com.apple.documentation/documentation/Observation/Observable>
/// object. This includes global variables, properties that exists outside of
/// SwiftUI types, or even local variables. For example, you can create a
/// `@Bindable` variable within a view's ``View/body-swift.property``:
///
///     struct LibraryView: View {
///         @State private var books = [Book(), Book(), Book()]
///
///         var body: some View {
///             List(books) { book in
///                 @Bindable var book = book
///                 TextField("Title", text: $book.title)
///             }
///         }
///     }
///
/// The `@Bindable` variable `book` provides a binding that connects
/// ``TextField`` to the `title` property of a book so that a person can make
/// changes directly to the model data.
///
/// Use this same approach when you need a binding to a property of an
/// observable object stored in a view's environment. For example, the
/// following code uses the ``Environment`` property wrapper to retrieve an
/// instance of the observable type `Book`. Then the code creates a `@Bindable`
/// variable `book` and passes a binding for the `title` property to a
/// ``TextField`` using the `$` syntax.
///
///     struct TitleEditView: View {
///         @Environment(Book.self) private var book
///
///         var body: some View {
///             @Bindable var book = book
///             TextField("Title", text: $book.title)
///         }
///     }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@dynamicMemberLookup @propertyWrapper public struct Bindable<Value> {
/// The wrapped object.
public var wrappedValue: Value
/// The bindable wrapper for the object that creates bindings to its
/// properties using dynamic member lookup.
public var projectedValue: Bindable<Value> { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Bindable where Value : AnyObject {
/// Returns a binding to the value of a given key path.
public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<Value, Subject>) -> Binding<Subject> { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Bindable where Value : AnyObject, Value : Observable {
/// Creates a bindable object from an observable object.
///
/// You should not call this initializer directly. Instead, declare a
/// property with the `@Bindable` attribute, and provide an initial value.
public init(wrappedValue: Value)
/// Creates a bindable object from an observable object.
///
/// This initializer is equivalent to ``init(wrappedValue:)``, but is more
/// succinct when when creating bindable objects nested within other
/// expressions. For example, you can use the initializer to create a
/// bindable object inline with code that declares a view that takes a
/// binding as a parameter:
///
///     struct TitleEditView: View {
///         @Environment(Book.self) private var book
///
///         var body: some View {
///             TextField("Title", text: Bindable(book).title)
///         }
///     }
///
public init(_ wrappedValue: Value)
/// Creates a bindable from the value of another bindable.
public init(projectedValue: Bindable<Value>)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Bindable : Identifiable where Value : Identifiable {
/// The stable identity of the entity associated with this instance.
public var id: Value.ID { get }
/// A type representing the stable identity of the entity associated with
/// an instance.
public typealias ID = Value.ID
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Bindable : Sendable where Value : Sendable {
}
/// A property wrapper type that can read and write a value owned by a source of
/// truth.
///
/// Use a binding to create a two-way connection between a property that stores
/// data, and a view that displays and changes the data. A binding connects a
/// property to a source of truth stored elsewhere, instead of storing data
/// directly. For example, a button that toggles between play and pause can
/// create a binding to a property of its parent view using the `Binding`
/// property wrapper.
///
///     struct PlayButton: View {
///         @Binding var isPlaying: Bool
///
///         var body: some View {
///             Button(isPlaying ? "Pause" : "Play") {
///                 isPlaying.toggle()
///             }
///         }
///     }
///
/// The parent view declares a property to hold the playing state, using the
/// ``State`` property wrapper to indicate that this property is the value's
/// source of truth.
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var isPlaying: Bool = false
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                     .foregroundStyle(isPlaying ? .primary : .secondary)
///                 PlayButton(isPlaying: $isPlaying) // Pass a binding.
///             }
///         }
///     }
///
/// When `PlayerView` initializes `PlayButton`, it passes a binding of its state
/// property into the button's binding property. Applying the `$` prefix to a
/// property wrapped value returns its ``State/projectedValue``, which for a
/// state property wrapper returns a binding to the value.
///
/// Whenever the user taps the `PlayButton`, the `PlayerView` updates its
/// `isPlaying` state.
///
/// > Note: To create bindings to properties of a type that conforms to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol, use the ``Bindable`` property wrapper. For more information,
/// see <doc:Migrating-from-the-observable-object-protocol-to-the-observable-macro>.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen @propertyWrapper @dynamicMemberLookup public struct Binding<Value> {
/// The binding's transaction.
///
/// The transaction captures the information needed to update the view when
/// the binding value changes.
public var transaction: Transaction
/// Creates a binding with closures that read and write the binding value.
///
/// - Parameters:
///   - get: A closure that retrieves the binding value. The closure has no
///     parameters, and returns a value.
///   - set: A closure that sets the binding value. The closure has the
///     following parameter:
///       - newValue: The new value of the binding value.
public init(get: @escaping () -> Value, set: @escaping (Value) -> Void)
/// Creates a binding with a closure that reads from the binding value, and
/// a closure that applies a transaction when writing to the binding value.
///
/// - Parameters:
///   - get: A closure to retrieve the binding value. The closure has no
///     parameters, and returns a value.
///   - set: A closure to set the binding value. The closure has the
///     following parameters:
///       - newValue: The new value of the binding value.
///       - transaction: The transaction to apply when setting a new value.
public init(get: @escaping () -> Value, set: @escaping (Value, Transaction) -> Void)
/// Creates a binding with an immutable value.
///
/// Use this method to create a binding to a value that cannot change.
/// This can be useful when using a ``PreviewProvider`` to see how a view
/// represents different values.
///
///     // Example of binding to an immutable value.
///     PlayButton(isPlaying: Binding.constant(true))
///
/// - Parameter value: An immutable value.
public static func constant(_ value: Value) -> Binding<Value>
/// The underlying value referenced by the binding variable.
///
/// This property provides primary access to the value's data. However, you
/// don't access `wrappedValue` directly. Instead, you use the property
/// variable created with the ``Binding`` attribute. In the
/// following code example, the binding variable `isPlaying` returns the
/// value of `wrappedValue`:
///
///     struct PlayButton: View {
///         @Binding var isPlaying: Bool
///
///         var body: some View {
///             Button(isPlaying ? "Pause" : "Play") {
///                 isPlaying.toggle()
///             }
///         }
///     }
///
/// When a mutable binding value changes, the new value is immediately
/// available. However, updates to a view displaying the value happens
/// asynchronously, so the view may not show the change immediately.
public var wrappedValue: Value { get nonmutating set }
/// A projection of the binding value that returns a binding.
///
/// Use the projected value to pass a binding value down a view hierarchy.
/// To get the `projectedValue`, prefix the property variable with `$`. For
/// example, in the following code example `PlayerView` projects a binding
/// of the state property `isPlaying` to the `PlayButton` view using
/// `$isPlaying`.
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var isPlaying: Bool = false
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                     .foregroundStyle(isPlaying ? .primary : .secondary)
///                 PlayButton(isPlaying: $isPlaying)
///             }
///         }
///     }
///
public var projectedValue: Binding<Value> { get }
/// Creates a binding from the value of another binding.
public init(projectedValue: Binding<Value>)
/// Returns a binding to the resulting value of a given key path.
///
/// - Parameter keyPath: A key path to a specific resulting value.
///
/// - Returns: A new binding.
public subscript<Subject>(dynamicMember keyPath: WritableKeyPath<Value, Subject>) -> Binding<Subject> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Binding {
/// Creates a binding by projecting the base value to an optional value.
///
/// - Parameter base: A value to project to an optional value.
public init<V>(_ base: Binding<V>) where Value == V?
/// Creates a binding by projecting the base value to an unwrapped value.
///
/// - Parameter base: A value to project to an unwrapped value.
///
/// - Returns: A new binding or `nil` when `base` is `nil`.
public init?(_ base: Binding<Value?>)
/// Creates a binding by projecting the base value to a hashable value.
///
/// - Parameters:
///   - base: A `Hashable` value to project to an `AnyHashable` value.
public init<V>(_ base: Binding<V>) where Value == AnyHashable, V : Hashable
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Binding : Identifiable where Value : Identifiable {
/// The stable identity of the entity associated with this instance,
/// corresponding to the `id` of the binding's wrapped value.
public var id: Value.ID { get }
/// A type representing the stable identity of the entity associated with
/// an instance.
public typealias ID = Value.ID
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Binding : Sequence where Value : MutableCollection {
/// A type representing the sequence's elements.
public typealias Element = Binding<Value.Element>
/// A type that provides the sequence's iteration interface and
/// encapsulates its iteration state.
public typealias Iterator = IndexingIterator<Binding<Value>>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<Binding<Value>>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Binding : Collection where Value : MutableCollection {
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public typealias Index = Value.Index
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = Value.Indices
/// The position of the first element in a nonempty collection.
///
/// If the collection is empty, `startIndex` is equal to `endIndex`.
public var startIndex: Binding<Value>.Index { get }
/// The collection's "past the end" position---that is, the position one
/// greater than the last valid subscript argument.
///
/// When you need a range that includes the last element of a collection, use
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator
/// creates a range that doesn't include the upper bound, so it's always
/// safe to use with `endIndex`. For example:
///
///     let numbers = [10, 20, 30, 40, 50]
///     if let index = numbers.firstIndex(of: 30) {
///         print(numbers[index ..< numbers.endIndex])
///     }
///     // Prints "[30, 40, 50]"
///
/// If the collection is empty, `endIndex` is equal to `startIndex`.
public var endIndex: Binding<Value>.Index { get }
/// The indices that are valid for subscripting the collection, in ascending
/// order.
///
/// A collection's `indices` property can hold a strong reference to the
/// collection itself, causing the collection to be nonuniquely referenced.
/// If you mutate the collection while iterating over its indices, a strong
/// reference can result in an unexpected copy of the collection. To avoid
/// the unexpected copy, use the `index(after:)` method starting with
/// `startIndex` to produce indices instead.
///
///     var c = MyFancyCollection([10, 20, 30, 40, 50])
///     var i = c.startIndex
///     while i != c.endIndex {
///         c[i] /= 5
///         i = c.index(after: i)
///     }
///     // c == MyFancyCollection([2, 4, 6, 8, 10])
public var indices: Value.Indices { get }
/// Returns the position immediately after the given index.
///
/// The successor of an index must be well defined. For an index `i` into a
/// collection `c`, calling `c.index(after: i)` returns the same index every
/// time.
///
/// - Parameter i: A valid index of the collection. `i` must be less than
///   `endIndex`.
/// - Returns: The index value immediately after `i`.
public func index(after i: Binding<Value>.Index) -> Binding<Value>.Index
/// Replaces the given index with its successor.
///
/// - Parameter i: A valid index of the collection. `i` must be less than
///   `endIndex`.
public func formIndex(after i: inout Binding<Value>.Index)
/// Accesses the element at the specified position.
///
/// The following example accesses an element of an array through its
/// subscript to print its value:
///
///     var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"]
///     print(streets[1])
///     // Prints "Bryant"
///
/// You can subscript a collection with any valid index other than the
/// collection's end index. The end index refers to the position one past
/// the last element of a collection, so it doesn't correspond with an
/// element.
///
/// - Parameter position: The position of the element to access. `position`
///   must be a valid index of the collection that is not equal to the
///   `endIndex` property.
///
/// - Complexity: O(1)
public subscript(position: Binding<Value>.Index) -> Binding<Value>.Element { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Binding : BidirectionalCollection where Value : BidirectionalCollection, Value : MutableCollection {
/// Returns the position immediately before the given index.
///
/// - Parameter i: A valid index of the collection. `i` must be greater than
///   `startIndex`.
/// - Returns: The index value immediately before `i`.
public func index(before i: Binding<Value>.Index) -> Binding<Value>.Index
/// Replaces the given index with its predecessor.
///
/// - Parameter i: A valid index of the collection. `i` must be greater than
///   `startIndex`.
public func formIndex(before i: inout Binding<Value>.Index)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Binding : RandomAccessCollection where Value : MutableCollection, Value : RandomAccessCollection {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Binding {
/// Specifies a transaction for the binding.
///
/// - Parameter transaction  : An instance of a ``Transaction``.
///
/// - Returns: A new binding.
public func transaction(_ transaction: Transaction) -> Binding<Value>
/// Specifies an animation to perform when the binding value changes.
///
/// - Parameter animation: An animation sequence performed when the binding
///   value changes.
///
/// - Returns: A new binding.
public func animation(_ animation: Animation? = .default) -> Binding<Value>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Binding : DynamicProperty {
}
/// Modes for compositing a view with overlapping content.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum BlendMode : Sendable {
case normal
case multiply
case screen
case overlay
case darken
case lighten
case colorDodge
case colorBurn
case softLight
case hardLight
case difference
case exclusion
case hue
case saturation
case color
case luminosity
case sourceAtop
case destinationOver
case destinationOut
case plusDarker
case plusLighter
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: BlendMode, b: BlendMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension BlendMode : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension BlendMode : Hashable {
}
/// A button style that applies standard border artwork based on the button's
/// context.
///
/// You can also use ``PrimitiveButtonStyle/bordered`` to construct this style.
@available(iOS 15.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
public struct BorderedButtonStyle : PrimitiveButtonStyle {
/// Creates a bordered button style.
public init()
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration: The properties of the button.
public func makeBody(configuration: BorderedButtonStyle.Configuration) -> some View
/// A view that represents the body of a button.
public typealias Body = some View
}
/// A button style that applies standard border prominent artwork based
/// on the button's context.
///
/// Use ``PrimitiveButtonStyle/borderedProminent`` to construct this style.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct BorderedProminentButtonStyle : PrimitiveButtonStyle {
/// Creates a bordered prominent button style.
public init()
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
public func makeBody(configuration: BorderedProminentButtonStyle.Configuration) -> some View
/// A view that represents the body of a button.
public typealias Body = some View
}
/// A menu style that displays a borderless button that toggles the display of
/// the menu's contents when pressed.
///
/// Use ``MenuStyle/borderlessButton`` to construct this style.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(tvOS, introduced: 17.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
public struct BorderlessButtonMenuStyle : MenuStyle {
/// Creates a borderless button menu style.
public init()
/// Creates a view that represents the body of a menu.
///
/// - Parameter configuration: The properties of the menu.
///
/// The system calls this method for each ``Menu`` instance in a view
/// hierarchy where this style is the current menu style.
public func makeBody(configuration: BorderlessButtonMenuStyle.Configuration) -> some View
/// A view that represents the body of a menu.
public typealias Body = some View
}
/// A button style that doesn't apply a border.
///
/// You can also use ``PrimitiveButtonStyle/borderless`` to construct this
/// style.
@available(iOS 13.0, macOS 10.15, tvOS 17.0, watchOS 8.0, *)
public struct BorderlessButtonStyle : PrimitiveButtonStyle {
/// Creates a borderless button style.
public init()
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
public func makeBody(configuration: BorderlessButtonStyle.Configuration) -> some View
/// A view that represents the body of a button.
public typealias Body = some View
}
/// A control that initiates an action.
///
/// You create a button by providing an action and a label. The action is either
/// a method or closure property that does something when a user clicks or taps
/// the button. The label is a view that describes the button's action --- for
/// example, by showing text, an icon, or both.
///
/// The label of a button can be any kind of view, such as a ``Text`` view for
/// text-only labels:
///
///     Button(action: signIn) {
///         Text("Sign In")
///     }
///
/// Or a ``Label`` view, for buttons with both a title and an icon:
///
///     Button(action: signIn) {
///         Label("Sign In", systemImage: "arrow.up")
///     }
///
/// For those common cases, you can also use the convenience initializers that
/// take a title string or ``LocalizedStringKey`` as their first parameter, and
/// optionally a system image name or `ImageResource` as their second parameter,
/// instead of a trailing closure:
///
///     Button("Sign In", systemImage: "arrow.up", action: signIn)
///
/// Prefer to use these convenience initializers, or a ``Label`` view, when
/// providing both a title and an icon. This allows the button to dynamically
/// adapt its appearance to render its title and icon correctly in containers
/// such as toolbars and menus. For example, on iOS, buttons only display their
/// icons by default when placed in toolbars, but show both a leading title and
/// trailing icon in menus. Defining labels this way also helps with
/// accessibility --- for example, applying the ``View/labelStyle(_:)`` modifier
/// with an ``LabelStyle/iconOnly`` style to the button will cause it to only
/// visually display its icon, but still use its title to describe the button in
/// accessibility modes like VoiceOver:
///
///     Button("Sign In", systemImage: "arrow.up", action: signIn)
///         .labelStyle(.iconOnly)
///
/// Avoid labels that only use images or exclusively visual components without
/// an accessibility label.
///
/// How the user activates the button varies by platform:
/// - In iOS and watchOS, the user taps the button.
/// - In macOS, the user clicks the button.
/// - In tvOS, the user presses "select" on an
///   external remote, like the Siri Remote, while focusing on the button.
///
/// The appearance of the button depends on factors like where you
/// place it, whether you assign it a role, and how you style it.
///
/// ### Adding buttons to containers
///
/// Use buttons for any user interface element that initiates an action.
/// Buttons automatically adapt their visual style to match the expected style
/// within these different containers and contexts. For example, to create a
/// ``List`` cell that initiates an action when selected by the user, add a
/// button to the list's content:
///
///     List {
///         // Cells that show all the current folders.
///         ForEach(folders) { folder in
///             Text(folder.title)
///         }
///
///         // A cell that, when selected, adds a new folder.
///         Button(action: addItem) {
///             Label("Add Folder", systemImage: "folder.badge.plus")
///         }
///     }
///
/// ![A screenshot of a list of four items. The first three items use a
/// grayscale foreground color and have the text Documents, Downloads,
/// and Recents. The last item has a blue foreground color and shows
/// a folder icon with the text Add Folder.](Button-1)
///
/// Similarly, to create a context menu item that initiates an action, add a
/// button to the ``View/contextMenu(_:)`` modifier's content closure:
///
///     .contextMenu {
///         Button("Cut", action: cut)
///         Button("Copy", action: copy)
///         Button("Paste", action: paste)
///     }
///
/// ![A screenshot of a context menu that contains the three items Cut, Copy,
/// and Paste.](Button-2)
///
/// This pattern extends to most other container views in SwiftUI that have
/// customizable, interactive content, like ``Form`` instances.
///
/// ### Assigning a role
///
/// You can optionally initialize a button with a ``ButtonRole`` that
/// characterizes the button's purpose. For example, you can create a
/// ``ButtonRole/destructive`` button for a deletion action:
///
///      Button("Delete", role: .destructive, action: delete)
///
/// The system uses the button's role to style the button appropriately
/// in every context. For example, a destructive button in a contextual menu
/// appears with a red foreground color:
///
/// ![A screenshot of a context menu that contains the four items Cut, Copy,
/// Paste, and Delete. The last item uses a foreground color of red.](Button-3)
///
/// If you don't specify a role for a button, the system applies an
/// appropriate default appearance.
///
/// ### Styling buttons
///
/// You can customize a button's appearance using one of the standard button
/// styles, like ``PrimitiveButtonStyle/bordered``, and apply the style with the
/// ``View/buttonStyle(_:)-66fbx`` modifier:
///
///     HStack {
///         Button("Sign In", action: signIn)
///         Button("Register", action: register)
///     }
///     .buttonStyle(.bordered)
///
/// If you apply the style to a container view, as in the example above,
/// all the buttons in the container use the style:
///
/// ![A screenshot of two buttons, side by side, each with a capsule shaped
/// background. The label for the first button is Sign In; the right button is
/// Register.](Button-4)
///
/// You can also create custom styles. To add a custom appearance with
/// standard interaction behavior, create a style that conforms to the
/// ``ButtonStyle`` protocol. To customize both appearance and interaction
/// behavior, create a style that conforms to the ``PrimitiveButtonStyle``
/// protocol. Custom styles can also read the button's role and use it to
/// adjust the button's appearance.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Button<Label> : View where Label : View {
/// Creates a button that displays a custom label.
///
/// - Parameters:
///   - action: The action to perform when the user triggers the button.
///   - label: A view that describes the purpose of the button's `action`.
public init(action: @escaping () -> Void, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Button where Label == Text {
/// Creates a button that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// To initialize a button with a string variable, use
/// ``Button/init(_:action:)-lpm7`` instead.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, action: @escaping () -> Void)
/// Creates a button that generates its label from a string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// To initialize a button with a localized string key, use
/// ``Button/init(_:action:)-1asy`` instead.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - action: The action to perform when the user triggers the button.
public init<S>(_ title: S, action: @escaping () -> Void) where S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Button where Label == Label<Text, Image> {
/// Creates a button that generates its label from a localized string key
/// and system image name.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - systemImage: The name of the image resource to lookup.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, systemImage: String, action: @escaping () -> Void)
/// Creates a button that generates its label from a string and
/// system image name.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - systemImage: The name of the image resource to lookup.
///   - action: The action to perform when the user triggers the button.
public init<S>(_ title: S, systemImage: String, action: @escaping () -> Void) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Button where Label == Label<Text, Image> {
/// Creates a button that generates its label from a localized string key
/// and image resource.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - image: The image resource to lookup.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, action: @escaping () -> Void)
/// Creates a button that generates its label from a string and
/// image resource.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - image: The image resource to lookup.
///   - action: The action to perform when the user triggers the button.
public init<S>(_ title: S, image: ImageResource, action: @escaping () -> Void) where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Button where Label == PrimitiveButtonStyleConfiguration.Label {
/// Creates a button based on a configuration for a style with a custom
/// appearance and custom interaction behavior.
///
/// Use this initializer within the
/// ``PrimitiveButtonStyle/makeBody(configuration:)`` method of a
/// ``PrimitiveButtonStyle`` to create an instance of the button that you
/// want to style. This is useful for custom button styles that modify the
/// current button style, rather than implementing a brand new style.
///
/// For example, the following style adds a red border around the button,
/// but otherwise preserves the button's current style:
///
///     struct RedBorderedButtonStyle: PrimitiveButtonStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Button(configuration)
///                 .border(Color.red)
///         }
///     }
///
/// - Parameter configuration: A configuration for a style with a custom
///   appearance and custom interaction behavior.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init(_ configuration: PrimitiveButtonStyleConfiguration)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Button {
/// Creates a button with a specified role that displays a custom label.
///
/// - Parameters:
///   - role: An optional semantic role that describes the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user interacts with the button.
///   - label: A view that describes the purpose of the button's `action`.
public init(role: ButtonRole?, action: @escaping () -> Void, @ViewBuilder label: () -> Label)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Button where Label == Text {
/// Creates a button with a specified role that generates its label from a
/// localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// To initialize a button with a string variable, use
/// ``init(_:role:action:)-8y5yk`` instead.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, role: ButtonRole?, action: @escaping () -> Void)
/// Creates a button with a specified role that generates its label from a
/// string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// To initialize a button with a localized string key, use
/// ``init(_:role:action:)-93ek6`` instead.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user interacts with the button.
public init<S>(_ title: S, role: ButtonRole?, action: @escaping () -> Void) where S : StringProtocol
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Button where Label == Label<Text, Image> {
/// Creates a button with a specified role that generates its label from a
/// localized string key and a system image.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - systemImage: The name of the image resource to lookup.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, systemImage: String, role: ButtonRole?, action: @escaping () -> Void)
/// Creates a button with a specified role that generates its label from a
/// string and a system image and an image resource.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - systemImage: The name of the image resource to lookup.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user interacts with the button.
public init<S>(_ title: S, systemImage: String, role: ButtonRole?, action: @escaping () -> Void) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Button where Label == Label<Text, Image> {
/// Creates a button with a specified role that generates its label from a
/// localized string key and an image resource.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the button's localized title, that describes
///     the purpose of the button's `action`.
///   - image: The image resource to lookup.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user triggers the button.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, role: ButtonRole?, action: @escaping () -> Void)
/// Creates a button with a specified role that generates its label from a
/// string and an image resource.
///
/// This initializer creates a ``Label`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - title: A string that describes the purpose of the button's `action`.
///   - image: The image resource to lookup.
///   - role: An optional semantic role describing the button. A value of
///     `nil` means that the button doesn't have an assigned role.
///   - action: The action to perform when the user interacts with the button.
public init<S>(_ title: S, image: ImageResource, role: ButtonRole?, action: @escaping () -> Void) where S : StringProtocol
}
/// A shape that is used to draw a button's border.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct ButtonBorderShape : Equatable, Sendable {
/// A shape that defers to the system to determine an appropriate shape
/// for the given context and platform.
public static let automatic: ButtonBorderShape
/// A capsule shape.
///
/// - Note: This has no effect on non-widget system buttons on macOS.
@available(macOS 14.0, tvOS 17.0, *)
public static let capsule: ButtonBorderShape
/// A rounded rectangle shape.
public static let roundedRectangle: ButtonBorderShape
/// A rounded rectangle shape.
///
/// - Parameter radius: the corner radius of the rectangle.
/// - Note: This has no effect on non-widget system buttons on macOS.
@available(macOS 14.0, tvOS 17.0, *)
public static func roundedRectangle(radius: CGFloat) -> ButtonBorderShape
@available(iOS 17.0, macOS 14.0, tvOS 16.4, watchOS 10.0, *)
public static let circle: ButtonBorderShape
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ButtonBorderShape, b: ButtonBorderShape) -> Bool
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ButtonBorderShape : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ButtonBorderShape : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A menu style that displays a button that toggles the display of the
/// menu's contents when pressed.
///
/// Use ``MenuStyle/button`` to construct this style.
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct ButtonMenuStyle : MenuStyle {
/// Creates a button menu style.
public init()
/// Creates a view that represents the body of a menu.
///
/// - Parameter configuration: The properties of the menu.
///
/// The system calls this method for each ``Menu`` instance in a view
/// hierarchy where this style is the current menu style.
public func makeBody(configuration: ButtonMenuStyle.Configuration) -> some View
/// A view that represents the body of a menu.
public typealias Body = some View
}
/// The options for controlling the repeatability of button actions.
///
/// Use values of this type with the ``View/buttonRepeatBehavior(_:)``
/// modifier.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ButtonRepeatBehavior : Hashable, Sendable {
/// The automatic repeat behavior.
public static let automatic: ButtonRepeatBehavior
/// Repeating button actions will be enabled.
public static let enabled: ButtonRepeatBehavior
/// Repeating button actions will be disabled.
public static let disabled: ButtonRepeatBehavior
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ButtonRepeatBehavior, b: ButtonRepeatBehavior) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A value that describes the purpose of a button.
///
/// A button role provides a description of a button's purpose.  For example,
/// the ``ButtonRole/destructive`` role indicates that a button performs
/// a destructive action, like delete user data:
///
///     Button("Delete", role: .destructive) { delete() }
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct ButtonRole : Equatable, Sendable {
/// A role that indicates a destructive button.
///
/// Use this role for a button that deletes user data, or performs an
/// irreversible operation. A destructive button signals by its appearance
/// that the user should carefully consider whether to tap or click the
/// button. For example, SwiftUI presents a destructive button that you add
/// with the ``View/swipeActions(edge:allowsFullSwipe:content:)``
/// modifier using a red background:
///
///     List {
///         ForEach(items) { item in
///             Text(item.title)
///                 .swipeActions {
///                     Button(role: .destructive) { delete() } label: {
///                         Label("Delete", systemImage: "trash")
///                     }
///                 }
///         }
///     }
///     .navigationTitle("Shopping List")
///
/// ![A screenshot of a list of three items, where the second item is
/// shifted to the left, and the row displays a red button with a trash
/// icon on the right side.](ButtonRole-destructive-1)
public static let destructive: ButtonRole
/// A role that indicates a button that cancels an operation.
///
/// Use this role for a button that cancels the current operation.
public static let cancel: ButtonRole
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ButtonRole, b: ButtonRole) -> Bool
}
/// A type that applies standard interaction behavior and a custom appearance to
/// all buttons within a view hierarchy.
///
/// To configure the current button style for a view hierarchy, use the
/// ``View/buttonStyle(_:)-7qx1`` modifier. Specify a style that conforms to
/// `ButtonStyle` when creating a button that uses the standard button
/// interaction behavior defined for each platform. To create a button with
/// custom interaction behavior, use ``PrimitiveButtonStyle`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ButtonStyle {
/// A view that represents the body of a button.
associatedtype Body : View
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a button.
typealias Configuration = ButtonStyleConfiguration
}
/// The properties of a button.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct ButtonStyleConfiguration {
/// A type-erased label of a button.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// An optional semantic role that describes the button's purpose.
///
/// A value of `nil` means that the Button doesn't have an assigned role. If
/// the button does have a role, use it to make adjustments to the button's
/// appearance. The following example shows a custom style that uses
/// bold text when the role is ``ButtonRole/cancel``,
/// ``ShapeStyle/red`` text when the role is ``ButtonRole/destructive``,
/// and adds no special styling otherwise:
///
///     struct MyButtonStyle: ButtonStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             configuration.label
///                 .font(
///                     configuration.role == .cancel ? .title2.bold() : .title2)
///                 .foregroundColor(
///                     configuration.role == .destructive ? Color.red : nil)
///         }
///     }
///
/// You can create one of each button using this style to see the effect:
///
///     VStack(spacing: 20) {
///         Button("Cancel", role: .cancel) {}
///         Button("Delete", role: .destructive) {}
///         Button("Continue") {}
///     }
///     .buttonStyle(MyButtonStyle())
///
/// ![A screenshot of three buttons stacked vertically. The first says
/// Cancel in black, bold letters. The second says Delete in red, regular
/// weight letters. The third says Continue in black, regular weight
/// letters.](ButtonStyleConfiguration-role-1)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public let role: ButtonRole?
/// A view that describes the effect of pressing the button.
public let label: ButtonStyleConfiguration.Label
/// A Boolean that indicates whether the user is currently pressing the
/// button.
public let isPressed: Bool
}
/// A toggle style that displays as a button with its label as the title.
///
/// You can also use ``ToggleStyle/button`` to construct this style.
///
///     Toggle(isOn: $isFlagged) {
///         Label("Flag", systemImage: "flag.fill")
///     }
///     .toggleStyle(.button)
///
@available(iOS 15.0, macOS 12.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct ButtonToggleStyle : ToggleStyle {
/// Creates a button toggle style.
///
/// Don't call this initializer directly. Instead, use the
/// ``ToggleStyle/button`` static variable to create this style:
///
///     Toggle(isOn: $isFlagged) {
///         Label("Flag", systemImage: "flag.fill")
///     }
///     .toggleStyle(.button)
///
public init()
/// Creates a view that represents the body of a toggle button.
///
/// SwiftUI implements this required method of the ``ToggleStyle``
/// protocol to define the behavior and appearance of the
/// ``ToggleStyle/button`` toggle style. Don't call this method
/// directly; the system calls this method for each
/// ``Toggle`` instance in a view hierarchy that's styled as
/// a button.
///
/// - Parameter configuration: The properties of the toggle, including a
///   label and a binding to the toggle's state.
/// - Returns: A view that acts as a button that controls a Boolean state.
public func makeBody(configuration: ButtonToggleStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a toggle.
///
/// SwiftUI infers this type automatically based on the ``View``
/// instance that you return from your implementation of the
/// ``makeBody(configuration:)`` method.
public typealias Body = some View
}
/// A view type that supports immediate mode drawing.
///
/// Use a canvas to draw rich and dynamic 2D graphics inside a SwiftUI view.
/// The canvas passes a ``GraphicsContext`` to the closure that you use
/// to perform immediate mode drawing operations. The canvas also passes a
/// <doc://com.apple.documentation/documentation/CoreFoundation/CGSize> value
/// that you can use to customize what you draw. For example, you can use the
/// context's ``GraphicsContext/stroke(_:with:lineWidth:)`` command to draw
/// a ``Path`` instance:
///
///     Canvas { context, size in
///         context.stroke(
///             Path(ellipseIn: CGRect(origin: .zero, size: size)),
///             with: .color(.green),
///             lineWidth: 4)
///     }
///     .frame(width: 300, height: 200)
///     .border(Color.blue)
///
/// The example above draws the outline of an ellipse that exactly inscribes
/// a canvas with a blue border:
///
/// ![A screenshot of a canvas view that shows the green outline of an
/// ellipse inside a blue rectangle.](Canvas-1)
///
/// In addition to outlined and filled paths, you can draw images, text, and
/// complete SwiftUI views. To draw views, use the
/// ``init(opaque:colorMode:rendersAsynchronously:renderer:symbols:)`` method
/// to supply views that you can reference from inside the renderer. You can
/// also add masks, apply filters, perform transforms, control blending, and
/// more. For information about how to draw, see ``GraphicsContext``.
///
/// A canvas doesn't offer interactivity or accessibility for
/// individual elements, including for views that you pass in as symbols.
/// However, it might provide better performance for a complex drawing that
/// involves dynamic data. Use a canvas to improve performance for a drawing
/// that doesn't primarily involve text or require interactive elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct Canvas<Symbols> where Symbols : View {
/// A view that provides child views that you can use in the drawing
/// callback.
///
/// Uniquely tag each child view using the ``View/tag(_:)`` modifier,
/// so that you can find them from within your renderer using the
/// ``GraphicsContext/resolveSymbol(id:)`` method.
public var symbols: Symbols
/// The drawing callback that you use to draw into the canvas.
///
/// - Parameters:
///   - context: The graphics context to draw into.
///   - size: The current size of the view.
public var renderer: (inout GraphicsContext, CGSize) -> Void
/// A Boolean that indicates whether the canvas is fully opaque.
///
/// You might be able to improve performance by setting this value to
/// `true`, making the canvas is fully opaque. However, in that case,
/// the result of drawing a non-opaque image into the canvas is undefined.
public var isOpaque: Bool
/// The working color space and storage format of the canvas.
public var colorMode: ColorRenderingMode
/// A Boolean that indicates whether the canvas can present its contents
/// to its parent view asynchronously.
public var rendersAsynchronously: Bool
/// Creates and configures a canvas that you supply with renderable
/// child views.
///
/// This initializer behaves like the
/// ``init(opaque:colorMode:rendersAsynchronously:renderer:)`` initializer,
/// except that you also provide a collection of SwiftUI views for the
/// renderer to use as drawing elements.
///
/// SwiftUI stores a rendered version of each child view that you specify
/// in the `symbols` view builder and makes these available to the canvas.
/// Tag each child view so that you can retrieve it from within the
/// renderer using the ``GraphicsContext/resolveSymbol(id:)`` method.
/// For example, you can create a scatter plot using a passed-in child view
/// as the mark for each data point:
///
///     struct ScatterPlotView<Mark: View>: View {
///         let rects: [CGRect]
///         let mark: Mark
///
///         enum SymbolID: Int {
///             case mark
///         }
///
///         var body: some View {
///             Canvas { context, size in
///                 if let mark = context.resolveSymbol(id: SymbolID.mark) {
///                     for rect in rects {
///                         context.draw(mark, in: rect)
///                     }
///                 }
///             } symbols: {
///                 mark.tag(SymbolID.mark)
///             }
///             .frame(width: 300, height: 200)
///             .border(Color.blue)
///         }
///     }
///
/// You can use any SwiftUI view for the `mark` input:
///
///     ScatterPlotView(rects: rects, mark: Image(systemName: "circle"))
///
/// If the `rects` input contains 50 randomly arranged
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGRect>
/// instances, SwiftUI draws a plot like this:
///
/// ![A screenshot of a scatter plot inside a blue rectangle, containing
/// about fifty small circles scattered randomly throughout.](Canvas-init-1)
///
/// The symbol inputs, like all other elements that you draw to the
/// canvas, lack individual accessibility and interactivity, even if the
/// original SwiftUI view has these attributes. However, you can add
/// accessibility and interactivity modifers to the canvas as a whole.
///
/// - Parameters:
///   - opaque: A Boolean that indicates whether the canvas is fully
///     opaque. You might be able to improve performance by setting this
///     value to `true`, but then drawing a non-opaque image into the
///     context produces undefined results. The default is `false`.
///   - colorMode: A working color space and storage format of the canvas.
///     The default is ``ColorRenderingMode/nonLinear``.
///   - rendersAsynchronously: A Boolean that indicates whether the canvas
///     can present its contents to its parent view asynchronously. The
///     default is `false`.
///   - renderer: A closure in which you conduct immediate mode drawing.
///     The closure takes two inputs: a context that you use to issue
///     drawing commands and a size --- representing the current
///     size of the canvas --- that you can use to customize the content.
///     The canvas calls the renderer any time it needs to redraw the
///     content.
///   - symbols: A ``ViewBuilder`` that you use to supply SwiftUI views to
///     the canvas for use during drawing. Uniquely tag each view
///     using the ``View/tag(_:)`` modifier, so that you can find them from
///     within your renderer using the ``GraphicsContext/resolveSymbol(id:)``
///     method.
public init(opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear, rendersAsynchronously: Bool = false, renderer: @escaping (inout GraphicsContext, CGSize) -> Void, @ViewBuilder symbols: () -> Symbols)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Canvas where Symbols == EmptyView {
/// Creates and configures a canvas.
///
/// Use this initializer to create a new canvas that you can draw into.
/// For example, you can draw a path:
///
///     Canvas { context, size in
///         context.stroke(
///             Path(ellipseIn: CGRect(origin: .zero, size: size)),
///             with: .color(.green),
///             lineWidth: 4)
///     }
///     .frame(width: 300, height: 200)
///     .border(Color.blue)
///
/// The example above draws the outline of an ellipse that exactly inscribes
/// a canvas with a blue border:
///
/// ![A screenshot of a canvas view that shows the green outline of an
/// ellipse inside a blue rectangle.](Canvas-1)
///
/// For information about using a context to draw into a canvas, see
/// ``GraphicsContext``. If you want to provide SwiftUI views for the
/// renderer to use as drawing elements, use
/// ``init(opaque:colorMode:rendersAsynchronously:renderer:symbols:)``
/// instead.
///
/// - Parameters:
///   - opaque: A Boolean that indicates whether the canvas is fully
///     opaque. You might be able to improve performance by setting this
///     value to `true`, but then drawing a non-opaque image into the
///     context produces undefined results. The default is `false`.
///   - colorMode: A working color space and storage format of the canvas.
///     The default is ``ColorRenderingMode/nonLinear``.
///   - rendersAsynchronously: A Boolean that indicates whether the canvas
///     can present its contents to its parent view asynchronously. The
///     default is `false`.
///   - renderer: A closure in which you conduct immediate mode drawing.
///     The closure takes two inputs: a context that you use to issue
///     drawing commands and a size --- representing the current
///     size of the canvas --- that you can use to customize the content.
///     The canvas calls the renderer any time it needs to redraw the
///     content.
public init(opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear, rendersAsynchronously: Bool = false, renderer: @escaping (inout GraphicsContext, CGSize) -> Void)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Canvas : View {
}
/// A capsule shape aligned inside the frame of the view containing it.
///
/// A capsule shape is equivalent to a rounded rectangle where the corner radius
/// is chosen as half the length of the rectangle's smallest edge.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Capsule : Shape {
public var style: RoundedCornerStyle
/// Creates a new capsule shape.
///
/// - Parameters:
///   - style: the style of corners drawn by the shape.
@inlinable public init(style: RoundedCornerStyle = .continuous)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in r: CGRect) -> Path
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Capsule : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A circle centered on the frame of the view containing it.
///
/// The circle's radius equals half the length of the frame rectangle's smallest
/// edge.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Circle : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// Creates a new circle shape.
@inlinable public init()
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Circle {
/// Returns the size of the view that will render the shape, given
/// a proposed size.
///
/// Implement this method to tell the container of the shape how
/// much space the shape needs to render itself, given a size
/// proposal.
///
/// See ``Layout/sizeThatFits(proposal:subviews:cache:)``
/// for more details about how the layout system chooses the size of
/// views.
///
/// - Parameters:
///   - proposal: A size proposal for the container.
///
/// - Returns: A size that indicates how much space the shape needs.
public func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Circle : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A progress view that uses a circular gauge to indicate the partial
/// completion of an activity.
///
/// On watchOS, and in widgets and complications, a circular progress view
/// appears as a gauge with the ``GaugeStyle/accessoryCircularCapacity``
/// style. If the progress view is indeterminate, the gauge is empty.
///
/// In cases where no determinate circular progress view style is available,
/// circular progress views use an indeterminate style.
///
/// Use ``ProgressViewStyle/circular`` to construct the circular progress view
/// style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct CircularProgressViewStyle : ProgressViewStyle {
/// Creates a circular progress view style.
public init()
/// Creates a circular progress view style with a tint color.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
public init(tint: Color)
/// Creates a view representing the body of a progress view.
///
/// - Parameter configuration: The properties of the progress view being
///   created.
///
/// The view hierarchy calls this method for each progress view where this
/// style is the current progress view style.
///
/// - Parameter configuration: The properties of the progress view, such as
///  its preferred progress type.
public func makeBody(configuration: CircularProgressViewStyle.Configuration) -> some View
/// A view representing the body of a progress view.
public typealias Body = some View
}
/// A representation of a color that adapts to a given context.
///
/// You can create a color in one of several ways:
///
/// * Load a color from an Asset Catalog:
///     ```
///     let aqua = Color("aqua") // Looks in your app's main bundle by default.
///     ```
/// * Specify component values, like red, green, and blue; hue,
///   saturation, and brightness; or white level:
///     ```
///     let skyBlue = Color(red: 0.4627, green: 0.8392, blue: 1.0)
///     let lemonYellow = Color(hue: 0.1639, saturation: 1, brightness: 1)
///     let steelGray = Color(white: 0.4745)
///     ```
/// * Create a color instance from another color, like a
///   <doc://com.apple.documentation/documentation/UIKit/UIColor> or an
///   <doc://com.apple.documentation/documentation/AppKit/NSColor>:
///     ```
///     #if os(iOS)
///     let linkColor = Color(uiColor: .link)
///     #elseif os(macOS)
///     let linkColor = Color(nsColor: .linkColor)
///     #endif
///     ```
/// * Use one of a palette of predefined colors, like ``ShapeStyle/black``,
///   ``ShapeStyle/green``, and ``ShapeStyle/purple``.
///
/// Some view modifiers can take a color as an argument. For example,
/// ``View/foregroundStyle(_:)`` uses the color you provide to set the
/// foreground color for view elements, like text or
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/):
///
///     Image(systemName: "leaf.fill")
///         .foregroundStyle(Color.green)
///
/// ![A screenshot of a green leaf.](Color-1)
///
/// Because SwiftUI treats colors as ``View`` instances, you can also
/// directly add them to a view hierarchy. For example, you can layer
/// a rectangle beneath a sun image using colors defined above:
///
///     ZStack {
///         skyBlue
///         Image(systemName: "sun.max.fill")
///             .foregroundStyle(lemonYellow)
///     }
///     .frame(width: 200, height: 100)
///
/// A color used as a view expands to fill all the space it's given,
/// as defined by the frame of the enclosing ``ZStack`` in the above example:
///
/// ![A screenshot of a yellow sun on a blue background.](Color-2)
///
/// SwiftUI only resolves a color to a concrete value
/// just before using it in a given environment.
/// This enables a context-dependent appearance for
/// system defined colors, or those that you load from an Asset Catalog.
/// For example, a color can have distinct light and dark variants
/// that the system chooses from at render time.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Color : Hashable, CustomStringConvertible, Sendable {
/// Creates a color that represents the specified custom color.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init<T>(_ color: T) where T : Hashable, T : ShapeStyle, T.Resolved == Color.Resolved
/// Evaluates this color to a resolved color given the current
/// `context`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func resolve(in environment: EnvironmentValues) -> Color.Resolved
/// A Core Graphics representation of the color, if available.
///
/// You can get a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGColor>
/// instance from a constant SwiftUI color. This includes colors you create
/// from a Core Graphics color, from RGB or HSB components, or from constant
/// UIKit and AppKit colors.
///
/// For a dynamic color, like one you load from an Asset Catalog using
/// ``init(_:bundle:)``, or one you create from a dynamic UIKit or AppKit
/// color, this property is `nil`. To evaluate all types of colors, use the
/// `resolve(in:)` method.
@available(iOS, introduced: 14.0, deprecated: 100000.0, renamed: "resolve(in:)")
@available(macOS, introduced: 11.0, deprecated: 100000.0, renamed: "resolve(in:)")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, renamed: "resolve(in:)")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, renamed: "resolve(in:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "resolve(in:)")
public var cgColor: CGColor? { get }
/// Hashes the essential components of the color by feeding them into the
/// given hash function.
///
/// - Parameters:
///   - hasher: The hash function to use when combining the components of
///     the color.
public func hash(into hasher: inout Hasher)
/// Indicates whether two colors are equal.
///
/// - Parameters:
///   - lhs: The first color to compare.
///   - rhs: The second color to compare.
/// - Returns: A Boolean that's set to `true` if the two colors are equal.
public static func == (lhs: Color, rhs: Color) -> Bool
/// A textual representation of the color.
///
/// Use this method to get a string that represents the color.
/// The <doc://com.apple.documentation/documentation/Swift/1541053-print>
/// function uses this property to get a string representing an instance:
///
///     print(Color.red)
///     // Prints "red"
public var description: String { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color {
/// A concrete color value.
///
/// `Color.Resolved` is a set of RGBA values that represent a color that can
/// be shown. The values are in Linear sRGB color space, extended range. This is
/// a low-level type, most colors are represented by the `Color` type.
///
/// - SeeAlso: `Color`
@frozen public struct Resolved : Hashable {
/// The amount of red in the color in the sRGB linear color space.
public var linearRed: Float
/// The amount of green in the color in the sRGB linear color space.
public var linearGreen: Float
/// The amount of blue in the color in the sRGB linear color space.
public var linearBlue: Float
/// The degree of opacity in the color, given in the range `0` to `1`.
///
/// A value of `0` means 100% transparency, while a value of `1` means
/// 100% opacity.
public var opacity: Float
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Color.Resolved, b: Color.Resolved) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Creates a constant color with the values specified by the resolved
/// color.
public init(_ resolved: Color.Resolved)
}
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use Color(cgColor:) when converting a CGColor, or create a standard Color directly")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use Color(cgColor:) when converting a CGColor, or create a standard Color directly")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Use Color(cgColor:) when converting a CGColor, or create a standard Color directly")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use Color(cgColor:) when converting a CGColor, or create a standard Color directly")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use Color(cgColor:) when converting a CGColor, or create a standard Color directly")
extension Color {
/// Creates a color from a Core Graphics color.
///
/// - Parameter color: A
///   <doc://com.apple.documentation/documentation/CoreGraphics/CGColor> instance
///   from which to create a color.
public init(_ cgColor: CGColor)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Color {
/// Creates a color from a Core Graphics color.
///
/// - Parameter color: A
///   <doc://com.apple.documentation/documentation/CoreGraphics/CGColor> instance
///   from which to create a color.
public init(cgColor: CGColor)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color {
/// Creates a color from a color set that you indicate by name.
///
/// Use this initializer to load a color from a color set stored in an
/// Asset Catalog. The system determines which color within the set to use
/// based on the environment at render time. For example, you
/// can provide light and dark versions for background and foreground
/// colors:
///
/// ![A screenshot of color sets for foreground and background colors,
///   each with light and dark variants,
///   in an Asset Catalog.](Color-init-1)
///
/// You can then instantiate colors by referencing the names of the assets:
///
///     struct Hello: View {
///         var body: some View {
///             ZStack {
///                 Color("background")
///                 Text("Hello, world!")
///                     .foregroundStyle(Color("foreground"))
///             }
///             .frame(width: 200, height: 100)
///         }
///     }
///
/// SwiftUI renders the appropriate colors for each appearance:
///
/// ![A side by side comparison of light and dark appearance screenshots
///   of the same content. The light variant shows dark text on a light
///   background, while the dark variant shows light text on a dark
///   background.](Color-init-2)
///
/// - Parameters:
///   - name: The name of the color resource to look up.
///   - bundle: The bundle in which to search for the color resource.
///     If you don't indicate a bundle, the initializer looks in your app's
///     main bundle by default.
public init(_ name: String, bundle: Bundle? = nil)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color {
/// Initialize a `Color` with a color resource.
public init(_ resource: ColorResource)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Color : Transferable {
/// One group of colors–constant colors–created with explicitly specified
/// component values are transferred as is.
///
/// Another group of colors–standard colors, like `Color.mint`,
/// and semantic colors, like `Color.accentColor`–are rendered on screen
/// differently depending on the current ``SwiftUI/Environment``. For transferring,
/// they are resolved against the default environment and might produce
/// a slightly different result at the destination if the source of drag
/// or copy uses a non-default environment.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static var transferRepresentation: some TransferRepresentation { get }
/// The type of the representation used to import and export the item.
///
/// Swift infers this type from the return value of the
/// ``transferRepresentation`` property.
public typealias Representation = some TransferRepresentation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color {
/// A profile that specifies how to interpret a color value for display.
public enum RGBColorSpace : Sendable {
/// The extended red, green, blue (sRGB) color space.
///
/// For information about the sRGB colorimetry and nonlinear
/// transform function, see the IEC 61966-2-1 specification.
///
/// Standard sRGB color spaces clamp the red, green, and blue
/// components of a color to a range of `0` to `1`, but SwiftUI colors
/// use an extended sRGB color space, so you can use component values
/// outside that range.
case sRGB
/// The extended sRGB color space with a linear transfer function.
///
/// This color space has the same colorimetry as ``sRGB``, but uses
/// a linear transfer function.
///
/// Standard sRGB color spaces clamp the red, green, and blue
/// components of a color to a range of `0` to `1`, but SwiftUI colors
/// use an extended sRGB color space, so you can use component values
/// outside that range.
case sRGBLinear
/// The Display P3 color space.
///
/// This color space uses the Digital Cinema Initiatives - Protocol 3
/// (DCI-P3) primary colors, a D65 white point, and the ``sRGB``
/// transfer function.
case displayP3
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Color.RGBColorSpace, b: Color.RGBColorSpace) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Creates a constant color from red, green, and blue component values.
///
/// This initializer creates a constant color that doesn't change based
/// on context. For example, it doesn't have distinct light and dark
/// appearances, unlike various system-defined colors, or a color that
/// you load from an Asset Catalog with ``init(_:bundle:)``.
///
/// A standard sRGB color space clamps each color component — `red`,
/// `green`, and `blue` — to a range of `0` to `1`, but SwiftUI colors
/// use an extended sRGB color space, so
/// you can use component values outside that range. This makes it
/// possible to create colors using the ``RGBColorSpace/sRGB`` or
/// ``RGBColorSpace/sRGBLinear`` color space that make full use of the wider
/// gamut of a diplay that supports ``RGBColorSpace/displayP3``.
///
/// - Parameters:
///   - colorSpace: The profile that specifies how to interpret the color
///     for display. The default is ``RGBColorSpace/sRGB``.
///   - red: The amount of red in the color.
///   - green: The amount of green in the color.
///   - blue: The amount of blue in the color.
///   - opacity: An optional degree of opacity, given in the range `0` to
///     `1`. A value of `0` means 100% transparency, while a value of `1`
///     means 100% opacity. The default is `1`.
public init(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1)
/// Creates a constant grayscale color.
///
/// This initializer creates a constant color that doesn't change based
/// on context. For example, it doesn't have distinct light and dark
/// appearances, unlike various system-defined colors, or a color that
/// you load from an Asset Catalog with ``init(_:bundle:)``.
///
/// A standard sRGB color space clamps the `white` component
/// to a range of `0` to `1`, but SwiftUI colors
/// use an extended sRGB color space, so
/// you can use component values outside that range. This makes it
/// possible to create colors using the ``RGBColorSpace/sRGB`` or
/// ``RGBColorSpace/sRGBLinear`` color space that make full use of the wider
/// gamut of a diplay that supports ``RGBColorSpace/displayP3``.
///
/// - Parameters:
///   - colorSpace: The profile that specifies how to interpret the color
///     for display. The default is ``RGBColorSpace/sRGB``.
///   - white: A value that indicates how white
///     the color is, with higher values closer to 100% white, and lower
///     values closer to 100% black.
///   - opacity: An optional degree of opacity, given in the range `0` to
///     `1`. A value of `0` means 100% transparency, while a value of `1`
///     means 100% opacity. The default is `1`.
public init(_ colorSpace: Color.RGBColorSpace = .sRGB, white: Double, opacity: Double = 1)
/// Creates a constant color from hue, saturation, and brightness values.
///
/// This initializer creates a constant color that doesn't change based
/// on context. For example, it doesn't have distinct light and dark
/// appearances, unlike various system-defined colors, or a color that
/// you load from an Asset Catalog with ``init(_:bundle:)``.
///
/// - Parameters:
///   - hue: A value in the range `0` to `1` that maps to an angle
///     from 0° to 360° to represent a shade on the color wheel.
///   - saturation: A value in the range `0` to `1` that indicates
///     how strongly the hue affects the color. A value of `0` removes the
///     effect of the hue, resulting in gray. As the value increases,
///     the hue becomes more prominent.
///   - brightness: A value in the range `0` to `1` that indicates
///     how bright a color is. A value of `0` results in black, regardless
///     of the other components. The color lightens as you increase this
///     component.
///   - opacity: An optional degree of opacity, given in the range `0` to
///     `1`. A value of `0` means 100% transparency, while a value of `1`
///     means 100% opacity. The default is `1`.
public init(hue: Double, saturation: Double, brightness: Double, opacity: Double = 1)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color {
/// Multiplies the opacity of the color by the given amount.
///
/// - Parameter opacity: The amount by which to multiply the opacity of the
///   color.
/// - Returns: A view with modified opacity.
public func opacity(_ opacity: Double) -> Color
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color {
/// A color that reflects the accent color of the system or app.
///
/// The accent color is a broad theme color applied to
/// views and controls. You can set it at the application level by specifying
/// an accent color in your app's asset catalog.
///
/// > Note: In macOS, SwiftUI applies customization of the accent color
/// only if the user chooses Multicolor under General > Accent color
/// in System Preferences.
///
/// The following code renders a ``Text`` view using the app's accent color:
///
///     Text("Accent Color")
///         .foregroundStyle(Color.accentColor)
///
public static var accentColor: Color { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color : ShapeStyle {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color {
/// A context-dependent red color suitable for use in UI elements.
public static let red: Color
/// A context-dependent orange color suitable for use in UI elements.
public static let orange: Color
/// A context-dependent yellow color suitable for use in UI elements.
public static let yellow: Color
/// A context-dependent green color suitable for use in UI elements.
public static let green: Color
/// A context-dependent mint color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let mint: Color
/// A context-dependent teal color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let teal: Color
/// A context-dependent cyan color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let cyan: Color
/// A context-dependent blue color suitable for use in UI elements.
public static let blue: Color
/// A context-dependent indigo color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let indigo: Color
/// A context-dependent purple color suitable for use in UI elements.
public static let purple: Color
/// A context-dependent pink color suitable for use in UI elements.
public static let pink: Color
/// A context-dependent brown color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let brown: Color
/// A white color suitable for use in UI elements.
public static let white: Color
/// A context-dependent gray color suitable for use in UI elements.
public static let gray: Color
/// A black color suitable for use in UI elements.
public static let black: Color
/// A clear color suitable for use in UI elements.
public static let clear: Color
/// The color to use for primary content.
public static let primary: Color
/// The color to use for secondary content.
public static let secondary: Color
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use Color(uiColor:) when converting a UIColor, or create a standard Color directly")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use Color(uiColor:) when converting a UIColor, or create a standard Color directly")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use Color(uiColor:) when converting a UIColor, or create a standard Color directly")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use Color(uiColor:) when converting a UIColor, or create a standard Color directly")
extension Color {
/// Creates a color from a UIKit color.
///
/// Use this method to create a SwiftUI color from a
/// <doc://com.apple.documentation/documentation/UIKit/UIColor> instance.
/// The new color preserves the adaptability of the original.
/// For example, you can create a rectangle using
/// <doc://com.apple.documentation/documentation/UIKit/UIColor/3173132-link>
/// to see how the shade adjusts to match the user's system settings:
///
///     struct Box: View {
///         var body: some View {
///             Color(UIColor.link)
///                 .frame(width: 200, height: 100)
///         }
///     }
///
/// The `Box` view defined above automatically changes its
/// appearance when the user turns on Dark Mode. With the light and dark
/// appearances placed side by side, you can see the subtle difference
/// in shades:
///
/// ![A side by side comparison of light and dark appearance screenshots of
///   rectangles rendered with the link color. The light variant appears on
///   the left, and the dark variant on the right.](Color-init-3)
///
/// > Note: Use this initializer only if you need to convert an existing
/// <doc://com.apple.documentation/documentation/UIKit/UIColor> to a
/// SwiftUI color. Otherwise, create a SwiftUI ``Color`` using an
/// initializer like ``init(_:red:green:blue:opacity:)``, or use a system
/// color like ``ShapeStyle/blue``.
///
/// - Parameter color: A
///   <doc://com.apple.documentation/documentation/UIKit/UIColor> instance
///   from which to create a color.
public init(_ color: UIColor)
}
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *)
@available(macOS, unavailable)
extension Color {
/// Creates a color from a UIKit color.
///
/// Use this method to create a SwiftUI color from a
/// <doc://com.apple.documentation/documentation/UIKit/UIColor> instance.
/// The new color preserves the adaptability of the original.
/// For example, you can create a rectangle using
/// <doc://com.apple.documentation/documentation/UIKit/UIColor/3173132-link>
/// to see how the shade adjusts to match the user's system settings:
///
///     struct Box: View {
///         var body: some View {
///             Color(uiColor: .link)
///                 .frame(width: 200, height: 100)
///         }
///     }
///
/// The `Box` view defined above automatically changes its
/// appearance when the user turns on Dark Mode. With the light and dark
/// appearances placed side by side, you can see the subtle difference
/// in shades:
///
/// ![A side by side comparison of light and dark appearance screenshots of
///   rectangles rendered with the link color. The light variant appears on
///   the left, and the dark variant on the right.](Color-init-3)
///
/// > Note: Use this initializer only if you need to convert an existing
/// <doc://com.apple.documentation/documentation/UIKit/UIColor> to a
/// SwiftUI color. Otherwise, create a SwiftUI ``Color`` using an
/// initializer like ``init(_:red:green:blue:opacity:)``, or use a system
/// color like ``ShapeStyle/blue``.
///
/// - Parameter color: A
///   <doc://com.apple.documentation/documentation/UIKit/UIColor> instance
///   from which to create a color.
public init(uiColor: UIColor)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Color {
/// Returns the standard gradient for the color `self`.
///
/// For example, filling a rectangle with a gradient derived from
/// the standard blue color:
///
///     Rectangle().fill(.blue.gradient)
///
public var gradient: AnyGradient { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved : ShapeStyle {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved : CustomStringConvertible {
/// A textual representation of this instance.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(describing:)`
/// initializer. This initializer works with any type, and uses the custom
/// `description` property for types that conform to
/// `CustomStringConvertible`:
///
///     struct Point: CustomStringConvertible {
///         let x: Int, y: Int
///
///         var description: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(describing: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `description` property.
public var description: String { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<Float, AnimatablePair<Float, AnimatablePair<Float, Float>>>
/// The data to animate.
public var animatableData: Color.Resolved.AnimatableData
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved {
/// Creates a resolved color from red, green, and blue component values.
///
/// A standard sRGB color space clamps each color component — `red`,
/// `green`, and `blue` — to a range of `0` to `1`, but SwiftUI colors
/// use an extended sRGB color space, so
/// you can use component values outside that range. This makes it
/// possible to create colors using the ``RGBColorSpace/sRGB`` or
/// ``RGBColorSpace/sRGBLinear`` color space that make full use of the
/// wider gamut of a diplay that supports ``RGBColorSpace/displayP3``.
///
/// - Parameters:
///   - colorSpace: The profile that specifies how to interpret the
///     color for display. The default is ``RGBColorSpace/sRGB``.
///   - red: The amount of red in the color.
///   - green: The amount of green in the color.
///   - blue: The amount of blue in the color.
///   - opacity: An optional degree of opacity, given in the range `0`
///     to `1`. A value of `0` means 100% transparency, while a value of
///     `1` means 100% opacity. The default is `1`.
public init(colorSpace: Color.RGBColorSpace = .sRGB, red: Float, green: Float, blue: Float, opacity: Float = 1)
/// The amount of red in the color in the sRGB color space.
public var red: Float
/// The amount of green in the color in the sRGB color space.
public var green: Float
/// The amount of blue in the color in the sRGB color space.
public var blue: Float
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved : Codable {
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
public func encode(to encoder: Encoder) throws
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
public init(from decoder: Decoder) throws
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Color.Resolved {
/// A Core Graphics representation of the color.
///
/// You can get a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGColor>
/// instance from a resolved color.
public var cgColor: CGColor { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color.RGBColorSpace : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Color.RGBColorSpace : Hashable {
}
/// A matrix to use in an RGBA color transformation.
///
/// The matrix has five columns, each with a red, green, blue, and alpha
/// component. You can use the matrix for tasks like creating a color
/// transformation ``GraphicsContext/Filter`` for a ``GraphicsContext`` using
/// the ``GraphicsContext/Filter/colorMatrix(_:)`` method.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public struct ColorMatrix : Equatable {
public var r1: Float
public var r2: Float
public var r3: Float
public var r4: Float
public var r5: Float
public var g1: Float
public var g2: Float
public var g3: Float
public var g4: Float
public var g5: Float
public var b1: Float
public var b2: Float
public var b3: Float
public var b4: Float
public var b5: Float
public var a1: Float
public var a2: Float
public var a3: Float
public var a4: Float
public var a5: Float
/// Creates the identity matrix.
@inlinable public init()
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ColorMatrix, b: ColorMatrix) -> Bool
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ColorMatrix : Sendable {
}
/// A control used to select a color from the system color picker UI.
///
/// The color picker provides a color well that shows the currently selected
/// color, and displays the larger system color picker that allows users to
/// select a new color.
///
/// By default color picker supports colors with opacity; to disable opacity
/// support, set the `supportsOpacity` parameter to `false`.
/// In this mode the color picker won't show controls for adjusting the opacity
/// of the selected color, and strips out opacity from any color set
/// programmatically or selected from the user's system favorites.
///
/// You use `ColorPicker` by embedding it inside a view hierarchy and
/// initializing it with a title string and a ``Binding`` to a ``Color``:
///
///     struct FormattingControls: View {
///         @State private var bgColor =
///             Color(.sRGB, red: 0.98, green: 0.9, blue: 0.2)
///
///         var body: some View {
///             VStack {
///                 ColorPicker("Alignment Guides", selection: $bgColor)
///             }
///         }
///     }
///
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct ColorPicker<Label> : View where Label : View {
/// Creates an instance that selects a color.
///
/// - Parameters:
///     - selection: A ``Binding`` to the variable that displays the
///       selected ``Color``.
///     - supportsOpacity: A Boolean value that indicates whether the color
///       picker allows adjusting the selected color's opacity; the default
///       is `true`.
///     - label: A view that describes the use of the selected color.
///        The system color picker UI sets it's title using the text from
///        this view.
///
public init(selection: Binding<Color>, supportsOpacity: Bool = true, @ViewBuilder label: () -> Label)
/// Creates an instance that selects a color.
///
/// - Parameters:
///     - selection: A ``Binding`` to the variable that displays the
///       selected ``CGColor``.
///     - supportsOpacity: A Boolean value that indicates whether the color
///       picker allows adjusting the selected color's opacity; the default
///       is `true`.
///     - label: A view that describes the use of the selected color.
///        The system color picker UI sets it's title using the text from
///        this view.
///
public init(selection: Binding<CGColor>, supportsOpacity: Bool = true, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ColorPicker where Label == Text {
/// Creates a color picker with a text label generated from a title string key.
///
/// Use ``ColorPicker`` to create a color well that your app uses to allow
/// the selection of a ``Color``. The example below creates a color well
/// using a ``Binding`` to a property stored in a settings object and title
/// you provide:
///
///     final class Settings: ObservableObject {
///         @Published var alignmentGuideColor =
///             Color(.sRGB, red: 0.98, green: 0.9, blue: 0.2)
///     }
///
///     struct FormattingControls: View {
///         @State private var settings = Settings()
///
///         var body: some View {
///             VStack {
///                 // Other formatting controls.
///                 ColorPicker("Alignment Guides",
///                     selection: $settings.alignmentGuideColor
///                 )
///             }
///         }
///     }
///
/// - Parameters:
///   - titleKey: The key for the localized title of the picker.
///   - selection: A ``Binding`` to the variable that displays the
///     selected ``Color``.
///   - supportsOpacity: A Boolean value that indicates whether the color
///     picker allows adjustments to the selected color's opacity; the
///     default is `true`.
public init(_ titleKey: LocalizedStringKey, selection: Binding<Color>, supportsOpacity: Bool = true)
/// Creates a color picker with a text label generated from a title string.
///
/// Use ``ColorPicker`` to create a color well that your app uses to allow
/// the selection of a ``Color``. The example below creates a color well
/// using a ``Binding`` and title you provide:
///
///     func showColorPicker(_ title: String, color: Binding<Color>) {
///         ColorPicker(title, selection: color)
///     }
///
/// - Parameters:
///   - title: The title displayed by the color picker.
///   - selection: A ``Binding`` to the variable containing a ``Color``.
///   - supportsOpacity: A Boolean value that indicates whether the color
///     picker allows adjustments to the selected color's opacity; the
///     default is `true`.
public init<S>(_ title: S, selection: Binding<Color>, supportsOpacity: Bool = true) where S : StringProtocol
/// Creates a color picker with a text label generated from a title string key.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the picker.
///   - selection: A ``Binding`` to the variable that displays the
///     selected ``CGColor``.
///   - supportsOpacity: A Boolean value that indicates whether the color
///     picker allows adjustments to the selected color's opacity; the
///     default is `true`.
public init(_ titleKey: LocalizedStringKey, selection: Binding<CGColor>, supportsOpacity: Bool = true)
/// Creates a color picker with a text label generated from a title string.
///
/// - Parameters:
///   - title: The title displayed by the color picker.
///   - selection: A ``Binding`` to the variable containing a ``CGColor``.
///   - supportsOpacity: A Boolean value that indicates whether the color
///     picker allows adjustments to the selected color's opacity; the
///     default is `true`.
public init<S>(_ title: S, selection: Binding<CGColor>, supportsOpacity: Bool = true) where S : StringProtocol
}
/// The set of possible working color spaces for color-compositing operations.
///
/// Each color space guarantees the preservation of a particular range of color
/// values.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum ColorRenderingMode : Sendable {
/// The non-linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` produce undefined
/// results. This color space is gamma corrected.
case nonLinear
/// The linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` produce undefined
/// results. This color space isn't gamma corrected.
case linear
/// The extended linear sRGB working color space.
///
/// Color component values outside the range `[0, 1]` are preserved.
/// This color space isn't gamma corrected.
case extendedLinear
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ColorRenderingMode, b: ColorRenderingMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorRenderingMode : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorRenderingMode : Hashable {
}
/// The possible color schemes, corresponding to the light and dark appearances.
///
/// You receive a color scheme value when you read the
/// ``EnvironmentValues/colorScheme`` environment value. The value tells you if
/// a light or dark appearance currently applies to the view. SwiftUI updates
/// the value whenever the appearance changes, and redraws views that
/// depend on the value. For example, the following ``Text`` view automatically
/// updates when the user enables Dark Mode:
///
///     @Environment(\.colorScheme) private var colorScheme
///
///     var body: some View {
///         Text(colorScheme == .dark ? "Dark" : "Light")
///     }
///
/// Set a preferred appearance for a particular view hierarchy to override
/// the user's Dark Mode setting using the ``View/preferredColorScheme(_:)``
/// view modifier.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum ColorScheme : CaseIterable, Sendable {
/// The color scheme that corresponds to a light appearance.
case light
/// The color scheme that corresponds to a dark appearance.
case dark
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ColorScheme, b: ColorScheme) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [ColorScheme]
/// A collection of all values of this type.
public static var allCases: [ColorScheme] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
extension ColorScheme {
/// Creates a color scheme from its user interface style equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiUserInterfaceStyle: UIUserInterfaceStyle)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorScheme : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorScheme : Hashable {
}
/// The contrast between the app's foreground and background colors.
///
/// You receive a contrast value when you read the
/// ``EnvironmentValues/colorSchemeContrast`` environment value. The value
/// tells you if a standard or increased contrast currently applies to the view.
/// SwiftUI updates the value whenever the contrast changes, and redraws
/// views that depend on the value. For example, the following ``Text`` view
/// automatically updates when the user enables increased contrast:
///
///     @Environment(\.colorSchemeContrast) private var colorSchemeContrast
///
///     var body: some View {
///         Text(colorSchemeContrast == .standard ? "Standard" : "Increased")
///     }
///
/// The user sets the contrast by selecting the Increase Contrast option in
/// Accessibility > Display in System Preferences on macOS, or
/// Accessibility > Display & Text Size in the Settings app on iOS.
/// Your app can't override the user's choice. For
/// information about using color and contrast in your app, see
/// [Color and Contrast](https://developer.apple.com/design/human-interface-guidelines/accessibility/overview/color-and-contrast).
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum ColorSchemeContrast : CaseIterable, Sendable {
/// SwiftUI displays views with standard contrast between the app's
/// foreground and background colors.
case standard
/// SwiftUI displays views with increased contrast between the app's
/// foreground and background colors.
case increased
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ColorSchemeContrast, b: ColorSchemeContrast) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [ColorSchemeContrast]
/// A collection of all values of this type.
public static var allCases: [ColorSchemeContrast] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
extension ColorSchemeContrast {
/// Creates a contrast from its accessibility contrast equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiAccessibilityContrast: UIAccessibilityContrast)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorSchemeContrast : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ColorSchemeContrast : Hashable {
}
/// A navigation view style represented by a series of views in columns.
///
/// You can also use ``NavigationViewStyle/columns`` to construct this style.
@available(iOS, introduced: 15.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
@available(macOS, introduced: 12.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
public struct ColumnNavigationViewStyle : NavigationViewStyle {
}
/// A non-scrolling form style with a trailing aligned column of labels
/// next to a leading aligned column of values.
///
/// Use the ``FormStyle/columns`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.columns)
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ColumnsFormStyle : FormStyle {
/// A non-scrolling form style with a trailing aligned column of labels
/// next to a leading aligned column of values.
///
/// Don't call this initializer directly. Instead, use the
/// ``FormStyle/columns`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.columns)
///
public init()
/// Creates a view that represents the body of a form.
///
/// - Parameter configuration: The properties of the form.
/// - Returns: A view that has behavior and appearance that enables it
///   to function as a ``Form``.
public func makeBody(configuration: ColumnsFormStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a form.
public typealias Body = some View
}
/// Groups of controls that you can add to existing command menus.
///
/// In macOS, SwiftUI realizes command groups as collections of menu items in a
/// menu bar menu. In iOS, iPadOS, and tvOS, SwiftUI creates key commands for
/// each of a group's commands that has a keyboard shortcut.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct CommandGroup<Content> : Commands where Content : View {
/// A value describing the addition of the given views to the beginning of
/// the indicated group.
public init(before group: CommandGroupPlacement, @ViewBuilder addition: () -> Content)
/// A value describing the addition of the given views to the end of the
/// indicated group.
public init(after group: CommandGroupPlacement, @ViewBuilder addition: () -> Content)
/// A value describing the complete replacement of the contents of the
/// indicated group with the given views.
public init(replacing group: CommandGroupPlacement, @ViewBuilder addition: () -> Content)
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// The standard locations that you can place new command groups relative to.
///
/// The names of these placements aren't visible in the user interface, but
/// the discussion for each placement lists the items that it includes.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct CommandGroupPlacement {
/// Placement for commands that provide information about the app,
/// the terms of the user's license agreement, and so on.
///
/// By default, this group includes the following command in macOS:
/// * About App
public static let appInfo: CommandGroupPlacement
/// Placement for commands that expose app settings and
/// preferences.
///
/// By default, this group includes the following command in macOS:
/// * Preferences
public static let appSettings: CommandGroupPlacement
/// Placement for commands that expose services other apps provide.
///
/// By default, this group includes the following command in macOS:
/// * Services submenu (managed automatically)
public static let systemServices: CommandGroupPlacement
/// Placement for commands that control the visibility of running
/// apps.
///
/// By default, this group includes the following commands in macOS:
/// * Hide App
/// * Hide Others
/// * Show All
public static let appVisibility: CommandGroupPlacement
/// Placement for commands that result in app termination.
///
/// By default, this group includes the following command in macOS:
/// * Quit App
public static let appTermination: CommandGroupPlacement
/// Placement for commands that create and open different kinds of
/// documents.
///
/// By default, this group includes the following commands in macOS:
/// * New
/// * Open
/// * Open Recent submenu (managed automatically)
public static let newItem: CommandGroupPlacement
/// Placement for commands that save open documents and close
/// windows.
///
/// By default, this group includes the following commands in macOS:
/// * Close
/// * Save
/// * Save As/Duplicate
/// * Revert to Saved
public static let saveItem: CommandGroupPlacement
/// Placement for commands that relate to importing and exporting
/// data using formats that the app doesn't natively support.
///
/// Empty by default in macOS.
public static let importExport: CommandGroupPlacement
/// Placement for commands related to printing app content.
///
/// By default, this group includes the following commands in macOS:
/// * Page Setup
/// * Print
public static let printItem: CommandGroupPlacement
/// Placement for commands that control the Undo Manager.
///
/// By default, this group includes the following commands in macOS:
/// * Undo
/// * Redo
public static let undoRedo: CommandGroupPlacement
/// Placement for commands that interact with the Clipboard and
/// manipulate content that is currently selected in the app's view
/// hierarchy.
///
/// By default, this group includes the following commands in macOS:
/// * Cut
/// * Copy
/// * Paste
/// * Paste and Match Style
/// * Delete
/// * Select All
public static let pasteboard: CommandGroupPlacement
/// Placement for commands that manipulate and transform text
/// selections.
///
/// By default, this group includes the following commands in macOS:
/// * Find submenu
/// * Spelling and Grammar submenu
/// * Substitutions submenu
/// * Transformations submenu
/// * Speech submenu
public static let textEditing: CommandGroupPlacement
/// Placement for commands that manipulate and transform the styles
/// applied to text selections.
///
/// By default, this group includes the following commands in macOS:
/// * Font submenu
/// * Text submenu
public static let textFormatting: CommandGroupPlacement
/// Placement for commands that manipulate the toolbar.
///
/// By default, this group includes the following commands in macOS:
/// * Show/Hide Toolbar
/// * Customize Toolbar
public static let toolbar: CommandGroupPlacement
/// Placement for commands that control the app's sidebar and full-screen
/// modes.
///
/// By default, this group includes the following commands in macOS:
/// * Show/Hide Sidebar
/// * Enter/Exit Full Screen
public static let sidebar: CommandGroupPlacement
/// Placement for commands that control the size of the window.
///
/// By default, this group includes the following commands in macOS:
/// * Minimize
/// * Zoom
public static let windowSize: CommandGroupPlacement
/// Placement for commands that arrange all of an app's windows.
///
/// By default, this group includes the following command in macOS:
/// * Bring All to Front
public static let windowArrangement: CommandGroupPlacement
/// Placement for commands that present documentation and helpful
/// information to people.
///
/// By default, this group includes the following command in macOS:
/// * App Help
public static let help: CommandGroupPlacement
}
/// Command menus are stand-alone, top-level containers for controls that
/// perform related, app-specific commands.
///
/// Command menus are realized as menu bar menus on macOS, inserted between the
/// built-in View and Window menus in order of declaration. On iOS, iPadOS, and
/// tvOS, SwiftUI creates key commands for each of a menu's commands that has a
/// keyboard shortcut.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct CommandMenu<Content> : Commands where Content : View {
/// Creates a new menu with a localized name for a collection of app-
/// specific commands, inserted in the standard location for app menus
/// (after the View menu, in order with other menus declared without an
/// explicit location).
public init(_ nameKey: LocalizedStringKey, @ViewBuilder content: () -> Content)
/// Creates a new menu for a collection of app-specific commands, inserted
/// in the standard location for app menus (after the View menu, in order
/// with other menus declared without an explicit location).
public init(_ name: Text, @ViewBuilder content: () -> Content)
/// Creates a new menu for a collection of app-specific commands, inserted
/// in the standard location for app menus (after the View menu, in order
/// with other menus declared without an explicit location).
public init<S>(_ name: S, @ViewBuilder content: () -> Content) where S : StringProtocol
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// Conforming types represent a group of related commands that can be exposed
/// to the user via the main menu on macOS and key commands on iOS.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol Commands {
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
associatedtype Body : Commands
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
@CommandsBuilder var body: Self.Body { get }
}
/// Constructs command sets from multi-expression closures. Like `ViewBuilder`,
/// it supports up to ten expressions in the closure body.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@resultBuilder public struct CommandsBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : Commands
/// Builds an empty command set from a block containing no statements.
public static func buildBlock() -> EmptyCommands
/// Passes a single command group written as a child group through
/// modified.
public static func buildBlock<C>(_ content: C) -> C where C : Commands
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
/// Provides support for "if" statements in multi-statement closures,
/// producing an optional value that is visible only when the condition
/// evaluates to `true`.
public static func buildIf<C>(_ content: C?) -> C? where C : Commands
/// Provides support for "if" statements in multi-statement closures,
/// producing conditional content for the "then" branch.
public static func buildEither<T, F>(first: T) -> _ConditionalContent<T, F> where T : Commands, F : Commands
/// Provides support for "if-else" statements in multi-statement closures,
/// producing conditional content for the "else" branch.
public static func buildEither<T, F>(second: F) -> _ConditionalContent<T, F> where T : Commands, F : Commands
/// Provides support for "if" statements with `#available()` clauses in
/// multi-statement closures, producing conditional content for the "then"
/// branch, i.e. the conditionally-available branch.
public static func buildLimitedAvailability<C>(_ content: C) -> some Commands where C : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Commands where C0 : Commands, C1 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands, C5 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands, C5 : Commands, C6 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands, C5 : Commands, C6 : Commands, C7 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands, C5 : Commands, C6 : Commands, C7 : Commands, C8 : Commands
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension CommandsBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some Commands where C0 : Commands, C1 : Commands, C2 : Commands, C3 : Commands, C4 : Commands, C5 : Commands, C6 : Commands, C7 : Commands, C8 : Commands, C9 : Commands
}
/// A date picker style that displays the components in a compact, textual
/// format.
///
/// You can also use ``DatePickerStyle/compact`` to construct this style.
@available(iOS 14.0, macCatalyst 13.4, macOS 10.15.4, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct CompactDatePickerStyle : DatePickerStyle {
/// Creates an instance of the compact date picker style.
public init()
/// Returns the appearance and interaction content for a `DatePicker`.
///
/// The system calls this method for each ``DatePicker`` instance in a view
/// hierarchy where this style is the current date picker style.
///
/// - Parameter configuration : The properties of the date picker.
@available(iOS 16.0, macOS 13.0, *)
public func makeBody(configuration: CompactDatePickerStyle.Configuration) -> some View
/// A view representing the appearance and interaction of a `DatePicker`.
public typealias Body = some View
}
/// A control group style that presents its content as a compact menu when the user
/// presses the control, or as a submenu when nested within a larger menu.
///
/// Use ``ControlGroupStyle/compactMenu`` to construct this style.
@available(iOS 16.4, macOS 13.3, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct CompactMenuControlGroupStyle : ControlGroupStyle {
/// Creates a compact menu control group style.
public init()
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@MainActor public func makeBody(configuration: CompactMenuControlGroupStyle.Configuration) -> some View
/// A view representing the body of a control group.
public typealias Body = some View
}
/// The placement of a container background.
///
/// This method controls where to place a background that you specify with the
/// ``View/containerBackground(_:for:)`` or
/// ``View/containerBackground(for:alignment:content:)`` modifier.
@available(iOS 17.0, tvOS 17.0, macOS 14.0, watchOS 10.0, *)
public struct ContainerBackgroundPlacement : Sendable, Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ContainerBackgroundPlacement, b: ContainerBackgroundPlacement) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A shape that is replaced by an inset version of the current
/// container shape. If no container shape was defined, is replaced by
/// a rectangle.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public struct ContainerRelativeShape : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
@inlinable public init()
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ContainerRelativeShape : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// The placement of margins.
///
/// Different views can support customizating margins that appear in
/// different parts of that view. Use values of this type to customize
/// those margins of a particular placement.
///
/// For example, use a ``ContentMarginPlacement/scrollIndicators``
/// placement to customize the margins of scrollable view's scroll
/// indicators separately from the margins of a scrollable view's
/// content.
///
/// Use this type with the ``View/contentMargins(_:for:)`` modifier.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ContentMarginPlacement {
/// The automatic placement.
///
/// Views that support margin customization can automatically use
/// margins with this placement. For example, a ``ScrollView`` will
/// use this placement to automatically inset both its content and
/// scroll indicators by the specified amount.
public static var automatic: ContentMarginPlacement { get }
/// The scroll content placement.
///
/// Scrollable views like ``ScrollView`` will use this placement to
/// inset their content, but not their scroll indicators.
public static var scrollContent: ContentMarginPlacement { get }
/// The scroll indicators placement.
///
/// Scrollable views like ``ScrollView`` will use this placement to
/// inset their scroll indicators, but not their content.
public static var scrollIndicators: ContentMarginPlacement { get }
}
/// Constants that define how a view's content fills the available space.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public enum ContentMode : Hashable, CaseIterable {
/// An option that resizes the content so it's all within the available space,
/// both vertically and horizontally.
///
/// This mode preserves the content's aspect ratio.
/// If the content doesn't have the same aspect ratio as the available
/// space, the content becomes the same size as the available space on
/// one axis and leaves empty space on the other.
case fit
/// An option that resizes the content so it occupies all available space,
/// both vertically and horizontally.
///
/// This mode preserves the content's aspect ratio.
/// If the content doesn't have the same aspect ratio as the available
/// space, the content becomes the same size as the available space on
/// one axis, and larger on the other axis.
case fill
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ContentMode, b: ContentMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [ContentMode]
/// A collection of all values of this type.
public static var allCases: [ContentMode] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ContentMode : Sendable {
}
/// A kind for the content shape of a view.
///
/// The kind is used by the system to influence various effects, hit-testing,
/// and more.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct ContentShapeKinds : OptionSet, Sendable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int
/// Creates a content shape kind.
public init(rawValue: Int)
/// The kind for hit-testing and accessibility.
///
/// Setting a content shape with this kind causes the view to hit-test
/// using the specified shape.
public static let interaction: ContentShapeKinds
/// The kind for drag and drop previews.
///
/// When using this kind, only the preview shape is affected. To control the
/// shape used to hit-test and start the drag preview, use the `interaction`
/// kind.
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static let dragPreview: ContentShapeKinds
/// The kind for context menu previews.
///
/// When using this kind, only the preview shape will be affected. To
/// control the shape used to hit-test and start the context menu
/// presentation, use the `.interaction` kind.
@available(tvOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public static let contextMenuPreview: ContentShapeKinds
/// The kind for hover effects.
///
/// When using this kind, only the preview shape is affected. To control
/// the shape used to hit-test and start the effect, use the `interaction`
/// kind.
///
/// This kind does not affect the `onHover` modifier.
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static let hoverEffect: ContentShapeKinds
/// The kind for accessibility visuals and sorting.
///
/// Setting a content shape with this kind causes the accessibility frame
/// and path of the view's underlying accessibility element to match the
/// shape without adjusting the hit-testing shape, updating the visual focus
/// ring that assistive apps, such as VoiceOver, draw, as well as how the
/// element is sorted. Updating the accessibility shape is only required if
/// the shape or size used to hit-test significantly diverges from the visual
/// shape of the view.
///
/// To control the shape for accessibility and hit-testing, use the `interaction` kind.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static let accessibility: ContentShapeKinds
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = ContentShapeKinds
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = ContentShapeKinds
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "DynamicTypeSize")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "DynamicTypeSize")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "DynamicTypeSize")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "DynamicTypeSize")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "DynamicTypeSize")
public enum ContentSizeCategory : Hashable, CaseIterable {
case extraSmall
case small
case medium
case large
case extraLarge
case extraExtraLarge
case extraExtraExtraLarge
case accessibilityMedium
case accessibilityLarge
case accessibilityExtraLarge
case accessibilityExtraExtraLarge
case accessibilityExtraExtraExtraLarge
/// A Boolean value indicating whether the content size category is one that
/// is associated with accessibility.
@available(iOS 13.4, macOS 10.15.4, tvOS 13.4, watchOS 6.2, *)
public var isAccessibilityCategory: Bool { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ContentSizeCategory, b: ContentSizeCategory) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [ContentSizeCategory]
/// A collection of all values of this type.
public static var allCases: [ContentSizeCategory] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ContentSizeCategory {
/// Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
public static func < (lhs: ContentSizeCategory, rhs: ContentSizeCategory) -> Bool
/// Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
public static func <= (lhs: ContentSizeCategory, rhs: ContentSizeCategory) -> Bool
/// Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
public static func > (lhs: ContentSizeCategory, rhs: ContentSizeCategory) -> Bool
/// Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
public static func >= (lhs: ContentSizeCategory, rhs: ContentSizeCategory) -> Bool
}
extension ContentSizeCategory {
/// Create a size category from its UIContentSizeCategory equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiSizeCategory: UIContentSizeCategory)
}
/// A kind of transition that applies to the content within a single view,
/// rather than to the insertion or removal of a view.
///
/// Set the behavior of content transitions within a view with the
/// ``View/contentTransition(_:)`` modifier, passing in one of the defined
/// transitions, such as ``opacity`` or ``interpolate`` as the parameter.
///
/// > Tip: Content transitions only take effect within transactions that apply
/// an ``Animation`` to the views inside the ``View/contentTransition(_:)``
/// modifier.
///
/// Content transitions only take effect within the context of an
/// ``Animation`` block.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ContentTransition : Equatable, Sendable {
/// The identity content transition, which indicates that content changes
/// shouldn't animate.
///
/// You can pass this value to a ``View/contentTransition(_:)``
/// modifier to selectively disable animations that would otherwise
/// be applied by a ``withAnimation(_:_:)`` block.
public static let identity: ContentTransition
/// A content transition that indicates content fades from transparent
/// to opaque on insertion, and from opaque to transparent on removal.
public static let opacity: ContentTransition
/// A content transition that indicates the views attempt to interpolate
/// their contents during transitions, where appropriate.
///
/// Text views can interpolate transitions when the text views have
/// identical strings. Matching glyph pairs can animate changes to their
/// color, position, size, and any variable properties. Interpolation can
/// apply within a ``Font/Design`` case, but not between cases, or between
/// entirely different fonts. For example, you can interpolate a change
/// between ``Font/Weight/thin`` and ``Font/Weight/black`` variations of a
/// font, since these are both cases of ``Font/Weight``. However, you can't
/// interpolate between the default design of a font and its Italic version,
/// because these are different fonts. Any changes that can't show an
/// interpolated animation use an opacity animation instead.
///
/// Symbol images created with the ``Image/init(systemName:)`` initializer
/// work the same way as text: changes within the same symbol attempt to
/// interpolate the symbol's paths. When interpolation is unavailable, the
/// system uses an opacity transition instead.
public static let interpolate: ContentTransition
/// Creates a content transition intended to be used with `Text`
/// views displaying numeric text. In certain environments changes
/// to the text will enable a nonstandard transition tailored to
/// numeric characters that count up or down.
///
/// - Parameters:
///   - countsDown: true if the numbers represented by the text
///     are counting downwards.
///
/// - Returns: a new content transition.
public static func numericText(countsDown: Bool = false) -> ContentTransition
/// Creates a content transition intended to be used with `Text`
/// views displaying numbers.
///
/// The example below creates a text view displaying a particular
/// value, assigning the same value to the associated transition:
///
///     Text("\(value)")
///         .contentTransition(.numericText(value: value))
///
/// - Parameters:
///   - value: the value represented by the `Text` view being
///     animated. The difference between the old and new values
///     when the text changes will be used to determine the
///     animation direction.
///
/// - Returns: a new content transition.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static func numericText(value: Double) -> ContentTransition
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ContentTransition, b: ContentTransition) -> Bool
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ContentTransition {
/// Creates a content transition that applies the symbol Replace
/// animation to symbol images that it is applied to.
///
/// - Parameter config: the animation configuration value.
///
/// - Returns: a new content transition.
public static func symbolEffect<T>(_ effect: T, options: SymbolEffectOptions = .default) -> ContentTransition where T : ContentTransitionSymbolEffect, T : SymbolEffect
/// A content transition that applies the default symbol effect
/// transition to symbol images within the inserted or removed view
/// hierarchy. Other views are unaffected by this transition.
public static var symbolEffect: ContentTransition { get }
}
/// An interface, consisting of a label and additional content, that you
/// display when the content of your app is unavailable to users.
///
/// It is recommended to use `ContentUnavailableView` in situations where a view's
/// content cannot be displayed. That could be caused by a network error, a
/// list without items, a search that returns no results etc.
///
/// You create an `ContentUnavailableView` in its simplest form, by providing a
/// label and some additional content such as a description or a call to action:
///
///     ContentUnavailableView {
///         Label("No Mail", systemImage: "tray.fill")
///     } description: {
///         Text("New mails you receive will appear here.")
///     }
///
/// The system provides default `ContentUnavailableView`s that you can use in
/// specific situations. The example below illustrates the usage of the
/// ``ContentUnavailableView/search`` view:
///
///     struct ContentView: View {
///         @ObservedObject private var viewModel = ContactsViewModel()
///
///         var body: some View {
///             NavigationStack {
///                 List {
///                     ForEach(viewModel.searchResults) { contact in
///                         NavigationLink {
///                             ContactsView(contact)
///                         } label: {
///                             Text(contact.name)
///                         }
///                     }
///                 }
///                 .navigationTitle("Contacts")
///                 .searchable(text: $viewModel.searchText)
///                 .overlay {
///                     if searchResults.isEmpty {
///                         ContentUnavailableView.search
///                     }
///                 }
///             }
///         }
///     }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ContentUnavailableView<Label, Description, Actions> : View where Label : View, Description : View, Actions : View {
/// Creates an interface, consisting of a label and additional content, that you
/// display when the content of your app is unavailable to users.
///
/// - Parameters:
///   - label: The label that describes the view.
///   - description: The view that describes the interface.
///   - actions: The content of the interface actions.
public init(@ViewBuilder label: () -> Label, @ViewBuilder description: () -> Description = { EmptyView() }, @ViewBuilder actions: () -> Actions = { EmptyView() })
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ContentUnavailableView where Label == Label<Text, Image>, Description == Text?, Actions == EmptyView {
/// Creates an interface, consisting of a title generated from a localized
/// string, an image and additional content, that you display when the
/// content of your app is unavailable to users.
///
/// - Parameters:
///    - title: A title generated from a localized string.
///    - image: The name of the image resource to lookup.
///    - description: The view that describes the interface.
public init(_ title: LocalizedStringKey, image name: String, description: Text? = nil)
/// Creates an interface, consisting of a title generated from a localized
/// string, a system icon image and additional content, that you display when the
/// content of your app is unavailable to users.
///
/// - Parameters:
///    - title: A title generated from a localized string.
///    - systemImage: The name of the system symbol image resource to lookup.
///      Use the SF Symbols app to look up the names of system symbol images.
///    - description: The view that describes the interface.
public init(_ title: LocalizedStringKey, systemImage name: String, description: Text? = nil)
/// Creates an interface, consisting of a title generated from a string,
/// an image and additional content, that you display when the content of
/// your app is unavailable to users.
///
/// - Parameters:
///    - title: A string used as the title.
///    - image: The name of the image resource to lookup.
///    - description: The view that describes the interface.
public init<S>(_ title: S, image name: String, description: Text? = nil) where S : StringProtocol
/// Creates an interface, consisting of a title generated from a string,
/// a system icon image and additional content, that you display when the
/// content of your app is unavailable to users.
///
/// - Parameters:
///    - title: A string used as the title.
///    - systemImage: The name of the system symbol image resource to lookup.
///      Use the SF Symbols app to look up the names of system symbol images.
///    - description: The view that describes the interface.
public init<S>(_ title: S, systemImage name: String, description: Text? = nil) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ContentUnavailableView where Label == SearchUnavailableContent.Label, Description == SearchUnavailableContent.Description, Actions == SearchUnavailableContent.Actions {
/// Creates a `ContentUnavailableView` instance that conveys a search state.
///
/// A `ContentUnavailableView` initialized with this static member is expected to
/// be contained within a searchable view hierarchy. Such a configuration
/// enables the search query to be parsed into the view's description.
///
/// For example, consider the usage of this static member in *ContactsListView*:
///
///     struct ContactsListView: View {
///         @ObservedObject private var viewModel = ContactsViewModel()
///
///         var body: some View {
///             NavigationStack {
///                 List {
///                     ForEach(viewModel.searchResults) { contact in
///                         NavigationLink {
///                             ContactsView(contact)
///                         } label: {
///                             Text(contact.name)
///                         }
///                     }
///                 }
///                 .navigationTitle("Contacts")
///                 .searchable(text: $viewModel.searchText)
///                 .overlay {
///                     if searchResults.isEmpty {
///                         ContentUnavailableView.search
///                     }
///                 }
///             }
///         }
///     }
///
public static var search: ContentUnavailableView<SearchUnavailableContent.Label, SearchUnavailableContent.Description, SearchUnavailableContent.Actions> { get }
/// Creates a `ContentUnavailableView` instance that conveys a search state.
///
/// For example, consider the usage of this static member in *ContactsListView*:
///
///     struct ContactsListView: View {
///         @ObservedObject private var viewModel = ContactsViewModel()
///
///         var body: some View {
///             NavigationStack {
///                 CustomSearchBar(query: $viewModel.searchText)
///                 List {
///                     ForEach(viewModel.searchResults) { contact in
///                         NavigationLink {
///                             ContactsView(contact)
///                         } label: {
///                             Text(contact.name)
///                         }
///                     }
///                 }
///                 .navigationTitle("Contacts")
///                 .overlay {
///                     if viewModel.searchResults.isEmpty {
///                         ContentUnavailableView
///                             .search(text: viewModel.searchText)
///                     }
///                 }
///             }
///         }
///     }
///
/// - Parameter text: The search text query.
public static func search(text: String) -> ContentUnavailableView<Label, Description, Actions>
}
/// A container for views that you present as menu items in a context menu.
///
/// A context menu view allows you to present a situationally specific menu
/// that enables taking actions relevant to the current task.
///
/// You can create a context menu by first defining a `ContextMenu` container
/// with the controls that represent the actions that people can take,
/// and then using the ``View/contextMenu(_:)`` view modifier to apply the
/// menu to a view.
///
/// The example below creates and applies a two item context menu container
/// to a ``Text`` view. The Boolean value `shouldShowMenu`, which defaults to
/// true, controls the availability of context menu:
///
///     private let menuItems = ContextMenu {
///         Button {
///             // Add this item to a list of favorites.
///         } label: {
///             Label("Add to Favorites", systemImage: "heart")
///         }
///         Button {
///             // Open Maps and center it on this item.
///         } label: {
///             Label("Show in Maps", systemImage: "mappin")
///         }
///     }
///
///     private struct ContextMenuMenuItems: View {
///         @State private var shouldShowMenu = true
///
///         var body: some View {
///             Text("Turtle Rock")
///                 .contextMenu(shouldShowMenu ? menuItems : nil)
///         }
///     }
///
/// ![A screenshot of a context menu showing two menu items: Add to
/// Favorites, and Show in Maps.](View-contextMenu-1-iOS)
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
@available(tvOS, unavailable)
@available(watchOS, introduced: 6.0, deprecated: 7.0)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
public struct ContextMenu<MenuItems> where MenuItems : View {
public init(@ViewBuilder menuItems: () -> MenuItems)
}
/// A container view that displays semantically-related controls
/// in a visually-appropriate manner for the context
///
/// You can provide an optional label to this view that describes its children.
/// This view may be used in different ways depending on the surrounding
/// context. For example, when you place the control group in a
/// toolbar item, SwiftUI uses the label when the group is moved to the
/// toolbar's overflow menu.
///
///     ContentView()
///         .toolbar(id: "items") {
///             ToolbarItem(id: "media") {
///                 ControlGroup {
///                     MediaButton()
///                     ChartButton()
///                     GraphButton()
///                 } label: {
///                     Label("Plus", systemImage: "plus")
///                 }
///             }
///         }
///
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct ControlGroup<Content> : View where Content : View {
/// Creates a new ControlGroup with the specified children
///
/// - Parameters:
///   - content: the children to display
public init(@ViewBuilder content: () -> Content)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroup where Content == ControlGroupStyleConfiguration.Content {
/// Creates a control group based on a style configuration.
///
/// Use this initializer within the
/// ``ControlGroupStyle/makeBody(configuration:)`` method of a
/// ``ControlGroupStyle`` instance to create an instance of the control group
/// being styled. This is useful for custom control group styles that modify
/// the current control group style.
///
/// For example, the following code creates a new, custom style that places a
/// red border around the current control group:
///
///     struct RedBorderControlGroupStyle: ControlGroupStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             ControlGroup(configuration)
///                 .border(Color.red)
///         }
///     }
///
public init(_ configuration: ControlGroupStyleConfiguration)
}
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroup {
/// Creates a new control group with the specified content and a label.
///
/// - Parameters:
///   - content: The content to display.
///   - label: A view that describes the purpose of the group.
public init<C, L>(@ViewBuilder content: () -> C, @ViewBuilder label: () -> L) where Content == LabeledControlGroupContent<C, L>, C : View, L : View
}
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroup {
/// Creates a new control group with the specified content that generates
/// its label from a localized string key.
///
/// - Parameters:
///   - titleKey: The key for the group's localized title, that describes
///     the contents of the group.
///   - label: A view that describes the purpose of the group.
public init<C>(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Text>, C : View
/// Creates a new control group with the specified content that generates
/// its label from a string.
///
/// - Parameters:
///   - title: A string that describes the contents of the group.
///   - label: A view that describes the purpose of the group.
public init<C, S>(_ title: S, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Text>, C : View, S : StringProtocol
}
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroup {
/// Creates a new control group with the specified content that generates
/// its label from a localized string key and image name.
///
/// - Parameters:
///   - titleKey: The key for the group's localized title, that describes
///     the contents of the group.
///   - systemImage: The name of the image resource to lookup.
///   - label: A view that describes the purpose of the group.
public init<C>(_ titleKey: LocalizedStringKey, systemImage: String, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Label<Text, Image>>, C : View
/// Creates a new control group with the specified content that generates
/// its label from a string and image name.
///
/// - Parameters:
///   - title: A string that describes the contents of the group.
///   - systemImage: The name of the image resource to lookup.
///   - label: A view that describes the purpose of the group.
public init<C, S>(_ title: S, systemImage: String, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Label<Text, Image>>, C : View, S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroup {
/// Creates a new control group with the specified content that generates
/// its label from a localized string key and image resource.
///
/// - Parameters:
///   - titleKey: The key for the group's localized title, that describes
///     the contents of the group.
///   - systemImage: The name of the image resource to lookup.
///   - label: A view that describes the purpose of the group.
public init<C>(_ titleKey: LocalizedStringKey, image: ImageResource, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Label<Text, Image>>, C : View
/// Creates a new control group with the specified content that generates
/// its label from a string and image name.
///
/// - Parameters:
///   - title: A string that describes the contents of the group.
///   - systemImage: The name of the image resource to lookup.
///   - label: A view that describes the purpose of the group.
public init<C, S>(_ title: S, image: ImageResource, @ViewBuilder content: () -> C) where Content == LabeledControlGroupContent<C, Label<Text, Image>>, C : View, S : StringProtocol
}
/// Defines the implementation of all control groups within a view
/// hierarchy.
///
/// To configure the current `ControlGroupStyle` for a view hierarchy, use the
/// ``View/controlGroupStyle(_:)`` modifier.
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public protocol ControlGroupStyle {
/// A view representing the body of a control group.
associatedtype Body : View
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@ViewBuilder @MainActor func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a `ControlGroup` instance being created.
typealias Configuration = ControlGroupStyleConfiguration
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ControlGroupStyle where Self == PaletteControlGroupStyle {
/// A control group style that presents its content as a palette.
///
/// - Note: When used outside of menus, this style is rendered as a
/// segmented control.
///
/// Use this style to render a multi-select or a stateless palette.
/// The following example creates a control group that contains both type of shelves:
///
///     Menu {
///         // A multi select palette
///         ControlGroup {
///             ForEach(ColorTags.allCases) { colorTag in
///                 Toggle(isOn: $selectedColorTags[colorTag]) {
///                     Label(colorTag.name, systemImage: "circle")
///                 }
///                 .tint(colorTag.color)
///             }
///         }
///         .controlGroupStyle(.palette)
///         .paletteSelectionEffect(.symbolVariant(.fill))
///
///         // A momentary / stateless palette
///         ControlGroup {
///             ForEach(Emotes.allCases) { emote in
///                 Button {
///                     sendEmote(emote)
///                 } label: {
///                     Label(emote.name, systemImage: emote.systemImage)
///                 }
///             }
///         }
///         .controlGroupStyle(.palette)
///     }
///
/// To apply this style to a control group, or to a view that contains
/// control groups, use the ``View/controlGroupStyle(_:)`` modifier.
public static var palette: PaletteControlGroupStyle { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroupStyle where Self == AutomaticControlGroupStyle {
/// The default control group style.
///
/// The default control group style can vary by platform. By default, both
/// platforms use a momentary segmented control style that's appropriate for
/// the environment in which it is rendered.
///
/// You can override a control group's style. To apply the default style to
/// a control group or to a view that contains a control group, use
/// the ``View/controlGroupStyle(_:)`` modifier.
public static var automatic: AutomaticControlGroupStyle { get }
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ControlGroupStyle where Self == NavigationControlGroupStyle {
/// The navigation control group style.
///
/// Use this style to group controls related to navigation, such as
/// back/forward buttons or timeline navigation controls.
///
/// The navigation control group style can vary by platform. On iOS, it
/// renders as individual borderless buttons, while on macOS, it displays as
/// a separated momentary segmented control.
///
/// To apply this style to a control group or to a view that contains a
/// control group, use the ``View/controlGroupStyle(_:)`` modifier.
public static var navigation: NavigationControlGroupStyle { get }
}
@available(iOS 16.4, macOS 13.3, tvOS 17.0, *)
@available(watchOS, unavailable)
extension ControlGroupStyle where Self == MenuControlGroupStyle {
/// A control group style that presents its content as a menu when the user
/// presses the control, or as a submenu when nested within a larger menu.
///
/// To apply this style to a control group, or to a view that contains
/// control groups, use the ``View/controlGroupStyle(_:)`` modifier.
public static var menu: MenuControlGroupStyle { get }
}
@available(iOS 16.4, macOS 13.3, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ControlGroupStyle where Self == CompactMenuControlGroupStyle {
/// A control group style that presents its content as a compact menu when the user
/// presses the control, or as a submenu when nested within a larger menu.
///
/// To apply this style to a control group, or to a view that contains
/// control groups, use the ``View/controlGroupStyle(_:)`` modifier.
public static var compactMenu: CompactMenuControlGroupStyle { get }
}
/// The properties of a control group.
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct ControlGroupStyleConfiguration {
/// A type-erased content of a `ControlGroup`.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that represents the content of the `ControlGroup`.
public let content: ControlGroupStyleConfiguration.Content
/// A type-erased label of a ``ControlGroup``.
@available(iOS 16.0, macOS 13.0, *)
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that provides the optional label of the ``ControlGroup``.
@available(iOS 16.0, macOS 13.0, *)
public let label: ControlGroupStyleConfiguration.Label
}
/// The size classes, like regular or small, that you can apply to controls
/// within a view.
@available(iOS 15.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
public enum ControlSize : CaseIterable, Sendable {
/// A control version that is minimally sized.
case mini
/// A control version that is proportionally smaller size for space-constrained views.
case small
/// A control version that is the default size.
case regular
/// A control version that is prominently sized.
@available(macOS 11.0, *)
case large
@available(iOS 17.0, macOS 14.0, watchOS 10.0, visionOS 1.0, *)
case extraLarge
/// A collection of all values of this type.
public static var allCases: [ControlSize] { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ControlSize, b: ControlSize) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [ControlSize]
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ControlSize : Equatable {
}
@available(iOS 15.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ControlSize : Hashable {
}
/// A resolved coordinate space created by `CoordinateSpaceProtocol`.
///
/// You don't typically use `CoordinateSpace` directly. Instead, use the static
/// properties and functions of `CoordinateSpaceProtocol` such as `.global`,
/// `.local`, and `.named(_:)`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum CoordinateSpace {
/// The global coordinate space at the root of the view hierarchy.
case global
/// The local coordinate space of the current view.
case local
/// A named reference to a view's local coordinate space.
case named(AnyHashable)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CoordinateSpace {
public var isGlobal: Bool { get }
public var isLocal: Bool { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CoordinateSpace : Equatable, Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: CoordinateSpace, rhs: CoordinateSpace) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A frame of reference within the layout system.
///
/// All geometric properties of a view, including size, position, and
/// transform, are defined within the local coordinate space of the view's
/// parent. These values can be converted into other coordinate spaces
/// by passing types conforming to this protocol into functions such as
/// `GeometryProxy.frame(in:)`.
///
/// For example, a named coordinate space allows you to convert the frame
/// of a view into the local coordinate space of an ancestor view by defining
/// a named coordinate space using the `coordinateSpace(_:)` modifier, then
/// passing that same named coordinate space into the `frame(in:)` function.
///
///     VStack {
///         GeometryReader { geometryProxy in
///             let distanceFromTop = geometryProxy.frame(in: "container").origin.y
///             Text("This view is \(distanceFromTop) points from the top of the VStack")
///         }
///         .padding()
///     }
///     .coordinateSpace(.named("container"))
///
/// You don't typically create types conforming to this protocol yourself.
/// Instead, use the system-provided `.global`, `.local`, and `.named(_:)`
/// implementations.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol CoordinateSpaceProtocol {
/// The resolved coordinate space.
var coordinateSpace: CoordinateSpace { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CoordinateSpaceProtocol where Self == NamedCoordinateSpace {
/// The named coordinate space that is added by the system for the innermost
/// containing scroll view that allows scrolling along the provided axis.
public static func scrollView(axis: Axis) -> Self
/// The named coordinate space that is added by the system for the innermost
/// containing scroll view.
public static var scrollView: NamedCoordinateSpace { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CoordinateSpaceProtocol where Self == NamedCoordinateSpace {
/// Creates a named coordinate space using the given value.
///
/// Use the `coordinateSpace(_:)` modifier to assign a name to the local
/// coordinate space of a  parent view. Child views can then refer to that
/// coordinate space using `.named(_:)`.
///
/// - Parameter name: A unique value that identifies the coordinate space.
///
/// - Returns: A named coordinate space identified by the given value.
public static func named(_ name: some Hashable) -> NamedCoordinateSpace
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CoordinateSpaceProtocol where Self == LocalCoordinateSpace {
/// The local coordinate space of the current view.
public static var local: LocalCoordinateSpace { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CoordinateSpaceProtocol where Self == GlobalCoordinateSpace {
/// The global coordinate space at the root of the view hierarchy.
public static var global: GlobalCoordinateSpace { get }
}
/// A keyframe that uses a cubic curve to smoothly interpolate between values.
///
/// If you don't specify a start or end velocity, SwiftUI automatically
/// computes a curve that maintains smooth motion between keyframes.
///
/// Adjacent cubic keyframes result in a Catmull-Rom spline.
///
/// If a cubic keyframe follows a different type of keyframe, such as a linear
/// keyframe, the end velocity of the segment defined by the previous keyframe
/// will be used as the starting velocity.
///
/// Likewise, if a cubic keyframe is followed by a different type of keyframe,
/// the initial velocity of the next segment is used as the end velocity of the
/// segment defined by this keyframe.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct CubicKeyframe<Value> : KeyframeTrackContent where Value : Animatable {
/// Creates a new keyframe using the given value and timestamp.
///
/// - Parameters:
///   - to: The value of the keyframe.
///   - startVelocity: The velocity of the value at the beginning of the
///     segment, or `nil` to automatically compute the velocity to maintain
///     smooth motion.
///   - endVelocity: The velocity of the value at the end of the segment,
///     or `nil` to automatically compute the velocity to maintain smooth
///     motion.
///   - duration: The duration of the segment defined by this keyframe.
public init(_ to: Value, duration: TimeInterval, startVelocity: Value? = nil, endVelocity: Value? = nil)
public typealias Body = CubicKeyframe<Value>
}
/// A type that defines how an animatable value changes over time.
///
/// Use this protocol to create a type that changes an animatable value over
/// time, which produces a custom visual transition of a view. For example, the
/// follow code changes an animatable value using an elastic ease-in ease-out
/// function:
///
///     struct ElasticEaseInEaseOutAnimation: CustomAnimation {
///         let duration: TimeInterval
///
///         func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic {
///             if time > duration { return nil } // The animation has finished.
///
///             let p = time / duration
///             let s = sin((20 * p - 11.125) * ((2 * Double.pi) / 4.5))
///             if p < 0.5 {
///                 return value.scaled(by: -(pow(2, 20 * p - 10) * s) / 2)
///             } else {
///                 return value.scaled(by: (pow(2, -20 * p + 10) * s) / 2 + 1)
///             }
///         }
///     }
///
/// > Note: To maintain state during the life span of a custom animation, use
/// the ``AnimationContext/state`` property available on the `context`
/// parameter value. You can also use context's
/// ``AnimationContext/environment`` property to retrieve environment values
/// from the view that created the custom animation. For more information, see
/// ``AnimationContext``.
///
/// To create an ``Animation`` instance of a custom animation, use the
/// ``Animation/init(_:)`` initializer, passing in an instance of a custom
/// animation; for example:
///
///     Animation(ElasticEaseInEaseOutAnimation(duration: 5.0))
///
/// To help make view code more readable, extend ``Animation`` and add a static
/// property and function that returns an `Animation` instance of a custom
/// animation. For example, the following code adds the static property
/// `elasticEaseInEaseOut` that returns the elastic ease-in ease-out animation
/// with a default duration of `0.35` seconds. Next, the code adds a method
/// that returns the animation with a specified duration.
///
///     extension Animation {
///         static var elasticEaseInEaseOut: Animation { elasticEaseInEaseOut(duration: 0.35) }
///         static func elasticEaseInEaseOut(duration: TimeInterval) -> Animation {
///             Animation(ElasticEaseInEaseOutAnimation(duration: duration))
///         }
///     }
///
/// To animate a view with the elastic ease-in ease-out animation, a view calls
/// either `.elasticEaseInEaseOut` or `.elasticEaseInEaseOut(duration:)`. For
/// example, the follow code includes an Animate button that, when clicked,
/// animates a circle as it moves from one edge of the view to the other,
/// using the elastic ease-in ease-out animation with a duration of `5`
/// seconds:
///
///     struct ElasticEaseInEaseOutView: View {
///         @State private var isActive = false
///
///         var body: some View {
///             VStack(alignment: isActive ? .trailing : .leading) {
///                 Circle()
///                     .frame(width: 100.0)
///                     .foregroundColor(.accentColor)
///
///                 Button("Animate") {
///                     withAnimation(.elasticEaseInEaseOut(duration: 5.0)) {
///                         isActive.toggle()
///                     }
///                 }
///                 .frame(maxWidth: .infinity)
///             }
///             .padding()
///         }
///     }
///
/// @Video(source: "animation-20-elastic.mp4", poster: "animation-20-elastic.png", alt: "A video that shows a circle that moves from one edge of the view to the other using an elastic ease-in ease-out animation. The circle's initial position is near the leading edge of the view. The circle begins moving slightly towards the leading, then towards trail edges of the view before it moves off the leading edge showing only two-thirds of the circle. The circle then moves quickly to the trailing edge of the view, going slightly beyond the edge so that only two-thirds of the circle is visible. The circle bounces back into full view before settling into position near the trailing edge of the view. The circle repeats this animation in reverse, going from the trailing edge of the view to the leading edge.")
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol CustomAnimation : Hashable {
/// Calculates the value of the animation at the specified time.
///
/// Implement this method to calculate and return the value of the
/// animation at a given point in time. If the animation has finished,
/// return `nil` as the value. This signals to the system that it can
/// remove the animation.
///
/// If your custom animation needs to maintain state between calls to the
/// `animate(value:time:context:)` method, store the state data in
/// `context`. This makes the data available to the method next time
/// the system calls it. To learn more about managing state data in a
/// custom animation, see ``AnimationContext``.
///
/// - Parameters:
///   - value: The vector to animate towards.
///   - time: The elapsed time since the start of the animation.
///   - context: An instance of ``AnimationContext`` that provides access
///   to state and the animation environment.
/// - Returns: The current value of the animation, or `nil` if the
///   animation has finished.
func animate<V>(value: V, time: TimeInterval, context: inout AnimationContext<V>) -> V? where V : VectorArithmetic
/// Calculates the velocity of the animation at a specified time.
///
/// Implement this method to provide the velocity of the animation at a
/// given time. Should subsequent animations merge with the animation,
/// the system preserves continuity of the velocity between animations.
///
/// The default implementation of this method returns `nil`.
///
/// > Note: State and environment data is available to this method via the
/// `context` parameter, but `context` is read-only. This behavior is
/// different than with ``animate(value:time:context:)`` and
/// ``shouldMerge(previous:value:time:context:)-7f4ts`` where `context` is
/// an `inout` parameter, letting you change the context including state
/// data of the animation. For more information about managing state data
/// in a custom animation, see ``AnimationContext``.
///
/// - Parameters:
///   - value: The vector to animate towards.
///   - time: The amount of time since the start of the animation.
///   - context: An instance of ``AnimationContext`` that provides access
///   to state and the animation environment.
/// - Returns: The current velocity of the animation, or `nil` if the
///   animation has finished.
func velocity<V>(value: V, time: TimeInterval, context: AnimationContext<V>) -> V? where V : VectorArithmetic
/// Determines whether an instance of the animation can merge with other
/// instance of the same type.
///
/// When a view creates a new animation on an animatable value that already
/// has a running animation of the same animation type, the system calls
/// the `shouldMerge(previous:value:time:context:)` method on the new
/// instance to determine whether it can merge the two instance. Implement
/// this method if the animation can merge with another instance. The
/// default implementation returns `false`.
///
/// If `shouldMerge(previous:value:time:context:)` returns `true`, the
/// system merges the new animation instance with the previous animation.
/// The system provides to the new instance the state and elapsed time from
/// the previous one. Then it removes the previous animation.
///
/// If this method returns `false`, the system doesn't merge the animation
/// with the previous one. Instead, both animations run together and the
/// system combines their results.
///
/// If your custom animation needs to maintain state between calls to the
/// `shouldMerge(previous:value:time:context:)` method, store the state
/// data in `context`. This makes the data available to the method next
/// time the system calls it. To learn more, see ``AnimationContext``.
///
/// - Parameters:
///   - previous: The previous running animation.
///   - value: The vector to animate towards.
///   - time: The amount of time since the start of the previous animation.
///   - context: An instance of ``AnimationContext`` that provides access
///   to state and the animation environment.
/// - Returns: A Boolean value of `true` if the animation should merge with
///   the previous animation; otherwise, `false`.
func shouldMerge<V>(previous: Animation, value: V, time: TimeInterval, context: inout AnimationContext<V>) -> Bool where V : VectorArithmetic
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CustomAnimation {
/// Calculates the velocity of the animation at a specified time.
///
/// Implement this method to provide the velocity of the animation at a
/// given time. Should subsequent animations merge with the animation,
/// the system preserves continuity of the velocity between animations.
///
/// The default implementation of this method returns `nil`.
///
/// > Note: State and environment data is available to this method via the
/// `context` parameter, but `context` is read-only. This behavior is
/// different than with ``animate(value:time:context:)`` and
/// ``shouldMerge(previous:value:time:context:)-7f4ts`` where `context` is
/// an `inout` parameter, letting you change the context including state
/// data of the animation. For more information about managing state data
/// in a custom animation, see ``AnimationContext``.
///
/// - Parameters:
///   - value: The vector to animate towards.
///   - time: The amount of time since the start of the animation.
///   - context: An instance of ``AnimationContext`` that provides access
///   to state and the animation environment.
/// - Returns: The current velocity of the animation, or `nil` if the
///   animation has finished.
public func velocity<V>(value: V, time: TimeInterval, context: AnimationContext<V>) -> V? where V : VectorArithmetic
/// Determines whether an instance of the animation can merge with other
/// instance of the same type.
///
/// When a view creates a new animation on an animatable value that already
/// has a running animation of the same animation type, the system calls
/// the `shouldMerge(previous:value:time:context:)` method on the new
/// instance to determine whether it can merge the two instance. Implement
/// this method if the animation can merge with another instance. The
/// default implementation returns `false`.
///
/// If `shouldMerge(previous:value:time:context:)` returns `true`, the
/// system merges the new animation instance with the previous animation.
/// The system provides to the new instance the state and elapsed time from
/// the previous one. Then it removes the previous animation.
///
/// If this method returns `false`, the system doesn't merge the animation
/// with the previous one. Instead, both animations run together and the
/// system combines their results.
///
/// If your custom animation needs to maintain state between calls to the
/// `shouldMerge(previous:value:time:context:)` method, store the state
/// data in `context`. This makes the data available to the method next
/// time the system calls it. To learn more, see ``AnimationContext``.
///
/// - Parameters:
///   - previous: The previous running animation.
///   - value: The vector to animate towards.
///   - time: The amount of time since the start of the previous animation.
///   - context: An instance of ``AnimationContext`` that provides access
///   to state and the animation environment.
/// - Returns: A Boolean value of `true` if the animation should merge with
///   the previous animation; otherwise, `false`.
public func shouldMerge<V>(previous: Animation, value: V, time: TimeInterval, context: inout AnimationContext<V>) -> Bool where V : VectorArithmetic
}
/// The definition of a custom detent with a calculated height.
///
/// You can create and use a custom detent with built-in detents.
///
///     extension PresentationDetent {
///         static let bar = Self.custom(BarDetent.self)
///         static let small = Self.height(100)
///         static let extraLarge = Self.fraction(0.75)
///     }
///
///     private struct BarDetent: CustomPresentationDetent {
///         static func height(in context: Context) -> CGFloat? {
///             max(44, context.maxDetentValue * 0.1)
///         }
///     }
///
///     struct ContentView: View {
///         @State private var showSettings = false
///         @State private var selectedDetent = PresentationDetent.bar
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView(selectedDetent: $selectedDetent)
///                     .presentationDetents(
///                         [.bar, .small, .medium, .large, .extraLarge],
///                         selection: $selectedDetent)
///             }
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol CustomPresentationDetent {
/// Calculates and returns a height based on the context.
///
/// - Parameter context: Information that can help to determine the
///   height of the detent.
///
/// - Returns: The height of the detent, or `nil` if the detent should be
///   inactive based on the `contenxt` input.
static func height(in context: Self.Context) -> CGFloat?
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension CustomPresentationDetent {
/// Information that you can use to calculate the height of a custom detent.
public typealias Context = PresentationDetent.Context
}
/// Conforming types represent items that can be placed in various locations
/// in a customizable toolbar.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol CustomizableToolbarContent : ToolbarContent where Self.Body : CustomizableToolbarContent {
}
extension CustomizableToolbarContent {
/// Configures the customization behavior of customizable toolbar content.
///
/// Customizable toolbar items support different kinds of customization:
/// * A user can add an an item that is not in the toolbar.
/// * A user can remove an item that is in the toolbar.
/// * A user can move an item within the toolbar.
///
/// Based on the customization behavior of the toolbar items, different
/// edits will be supported.
///
/// Use this modifier to the customization behavior a user can
/// perform on your toolbar items. In the following example, the
/// customizable toolbar item supports all of the different kinds of
/// toolbar customizations and starts in the toolbar.
///
///     ContentView()
///         .toolbar(id: "main") {
///             ToolbarItem(id: "new") {
///                 // new button here
///             }
///         }
///
/// You can create an item that can not be removed from the toolbar
/// or moved within the toolbar  by passing a value of
/// ``ToolbarCustomizationBehavior/disabled`` to this modifier.
///
///     ContentView()
///         .toolbar(id: "main") {
///             ToolbarItem(id: "new") {
///                 // new button here
///             }
///             .customizationBehavior(.disabled)
///         }
///
/// You can create an item that can not be removed from the toolbar, but
/// can be moved by passing a value of
/// ``ToolbarCustomizationBehavior/reorderable``.
///
///     ContentView()
///         .toolbar(id: "main") {
///             ToolbarItem(id: "new") {
///                 // new button here
///             }
///             .customizationBehavior(.reorderable)
///         }
///
/// - Parameter behavior: The customization behavior of the customizable
///   toolbar content.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func customizationBehavior(_ behavior: ToolbarCustomizationBehavior) -> some CustomizableToolbarContent
}
extension CustomizableToolbarContent {
/// Configures the way customizable toolbar items with the default
/// behavior behave.
///
/// Default customizable items support a variety of edits by the user.
/// * A user can add an an item that is not in the toolbar.
/// * A user can remove an item that is in the toolbar.
/// * A user can move an item within the toolbar.
///
/// By default, all default customizable items will be initially
/// present in the toolbar. Provide a value of
/// ``Visibility/hidden`` to this modifier to specify that items should
/// initially be hidden from the user, and require them to add those items
/// to the toolbar if desired.
///
///     ContentView()
///         .toolbar(id: "main") {
///             ToolbarItem(id: "new") {
///                 // new button here
///             }
///             .defaultCustomization(.hidden)
///         }
///
/// You can ensure that the user can always use an item with default
/// customizability, even if it's removed from the customizable toolbar. To
/// do this, provide the ``ToolbarCustomizationOptions/alwaysAvailable``
/// option. Unlike a customizable item with a customization behavior of
/// ``ToolbarCustomizationBehavior/none`` which always remain in the toolbar
/// itself, these items will remain in the overflow if the user removes them
/// from the toolbar.
///
/// Provide a value of ``ToolbarCustomizationOptions/alwaysAvailable`` to
/// the options parameter of this modifier to receive this behavior.
///
///     ContentView()
///         .toolbar(id: "main") {
///             ToolbarItem(id: "new") {
///                 // new button here
///             }
///             .defaultCustomization(options: .alwaysAvailable)
///         }
///
/// - Parameters:
///   - defaultVisibility: The default visibility of toolbar content
///     with the default customization behavior.
///   - options: The customization options to configure the behavior
///     of toolbar content with the default customization behavior.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func defaultCustomization(_ defaultVisibility: Visibility = .automatic, options: ToolbarCustomizationOptions = []) -> some CustomizableToolbarContent
/// Configures customizable toolbar content with the default visibility
/// and options.
///
/// Use the ``CustomizableToolbarContent/defaultCustomization(_:options:)``
/// modifier providing either a `defaultVisibility` or `options` instead.
@available(iOS, introduced: 16.0, deprecated: 16.0, message: "Please provide either a visibility or customization options")
@available(macOS, introduced: 13.0, deprecated: 13.0, message: "Please provide either a visibility or customization options")
@available(tvOS, introduced: 16.0, deprecated: 16.0, message: "Please provide either a visibility or customization options")
@available(watchOS, introduced: 9.0, deprecated: 9.0, message: "Please provide either a visibility or customization options")
public func defaultCustomization() -> some CustomizableToolbarContent
}
/// A control for selecting an absolute date.
///
/// Use a `DatePicker` when you want to provide a view that allows the user to
/// select a calendar date, and optionally a time. The view binds to a
/// <doc://com.apple.documentation/documentation/Foundation/Date> instance.
///
/// The following example creates a basic `DatePicker`, which appears on iOS as
/// text representing the date. This example limits the display to only the
/// calendar date, not the time. When the user taps or clicks the text, a
/// calendar view animates in, from which the user can select a date. When the
/// user dismisses the calendar view, the view updates the bound
/// <doc://com.apple.documentation/documentation/Foundation/Date>.
///
///     @State private var date = Date()
///
///     var body: some View {
///         DatePicker(
///             "Start Date",
///             selection: $date,
///             displayedComponents: [.date]
///         )
///     }
///
/// ![An iOS date picker, consisting of a label that says Start Date, and a
/// label showing the date Apr 1, 1976.](SwiftUI-DatePicker-basic.png)
///
/// You can limit the `DatePicker` to specific ranges of dates, allowing
/// selections only before or after a certain date, or between two dates. The
/// following example shows a date-and-time picker that only permits selections
/// within the year 2021 (in the `UTC` time zone).
///
///     @State private var date = Date()
///     let dateRange: ClosedRange<Date> = {
///         let calendar = Calendar.current
///         let startComponents = DateComponents(year: 2021, month: 1, day: 1)
///         let endComponents = DateComponents(year: 2021, month: 12, day: 31, hour: 23, minute: 59, second: 59)
///         return calendar.date(from:startComponents)!
///             ...
///             calendar.date(from:endComponents)!
///     }()
///
///     var body: some View {
///         DatePicker(
///             "Start Date",
///              selection: $date,
///              in: dateRange,
///              displayedComponents: [.date, .hourAndMinute]
///         )
///     }
///
/// ![A SwiftUI standard date picker on iOS, with the label Start Date, and
/// buttons for the time 5:15 PM and the date Jul 31,
/// 2021.](SwiftUI-DatePicker-selectFromRange.png)
///
/// ### Styling date pickers
///
/// To use a different style of date picker, use the
/// ``View/datePickerStyle(_:)`` view modifier. The following example shows the
/// graphical date picker style.
///
///     @State private var date = Date()
///
///     var body: some View {
///         DatePicker(
///             "Start Date",
///             selection: $date,
///             displayedComponents: [.date]
///         )
///         .datePickerStyle(.graphical)
///     }
///
/// ![A SwiftUI date picker using the graphical style, with the label Start Date
/// and wheels for the month, day, and year, showing the selection
/// October 22, 2021.](SwiftUI-DatePicker-graphicalStyle.png)
///
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct DatePicker<Label> : View where Label : View {
public typealias Components = DatePickerComponents
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
extension DatePicker {
/// Creates an instance that selects a `Date` with an unbounded range.
///
/// - Parameters:
///   - selection: The date value being displayed and selected.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
///   - label: A view that describes the use of the date.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(selection: Binding<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date], @ViewBuilder label: () -> Label)
/// Creates an instance that selects a `Date` in a closed range.
///
/// - Parameters:
///   - selection: The date value being displayed and selected.
///   - range: The inclusive range of selectable dates.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
///   - label: A view that describes the use of the date.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(selection: Binding<Date>, in range: ClosedRange<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date], @ViewBuilder label: () -> Label)
/// Creates an instance that selects a `Date` on or after some start date.
///
/// - Parameters:
///   - selection: The date value being displayed and selected.
///   - range: The open range from some selectable start date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
///   - label: A view that describes the use of the date.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(selection: Binding<Date>, in range: PartialRangeFrom<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date], @ViewBuilder label: () -> Label)
/// Creates an instance that selects a `Date` on or before some end date.
///
/// - Parameters:
///   - selection: The date value being displayed and selected.
///   - range: The open range before some selectable end date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
///   - label: A view that describes the use of the date.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(selection: Binding<Date>, in range: PartialRangeThrough<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date], @ViewBuilder label: () -> Label)
}
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
extension DatePicker where Label == Text {
/// Creates an instance that selects a `Date` with an unbounded range.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date value being displayed and selected.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(_ titleKey: LocalizedStringKey, selection: Binding<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
/// Creates an instance that selects a `Date` in a closed range.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The inclusive range of selectable dates.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(_ titleKey: LocalizedStringKey, selection: Binding<Date>, in range: ClosedRange<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
/// Creates an instance that selects a `Date` on or after some start date.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The open range from some selectable start date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(_ titleKey: LocalizedStringKey, selection: Binding<Date>, in range: PartialRangeFrom<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
/// Creates an instance that selects a `Date` on or before some end date.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The open range before some selectable end date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init(_ titleKey: LocalizedStringKey, selection: Binding<Date>, in range: PartialRangeThrough<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
/// Creates an instance that selects a `Date` within the given range.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date value being displayed and selected.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init<S>(_ title: S, selection: Binding<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date]) where S : StringProtocol
/// Creates an instance that selects a `Date` in a closed range.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The inclusive range of selectable dates.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init<S>(_ title: S, selection: Binding<Date>, in range: ClosedRange<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date]) where S : StringProtocol
/// Creates an instance that selects a `Date` on or after some start date.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The open range from some selectable start date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init<S>(_ title: S, selection: Binding<Date>, in range: PartialRangeFrom<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date]) where S : StringProtocol
/// Creates an instance that selects a `Date` on or before some end date.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date value being displayed and selected.
///   - range: The open range before some selectable end date.
///   - displayedComponents: The date components that user is able to
///     view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
///     if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
///     `.date`, only `.date` is displayed.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public init<S>(_ title: S, selection: Binding<Date>, in range: PartialRangeThrough<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date]) where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct DatePickerComponents : OptionSet, Sendable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: UInt)
/// Displays hour and minute components based on the locale
public static let hourAndMinute: DatePickerComponents
/// Displays day, month, and year based on the locale
public static let date: DatePickerComponents
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = DatePickerComponents
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = DatePickerComponents
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt
}
/// A type that specifies the appearance and interaction of all date pickers
/// within a view hierarchy.
///
/// To configure the current date picker style for a view hierarchy, use the
/// ``View/datePickerStyle(_:)`` modifier.
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
public protocol DatePickerStyle {
/// A view representing the appearance and interaction of a `DatePicker`.
associatedtype Body : View
/// Returns the appearance and interaction content for a `DatePicker`.
///
/// The system calls this method for each ``DatePicker`` instance in a view
/// hierarchy where this style is the current date picker style.
///
/// - Parameter configuration : The properties of the date picker.
@available(iOS 16.0, macOS 13.0, *)
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// A type alias for the properties of a `DatePicker`.
@available(iOS 16.0, macOS 13.0, *)
typealias Configuration = DatePickerStyleConfiguration
}
@available(iOS 13.0, watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
extension DatePickerStyle where Self == WheelDatePickerStyle {
/// A date picker style that displays each component as columns in a
/// scrollable wheel.
public static var wheel: WheelDatePickerStyle { get }
}
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
extension DatePickerStyle where Self == DefaultDatePickerStyle {
/// The default style for date pickers.
public static var automatic: DefaultDatePickerStyle { get }
}
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DatePickerStyle where Self == GraphicalDatePickerStyle {
/// A date picker style that displays an interactive calendar or clock.
///
/// This style is useful when you want to allow browsing through days in a
/// calendar, or when the look of a clock face is appropriate.
public static var graphical: GraphicalDatePickerStyle { get }
}
@available(iOS 14.0, macCatalyst 13.4, macOS 10.15.4, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DatePickerStyle where Self == CompactDatePickerStyle {
/// A date picker style that displays the components in a compact, textual
/// format.
///
/// Use this style when space is constrained and users expect to make
/// specific date and time selections. Some variants may include rich
/// editing controls in a pop up.
public static var compact: CompactDatePickerStyle { get }
}
/// The properties of a `DatePicker`.
@available(iOS 16.0, macOS 13.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct DatePickerStyleConfiguration {
/// A type-erased label of a `DatePicker`.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A description of the `DatePicker`.
public let label: DatePickerStyleConfiguration.Label
/// The date value being displayed and selected.
@Binding public var selection: Date { get nonmutating set }
public var $selection: Binding<Date> { get }
/// The oldest selectable date.
public var minimumDate: Date?
/// The most recent selectable date.
public var maximumDate: Date?
/// The date components that the user is able to view and edit.
public var displayedComponents: DatePickerComponents
}
/// The default button style, based on the button's context.
///
/// You can also use ``PrimitiveButtonStyle/automatic`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct DefaultButtonStyle : PrimitiveButtonStyle {
/// Creates a default button style.
public init()
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
public func makeBody(configuration: DefaultButtonStyle.Configuration) -> some View
/// A view that represents the body of a button.
public typealias Body = some View
}
/// The default style for date pickers.
///
/// You can also use ``DatePickerStyle/automatic`` to construct this style.
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct DefaultDatePickerStyle : DatePickerStyle {
/// Creates an instance of the default date picker style.
public init()
/// Returns the appearance and interaction content for a `DatePicker`.
///
/// The system calls this method for each ``DatePicker`` instance in a view
/// hierarchy where this style is the current date picker style.
///
/// - Parameter configuration : The properties of the date picker.
@available(iOS 16.0, macOS 13.0, *)
public func makeBody(configuration: DefaultDatePickerStyle.Configuration) -> some View
/// A view representing the appearance and interaction of a `DatePicker`.
public typealias Body = some View
}
/// The default type of the current value label when used by a date-relative
/// progress view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct DefaultDateProgressLabel : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// Prioritizations for default focus preferences when evaluating where
/// to move focus in different circumstances.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct DefaultFocusEvaluationPriority : Sendable {
/// Use the default focus preference when focus moves into the affected
/// branch automatically, but ignore it when the movement is driven by a
/// user-initiated navigation command.
public static let automatic: DefaultFocusEvaluationPriority
/// Always use the default focus preference when focus moves into the
/// affected branch.
public static let userInitiated: DefaultFocusEvaluationPriority
}
/// The default gauge view style in the current context of the view being
/// styled.
///
/// You can also use ``GaugeStyle/automatic`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
public struct DefaultGaugeStyle : GaugeStyle {
/// Creates a default gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: DefaultGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// The default style for group box views.
///
/// You can also use ``GroupBoxStyle/automatic`` to construct this style.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DefaultGroupBoxStyle : GroupBoxStyle {
public init()
/// Creates a view representing the body of a group box.
///
/// SwiftUI calls this method for each instance of ``SwiftUI/GroupBox``
/// created within a view hierarchy where this style is the current
/// group box style.
///
/// - Parameter configuration: The properties of the group box instance being
///   created.
public func makeBody(configuration: DefaultGroupBoxStyle.Configuration) -> some View
/// A view that represents the body of a group box.
public typealias Body = some View
}
/// The default label style in the current context.
///
/// You can also use ``LabelStyle/automatic`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct DefaultLabelStyle : LabelStyle {
/// Creates an automatic label style.
public init()
/// Creates a view that represents the body of a label.
///
/// The system calls this method for each ``Label`` instance in a view
/// hierarchy where this style is the current label style.
///
/// - Parameter configuration: The properties of the label.
public func makeBody(configuration: DefaultLabelStyle.Configuration) -> some View
/// A view that represents the body of a label.
public typealias Body = some View
}
/// The list style that describes a platform's default behavior and appearance
/// for a list.
///
/// You can also use ``ListStyle/automatic`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct DefaultListStyle : ListStyle {
/// Creates a default list style.
public init()
}
/// The default menu style, based on the menu's context.
///
/// You can also use ``MenuStyle/automatic`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct DefaultMenuStyle : MenuStyle {
/// Creates a default menu style.
public init()
/// Creates a view that represents the body of a menu.
///
/// - Parameter configuration: The properties of the menu.
///
/// The system calls this method for each ``Menu`` instance in a view
/// hierarchy where this style is the current menu style.
public func makeBody(configuration: DefaultMenuStyle.Configuration) -> some View
/// A view that represents the body of a menu.
public typealias Body = some View
}
/// The default navigation view style.
///
/// You can also use ``NavigationViewStyle/automatic`` to construct this style.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
public struct DefaultNavigationViewStyle : NavigationViewStyle {
public init()
}
/// The default picker style, based on the picker's context.
///
/// You can also use ``PickerStyle/automatic`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct DefaultPickerStyle : PickerStyle {
/// Creates a default picker style.
public init()
}
/// The default progress view style in the current context of the view being
/// styled.
///
/// Use ``ProgressViewStyle/automatic`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct DefaultProgressViewStyle : ProgressViewStyle {
/// Creates a default progress view style.
public init()
/// Creates a view representing the body of a progress view.
///
/// - Parameter configuration: The properties of the progress view being
///   created.
///
/// The view hierarchy calls this method for each progress view where this
/// style is the current progress view style.
///
/// - Parameter configuration: The properties of the progress view, such as
///  its preferred progress type.
public func makeBody(configuration: DefaultProgressViewStyle.Configuration) -> some View
/// A view representing the body of a progress view.
public typealias Body = some View
}
/// The default label used for a share link.
///
/// You don't use this type directly. Instead, ``ShareLink`` uses it
/// automatically depending on how you create a share link.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct DefaultShareLinkLabel : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// The default `TabView` style.
///
/// You can also use ``TabViewStyle/automatic`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct DefaultTabViewStyle : TabViewStyle {
public init()
}
/// The default text field style, based on the text field's context.
///
/// You can also use ``TextFieldStyle/automatic`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct DefaultTextFieldStyle : TextFieldStyle {
public init()
}
/// The default toggle style.
///
/// Use the ``ToggleStyle/automatic`` static variable to create this style:
///
///     Toggle("Enhance Sound", isOn: $isEnhanced)
///         .toggleStyle(.automatic)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct DefaultToggleStyle : ToggleStyle {
/// Creates a default toggle style.
///
/// Don't call this initializer directly. Instead, use the
/// ``ToggleStyle/automatic`` static variable to create this style:
///
///     Toggle("Enhance Sound", isOn: $isEnhanced)
///         .toggleStyle(.automatic)
///
public init()
/// Creates a view that represents the body of a toggle.
///
/// SwiftUI implements this required method of the ``ToggleStyle``
/// protocol to define the behavior and appearance of the
/// ``ToggleStyle/automatic`` toggle style. Don't call this method
/// directly. Rather, the system calls this method for each
/// ``Toggle`` instance in a view hierarchy that needs the default
/// style.
///
/// - Parameter configuration: The properties of the toggle, including a
///   label and a binding to the toggle's state.
/// - Returns: A view that acts as a toggle.
public func makeBody(configuration: DefaultToggleStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a toggle.
///
/// SwiftUI infers this type automatically based on the ``View``
/// instance that you return from your implementation of the
/// ``makeBody(configuration:)`` method.
public typealias Body = some View
}
/// A selectability type that disables text selection by the person using your app.
///
/// Don't use this type directly. Instead, use ``TextSelectability/disabled``.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DisabledTextSelectability : TextSelectability {
/// A Boolean value that indicates whether the selectability type allows
/// selection.
///
/// Conforming types, such as ``EnabledTextSelectability`` and
/// ``DisabledTextSelectability``, return `true` or `false` for this
/// property as appropriate. SwiftUI expects this value for a given
/// selectability type to be constant, unaffected by global state.
public static let allowsSelection: Bool
}
/// A view that shows or hides another content view, based on the state of a
/// disclosure control.
///
/// A disclosure group view consists of a label to identify the contents, and a
/// control to show and hide the contents. Showing the contents puts the
/// disclosure group into the "expanded" state, and hiding them makes the
/// disclosure group "collapsed".
///
/// In the following example, a disclosure group contains two toggles and
/// an embedded disclosure group. The top level disclosure group exposes its
/// expanded state with the bound property, `topLevelExpanded`. By expanding
/// the disclosure group, the user can use the toggles to update the state of
/// the `toggleStates` structure.
///
///     struct ToggleStates {
///         var oneIsOn: Bool = false
///         var twoIsOn: Bool = true
///     }
///     @State private var toggleStates = ToggleStates()
///     @State private var topExpanded: Bool = true
///
///     var body: some View {
///         DisclosureGroup("Items", isExpanded: $topExpanded) {
///             Toggle("Toggle 1", isOn: $toggleStates.oneIsOn)
///             Toggle("Toggle 2", isOn: $toggleStates.twoIsOn)
///             DisclosureGroup("Sub-items") {
///                 Text("Sub-item 1")
///             }
///         }
///     }
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DisclosureGroup<Label, Content> : View where Label : View, Content : View {
/// Creates a disclosure group with the given label and content views.
///
/// - Parameters:
///   - content: The content shown when the disclosure group expands.
///   - label: A view that describes the content of the disclosure group.
public init(@ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label)
/// Creates a disclosure group with the given label and content views, and
/// a binding to the expansion state (expanded or collapsed).
///
/// - Parameters:
///   - isExpanded: A binding to a Boolean value that determines the group's
///    expansion state (expanded or collapsed).
///   - content: The content shown when the disclosure group expands.
///   - label: A view that describes the content of the disclosure group.
public init(isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DisclosureGroup where Label == Text {
/// Creates a disclosure group, using a provided localized string key to
/// create a text view for the label.
///
/// - Parameters:
///   - titleKey: The key for the localized label of `self` that describes
///     the content of the disclosure group.
///   - content: The content shown when the disclosure group expands.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: @escaping () -> Content)
/// Creates a disclosure group, using a provided localized string key to
/// create a text view for the label, and a binding to the expansion state
/// (expanded or collapsed).
///
/// - Parameters:
///   - titleKey: The key for the localized label of `self` that describes
///     the content of the disclosure group.
///   - isExpanded: A binding to a Boolean value that determines the group's
///    expansion state (expanded or collapsed).
///   - content: The content shown when the disclosure group expands.
public init(_ titleKey: LocalizedStringKey, isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content)
/// Creates a disclosure group, using a provided string to create a
/// text view for the label.
///
/// - Parameters:
///   - label: A description of the content of the disclosure group.
///   - content: The content shown when the disclosure group expands.
public init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol
/// Creates a disclosure group, using a provided string to create a
/// text view for the label, and a binding to the expansion state (expanded
/// or collapsed).
///
/// - Parameters:
///   - label: A description of the content of the disclosure group.
///   - isExpanded: A binding to a Boolean value that determines the group's
///    expansion state (expanded or collapsed).
///   - content: The content shown when the disclosure group expands.
public init<S>(_ label: S, isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol
}
/// A type that specifies the appearance and interaction of disclosure groups
/// within a view hierarchy.
///
/// To configure the disclosure group style for a view hierarchy, use the
/// ``View/disclosureGroupStyle(_:)`` modifier.
///
/// To create a custom disclosure group style, declare a type that conforms
/// to `DisclosureGroupStyle`. Implement the
/// ``DisclosureGroupStyle/makeBody(configuration:)`` method to return a view
/// that composes the elements of the `configuration` that SwiftUI provides to
/// your method.
///
///     struct MyDisclosureStyle: DisclosureGroupStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             VStack {
///                 Button {
///                     withAnimation {
///                         configuration.isExpanded.toggle()
///                     }
///                 } label: {
///                     HStack(alignment: .firstTextBaseline) {
///                         configuration.label
///                         Spacer()
///                         Text(configuration.isExpanded ? "hide" : "show")
///                             .foregroundColor(.accentColor)
///                             .font(.caption.lowercaseSmallCaps())
///                             .animation(nil, value: configuration.isExpanded)
///                     }
///                     .contentShape(Rectangle())
///                 }
///                 .buttonStyle(.plain)
///                 if configuration.isExpanded {
///                     configuration.content
///                 }
///             }
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol DisclosureGroupStyle {
/// A view that represents the body of a disclosure group.
associatedtype Body : View
/// Creates a view that represents the body of a disclosure group.
///
/// SwiftUI calls this method for each instance of ``DisclosureGroup``
/// that you create within a view hierarchy where this style is the current
/// ``DisclosureGroupStyle``.
///
/// - Parameter configuration: The properties of the instance being created.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a disclosure group instance.
typealias Configuration = DisclosureGroupStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DisclosureGroupStyle where Self == AutomaticDisclosureGroupStyle {
/// A disclosure group style that resolves its appearance automatically
/// based on the current context.
public static var automatic: AutomaticDisclosureGroupStyle { get }
}
/// The properties of a disclosure group instance.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DisclosureGroupStyleConfiguration {
/// A type-erased label of a disclosure group.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The label for the disclosure group.
public let label: DisclosureGroupStyleConfiguration.Label
/// A type-erased content of a disclosure group.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The content of the disclosure group.
public let content: DisclosureGroupStyleConfiguration.Content
/// A binding to a Boolean that indicates whether the disclosure
/// group is expanded.
@Binding public var isExpanded: Bool { get nonmutating set }
public var $isExpanded: Binding<Bool> { get }
}
/// A kind of table row that shows or hides additional rows based on the state
/// of a disclosure control.
///
/// A disclosure group row consists of a label row that is always visible, and
/// some content rows that are conditionally visible depending on the state.
/// Toggling the control will flip the state between "expanded" and "collapsed".
///
/// In the following example, a disclosure group has `allDevices` as the label
/// row, and exposes its expanded state with the bound property, `expanded`.
/// Upon toggling the disclosure control, the user can update the expanded state
/// which will in turn show or hide the three content rows for `iPhone`, `iPad`,
/// and `Mac`.
///
///     private struct DeviceStats: Identifiable {
///         // ...
///     }
///     @State private var expanded: Bool = true
///     @State private var allDevices: DeviceStats = /* ... */
///     @State private var iPhone: DeviceStats = /* ... */
///     @State private var iPad: DeviceStats = /* ... */
///     @State private var Mac: DeviceStats = /* ... */
///
///     var body: some View {
///         Table(of: DeviceStats.self) {
///             // ...
///         } rows: {
///             DisclosureTableRow(allDevices, isExpanded: $expanded) {
///                 TableRow(iPhone)
///                 TableRow(iPad)
///                 TableRow(Mac)
///             }
///         }
///     }
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DisclosureTableRow<Label, Content> : TableRowContent where Label : TableRowContent, Content : TableRowContent, Label.TableRowValue == Content.TableRowValue {
/// The type of value represented by this table row content.
public typealias TableRowValue = Label.TableRowValue
/// Creates a disclosure group with the given value and table rows, and a
/// binding to the expansion state (expanded or collapsed).
///
/// - Parameters:
///   - value: The value of the disclosable table row.
///   - isExpanded: A binding to a Boolean value that determines the group's
///    expansion state (expanded or collapsed).
///   - content: The table row shown when the disclosure group expands.
public init<Value>(_ value: Value, isExpanded: Binding<Bool>? = nil, @TableRowBuilder<Value> content: @escaping () -> Content) where Label == TableRow<Value>, Value == Content.TableRowValue
/// The composition of content that comprise the table row content.
public var tableRowBody: some TableRowContent { get }
/// The type of content representing the body of this table row content.
public typealias TableRowBody = some TableRowContent
}
/// An action that dismisses a presentation.
///
/// Use the ``EnvironmentValues/dismiss`` environment value to get the instance
/// of this structure for a given ``Environment``. Then call the instance
/// to perform the dismissal. You call the instance directly because
/// it defines a ``DismissAction/callAsFunction()``
/// method that Swift calls when you call the instance.
///
/// You can use this action to:
///  * Dismiss a modal presentation, like a sheet or a popover.
///  * Pop the current view from a ``NavigationStack``.
///  * Close a window that you create with ``WindowGroup`` or ``Window``.
///
/// The specific behavior of the action depends on where you call it from.
/// For example, you can create a button that calls the ``DismissAction``
/// inside a view that acts as a sheet:
///
///     private struct SheetContents: View {
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Button("Done") {
///                 dismiss()
///             }
///         }
///     }
///
/// When you present the `SheetContents` view, someone can dismiss
/// the sheet by tapping or clicking the sheet's button:
///
///     private struct DetailView: View {
///         @State private var isSheetPresented = false
///
///         var body: some View {
///             Button("Show Sheet") {
///                 isSheetPresented = true
///             }
///             .sheet(isPresented: $isSheetPresented) {
///                 SheetContents()
///             }
///         }
///     }
///
/// Be sure that you define the action in the appropriate environment.
/// For example, don't reorganize the `DetailView` in the example above
/// so that it creates the `dismiss` property and calls it from the
/// ``View/sheet(item:onDismiss:content:)`` view modifier's `content`
/// closure:
///
///     private struct DetailView: View {
///         @State private var isSheetPresented = false
///         @Environment(\.dismiss) private var dismiss // Applies to DetailView.
///
///         var body: some View {
///             Button("Show Sheet") {
///                 isSheetPresented = true
///             }
///             .sheet(isPresented: $isSheetPresented) {
///                 Button("Done") {
///                     dismiss() // Fails to dismiss the sheet.
///                 }
///             }
///         }
///     }
///
/// If you do this, the sheet fails to dismiss because the action applies
/// to the environment where you declared it, which is that of the detail
/// view, rather than the sheet. In fact, in macOS and iPadOS, if the
/// `DetailView` is the root view of a window, the dismiss action closes
/// the window instead.
///
/// The dismiss action has no effect on a view that isn't currently
/// presented. If you need to query whether SwiftUI is currently presenting
/// a view, read the ``EnvironmentValues/isPresented`` environment value.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct DismissAction {
/// Dismisses the view if it is currently presented.
///
/// Don't call this method directly. SwiftUI calls it for you when you
/// call the ``DismissAction`` structure that you get from the
/// ``Environment``:
///
///     private struct SheetContents: View {
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Button("Done") {
///                 dismiss() // Implicitly calls dismiss.callAsFunction()
///             }
///         }
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
public func callAsFunction()
}
/// Programmatic window dismissal behaviors.
///
/// Use values of this type to control window dismissal during the
/// current transaction.
///
/// For example, to dismiss windows showing a modal presentation
/// that would otherwise prohibit dismissal, use the ``destructive``
/// behavior:
///
///     struct DismissWindowButton: View {
///         @Environment(\.dismissWindow) private var dismissWindow
///
///         var body: some View {
///             Button("Close Auxiliary Window") {
///                 withTransaction(\.dismissBehavior, .destructive) {
///                     dismissWindow(id: "auxiliary")
///                 }
///             }
///         }
///     }
///
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DismissBehavior : Sendable {
/// The interactive dismiss behavior.
///
/// Use this behavior when you want to dismiss a window in a manner that is
/// similar to the standard system affordances for window dismissal - for
/// example, when a user clicks the close button.
///
/// This is the default behavior on macOS and iOS.
///
/// On macOS, dismissing a window using this behavior will not dismiss a
/// window which is currently showing a modal presentation, such as a sheet
/// or alert. Additionally, a document window that is dismissed with this
/// behavior will show the save dialog if there are unsaved changes to the
/// document.
///
/// On iOS, dismissing a window using this behavior will dismiss it
/// regardless of any modal presentations being shown.
public static let interactive: DismissBehavior
/// The destructive dismiss behavior.
///
/// Use this behavior when you want to dismiss a window regardless of
/// any conditions that would normally prevent the dismissal. Dismissing
/// windows in this matter may result in loss of state.
///
/// On macOS, this behavior will cause windows to dismiss even when they are
/// currently showing a modal presentation, such as a sheet or alert.
/// Additionally, a document window will not show the save dialog when
/// there are unsaved changes and the window is dismissed with this
/// behavior.
///
/// On iOS, this behavior behaves the same as `interactive`.
public static let destructive: DismissBehavior
}
/// An action that can end a search interaction.
///
/// Use the ``EnvironmentValues/dismissSearch`` environment value to get the
/// instance of this structure for a given ``Environment``. Then call the
/// instance to dismiss the current search interaction. You call the instance
/// directly because it defines a ``DismissSearchAction/callAsFunction()``
/// method that Swift calls when you call the instance.
///
/// When you dismiss search, SwiftUI:
///
/// * Sets ``EnvironmentValues/isSearching`` to `false`.
/// * Clears any text from the search field.
/// * Removes focus from the search field.
///
/// > Note: Calling this instance has no effect if the user isn't
/// interacting with a search field.
///
/// Use this action to dismiss a search operation based on
/// another user interaction. For example, consider a searchable
/// view with a ``Button`` that presents more information about the first
/// matching item from a collection:
///
///     struct ContentView: View {
///         @State private var searchText = ""
///
///         var body: some View {
///             NavigationStack {
///                 SearchedView(searchText: searchText)
///                     .searchable(text: $searchText)
///             }
///         }
///     }
///
///     struct SearchedView: View {
///         var searchText: String
///
///         let items = ["a", "b", "c"]
///         var filteredItems: [String] { items.filter { $0 == searchText.lowercased() } }
///
///         @State private var isPresented = false
///         @Environment(\.dismissSearch) private var dismissSearch
///
///         var body: some View {
///             if let item = filteredItems.first {
///                 Button("Details about \(item)") {
///                     isPresented = true
///                 }
///                 .sheet(isPresented: $isPresented) {
///                     NavigationStack {
///                         DetailView(item: item, dismissSearch: dismissSearch)
///                     }
///                 }
///             }
///         }
///     }
///
/// The button becomes visible only after the user enters search text
/// that produces a match. When the user taps the button, SwiftUI shows
/// a sheet that provides more information about the item, including
/// an Add button for adding the item to a stored list of items:
///
///     private struct DetailView: View {
///         var item: String
///         var dismissSearch: DismissSearchAction
///
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Text("Information about \(item).")
///                 .toolbar {
///                     Button("Add") {
///                         // Store the item here...
///
///                         dismiss()
///                         dismissSearch()
///                     }
///                 }
///         }
///     }
///
/// People can dismiss the sheet by dragging it down, effectively
/// canceling the operation, leaving the in-progress search interaction
/// intact. Alternatively, people can tap the Add button to store the item.
/// Because the person using your app is likely to be done with both the
/// detail view and the search interaction at this point, the button's
/// closure also uses the ``EnvironmentValues/dismiss`` property to dismiss
/// the sheet, and the ``EnvironmentValues/dismissSearch`` property to
/// reset the search field.
///
/// > Important: Access the action from inside the searched view, as the
///   example above demonstrates, rather than from the searched view’s
///   parent, or another hierarchy, like that of a sheet. SwiftUI sets the
///   value in the environment of the view that you apply the searchable
///   modifier to, and doesn’t propagate the value up the view hierarchy.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct DismissSearchAction {
/// Dismisses the current search operation, if any.
///
/// Don't call this method directly. SwiftUI calls it for you when you
/// call the ``DismissSearchAction`` structure that you get from the
/// ``Environment``:
///
///     struct SearchedView: View {
///         @Environment(\.dismissSearch) private var dismissSearch
///
///         var body: some View {
///             Button("Cancel") {
///                 dismissSearch() // Implicitly calls dismissSearch.callAsFunction()
///             }
///         }
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
public func callAsFunction()
}
/// An action that dismisses a window associated to a particular scene.
///
/// Use the ``EnvironmentValues/dismissWindow`` environment value to get the
/// instance of this structure for a given ``Environment``. Then call the
/// instance to dismiss a window. You call the instance directly because it
/// defines a ``DismissWindowAction/callAsFunction(id:)`` method that Swift
/// calls when you call the instance.
///
/// For example, you can define a button that closes an auxiliary window:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///             }
///             #if os(macOS)
///             Window("Auxiliary", id: "auxiliary") {
///                 AuxiliaryContentView()
///             }
///             #endif
///         }
///     }
///
///     struct DismissWindowButton: View {
///         @Environment(\.dismissWindow) private var dismissWindow
///
///         var body: some View {
///             Button("Close Auxiliary Window") {
///                 dismissWindow(id: "auxiliary")
///             }
///         }
///     }
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DismissWindowAction {
/// Dismisses the current window.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/dismissWindow`` action:
///
///     dismissWindow()
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Methods-with-Special-Names)
/// in *The Swift Programming Language*.
public func callAsFunction()
/// Dismisses the window that's associated with the specified identifier.
///
/// When the specified identifier represents a ``WindowGroup``, all of the
/// open windows in that group will be dismissed. For dismissing a single
/// window associated to a `WindowGroup` scene, use
/// ``dismissWindow(value:)`` or ``dismissWindow(id:value:)``.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/dismissWindow`` action with an identifier:
///
///     dismissWindow(id: "message")
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Methods-with-Special-Names)
/// in *The Swift Programming Language*.
///
/// - Parameter id: The identifier of the scene to dismiss.
public func callAsFunction(id: String)
/// Dismisses the window defined by the window group that is presenting the
/// specified value type.
///
/// If multiple windows match the provided value, then they all will be
/// dismissed. For dismissing a specific window in a specific group, use
/// ``dismissWindow(id:value:)``.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/dismissWindow`` action with an identifier
/// and a value:
///
///     dismissWindow(value: message.id)
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Methods-with-Special-Names)
/// in *The Swift Programming Language*.
///
/// - Parameters:
///   - value: The value which is currently presented.
public func callAsFunction<D>(value: D) where D : Decodable, D : Encodable, D : Hashable
/// Dismisses the window defined by the window group that is presenting the
/// specified value type and that's associated with the specified identifier.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/dismissWindow`` action with an identifier
/// and a value:
///
///     dismissWindow(id: "message", value: message.id)
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Methods-with-Special-Names)
/// in *The Swift Programming Language*.
///
/// - Parameters:
///   - id: The identifier of the scene to dismiss.
///   - value: The value which is currently presented.
public func callAsFunction<D>(id: String, value: D) where D : Decodable, D : Encodable, D : Hashable
}
/// A visual element that can be used to separate other content.
///
/// When contained in a stack, the divider extends across the minor axis of the
/// stack, or horizontally when not in a stack.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Divider : View {
public init()
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DocumentConfiguration {
/// A Boolean value that indicates whether you can edit the document.
///
/// On macOS, the document could be non-editable if the user lacks write permissions,
/// the parent directory or volume is read-only,
/// or the document couldn't be autosaved.
///
/// On iOS, the document is not editable if there was
/// an error reading or saving it, there's an unresolved conflict,
/// the document is being uploaded or downloaded,
/// or otherwise, it is currently busy and unsafe for user edits.
public var isEditable: Bool { get }
/// A URL of an open document.
///
/// If the document has never been saved, returns `nil`.
public var fileURL: URL? { get }
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DocumentConfiguration : Sendable {
}
/// A scene that enables support for opening, creating, and saving documents.
///
/// Use a `DocumentGroup` scene to tell SwiftUI what kinds of documents your
/// app can open when you declare your app using the ``App`` protocol.
///
/// Initialize a document group scene by passing in the document model and a
/// view capable of displaying the document type. The document types you supply
/// to `DocumentGroup` must conform to ``FileDocument`` or
/// ``ReferenceFileDocument``. SwiftUI uses the model to add document support
/// to your app. In macOS this includes document-based menu support, including
/// the ability to open multiple documents. On iOS this includes a document
/// browser that can navigate to the documents stored on the file system
/// and multiwindow support:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(newDocument: TextFile()) { configuration in
///                 ContentView(document: configuration.$document)
///             }
///         }
///     }
///
/// Any time the configuration changes, SwiftUI updates the contents
/// with that new configuration, similar to other parameterized builders.
///
/// ### Viewing documents
///
/// If your app only needs to display but not modify a specific
/// document type, you can use the file viewer document group scene. You
/// supply the file type of the document, and a view that displays the
/// document type that you provide:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(viewing: MyImageFormatDocument.self) {
///                 MyImageFormatViewer(image: $0.document)
///             }
///         }
///     }
///
/// ### Supporting multiple document types
///
/// Your app can support multiple document types by adding additional
/// document group scenes:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(newDocument: TextFile()) { group in
///                 ContentView(document: group.$document)
///             }
///             DocumentGroup(viewing: MyImageFormatDocument.self) { group in
///                 MyImageFormatViewer(image: group.document)
///             }
///         }
///     }
///
/// ### Accessing the document's URL
///
/// If your app needs to know the document's URL, you can read it from the `editor`
/// closure's `configuration` parameter, along with the binding to the document.
/// When you create a new document, the configuration's `fileURL` property is `nil`.
/// Every time it changes, it is passed over to the `DocumentGroup` builder
/// in the updated `configuration`.
/// This ensures that the view you define in the closure always knows
/// the URL of the document it hosts.
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(newDocument: TextFile()) { configuration in
///                 ContentView(
///                     document: configuration.$document,
///                     fileURL: configuration.fileURL
///                 )
///             }
///         }
///     }
///
/// The URL can be used, for example, to present the file path of the file name
/// in the user interface.
/// Don't access the document's contents or metadata using the URL because that
/// can conflict with the management of the file that SwiftUI performs.
/// Instead, use the methods that ``FileDocument`` and ``ReferenceFileDocument``
/// provide to perform read and write operations.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DocumentGroup<Document, Content> : Scene where Content : View {
/// The content and behavior of the scene.
///
/// For any scene that you create, provide a computed `body` property that
/// defines the scene as a composition of other scenes. You can assemble a
/// scene from built-in scenes that SwiftUI provides, as well as other
/// scenes that you've defined.
///
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype``
/// associated type based on the contents of the `body` property.
@MainActor public var body: some Scene { get }
/// The type of scene that represents the body of this scene.
///
/// When you create a custom scene, Swift infers this type from your
/// implementation of the required ``SwiftUI/Scene/body-swift.property``
/// property.
public typealias Body = some Scene
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DocumentGroup where Document : ReferenceFileDocument {
/// Creates a document group that is able to create and edit reference file
/// documents.
///
/// - Parameters:
///   - newDocument: The initial document used when the user creates
///     a new document. The argument should create a new instance, such that
///     a new document is created on each invocation of the closure.
///   - editor: The editing UI for the provided document.
///
/// The current document for a given editor instance is also provided as an
/// environment object for its subhierarchy.
///
/// Undo support is not automatically provided for this construction of
/// a `DocumentGroup`, and any updates to the document by the editor view
/// hierarchy are expected to register undo operations when appropriate.
public init(newDocument: @escaping () -> Document, @ViewBuilder editor: @escaping (ReferenceFileDocumentConfiguration<Document>) -> Content)
/// Creates a document group that is able to view reference file documents.
///
/// - Parameters:
///   - documentType: The type of document being viewed.
///   - viewer: The viewing UI for the provided document.
///
/// The current document for a given editor instance is also provided as an
/// environment object for its subhierarchy.
///
/// - See Also: `CFBundleTypeRole` with a value of "Viewer"
public init(viewing documentType: Document.Type, @ViewBuilder viewer: @escaping (ReferenceFileDocumentConfiguration<Document>) -> Content)
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DocumentGroup where Document : FileDocument {
/// Creates a document group for creating and editing file documents.
///
/// Use a ``DocumentGroup`` scene to tell SwiftUI what kinds of documents
/// your app can open when you declare your app using the ``App`` protocol.
/// You initialize a document group scene by passing in the document model
/// and a view capable of displaying the document's contents. The document
/// types you supply to ``DocumentGroup`` must conform to ``FileDocument``
/// or ``ReferenceFileDocument``. SwiftUI uses the model to add document
/// support to your app. In macOS this includes document-based menu support
/// including the ability to open multiple documents. On iOS this includes
/// a document browser that can navigate to the documents stored on the
/// file system and multiwindow support:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(newDocument: TextFile()) { file in
///                 ContentView(document: file.$document)
///             }
///         }
///     }
///
/// The document types you supply to ``DocumentGroup`` must conform to
/// ``FileDocument`` or ``ReferenceFileDocument``. Your app can support
///  multiple document types by adding additional ``DocumentGroup`` scenes.
///
/// - Parameters:
///   - newDocument: The initial document to use when a user creates
///     a new document.
///   - editor: The editing UI for the provided document.
public init(newDocument: @autoclosure @escaping () -> Document, @ViewBuilder editor: @escaping (FileDocumentConfiguration<Document>) -> Content)
/// Creates a document group capable of viewing file documents.
///
/// Use this method to create a document group that can view files of a
/// specific type. The example below creates a new document viewer for
/// `MyImageFormatDocument` and displays them with `MyImageFormatViewer`:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             DocumentGroup(viewing: MyImageFormatDocument.self) { file in
///                 MyImageFormatViewer(image: file.document)
///             }
///         }
///     }
///
/// - Parameters:
///   - documentType: The type of document your app can view.
///   - viewer: The viewing UI for the provided document.
///
/// You tell the system about the app's role with respect to the document
/// type by setting the
///  <doc://com.apple.documentation/documentation/BundleResources/Information_Property_List/CFBundleDocumentTypes/CFBundleTypeRole>
///   `Info.plist` key with a value of `Viewer`.
///
public init(viewing documentType: Document.Type, @ViewBuilder viewer: @escaping (FileDocumentConfiguration<Document>) -> Content)
}
/// A navigation view style represented by a primary view stack that
/// navigates to a detail view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
public struct DoubleColumnNavigationViewStyle : NavigationViewStyle {
public init()
}
/// A dragging motion that invokes an action as the drag-event sequence changes.
///
/// To recognize a drag gesture on a view, create and configure the gesture, and
/// then add it to the view using the ``View/gesture(_:including:)`` modifier.
///
/// Add a drag gesture to a ``Circle`` and change its color while the user
/// performs the drag gesture:
///
///     struct DragGestureView: View {
///         @State private var isDragging = false
///
///         var drag: some Gesture {
///             DragGesture()
///                 .onChanged { _ in self.isDragging = true }
///                 .onEnded { _ in self.isDragging = false }
///         }
///
///         var body: some View {
///             Circle()
///                 .fill(self.isDragging ? Color.red : Color.blue)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .gesture(drag)
///         }
///     }
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
public struct DragGesture : Gesture {
/// The attributes of a drag gesture.
public struct Value : Equatable, Sendable {
/// The time associated with the drag gesture's current event.
public var time: Date
/// The location of the drag gesture's current event.
public var location: CGPoint
/// The location of the drag gesture's first event.
public var startLocation: CGPoint
/// The total translation from the start of the drag gesture to the
/// current event of the drag gesture.
///
/// This is equivalent to `location.{x,y} - startLocation.{x,y}`.
public var translation: CGSize { get }
/// The current drag velocity.
public var velocity: CGSize { get }
/// A prediction, based on the current drag velocity, of where the final
/// location will be if dragging stopped now.
public var predictedEndLocation: CGPoint { get }
/// A prediction, based on the current drag velocity, of what the final
/// translation will be if dragging stopped now.
public var predictedEndTranslation: CGSize { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: DragGesture.Value, b: DragGesture.Value) -> Bool
}
/// The minimum dragging distance before the gesture succeeds.
public var minimumDistance: CGFloat
/// The coordinate space in which to receive location values.
public var coordinateSpace: CoordinateSpace
/// Creates a dragging gesture with the minimum dragging distance before the
/// gesture succeeds and the coordinate space of the gesture's location.
///
/// - Parameters:
///   - minimumDistance: The minimum dragging distance for the gesture to
///     succeed.
///   - coordinateSpace: The coordinate space of the dragging gesture's
///     location.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(tvOS, unavailable)
public init(minimumDistance: CGFloat = 10, coordinateSpace: CoordinateSpace = .local)
/// Creates a dragging gesture with the minimum dragging distance before the
/// gesture succeeds and the coordinate space of the gesture's location.
///
/// - Parameters:
///   - minimumDistance: The minimum dragging distance for the gesture to
///     succeed.
///   - coordinateSpace: The coordinate space of the dragging gesture's
///     location.
@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public init(minimumDistance: CGFloat = 10, coordinateSpace: some CoordinateSpaceProtocol = .local)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// An interface that you implement to interact with a drop operation in a view
/// modified to accept drops.
///
/// The ``DropDelegate`` protocol provides a comprehensive and flexible way to
/// interact with a drop operation. Specify a drop delegate when you modify a
/// view to accept drops with the ``View/onDrop(of:delegate:)-6lin8`` method.
///
/// Alternatively, for simple drop cases that don't require the full
/// functionality of a drop delegate, you can modify a view to accept drops
/// using the ``View/onDrop(of:isTargeted:perform:)-f15m`` or the
/// ``View/onDrop(of:isTargeted:perform:)-982eu`` method. These methods handle the
/// drop using a closure you provide as part of the modifier.
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public protocol DropDelegate {
/// Tells the delegate that a drop containing items conforming to one of the
/// expected types entered a view that accepts drops.
///
/// Specify the expected types when you apply the drop modifier to the view.
/// The default implementation returns `true`.
@MainActor func validateDrop(info: DropInfo) -> Bool
/// Tells the delegate it can request the item provider data from the given
/// information.
///
/// Incorporate the received data into your app's data model as appropriate.
/// - Returns: A Boolean that is `true` if the drop was successful, `false`
///   otherwise.
@MainActor func performDrop(info: DropInfo) -> Bool
/// Tells the delegate a validated drop has entered the modified view.
///
/// The default implementation does nothing.
@MainActor func dropEntered(info: DropInfo)
/// Tells the delegate that a validated drop moved inside the modified view.
///
/// Use this method to return a drop proposal containing the operation the
/// delegate intends to perform at the drop ``DropInfo/location``. The
/// default implementation of this method returns `nil`, which tells the
/// drop to use the last valid returned value or else
/// ``DropOperation/copy``.
@MainActor func dropUpdated(info: DropInfo) -> DropProposal?
/// Tells the delegate a validated drop operation has exited the modified
/// view.
///
/// The default implementation does nothing.
@MainActor func dropExited(info: DropInfo)
}
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DropDelegate {
/// Tells the delegate that a drop containing items conforming to one of the
/// expected types entered a view that accepts drops.
///
/// Specify the expected types when you apply the drop modifier to the view.
/// The default implementation returns `true`.
@MainActor public func validateDrop(info: DropInfo) -> Bool
/// Tells the delegate a validated drop has entered the modified view.
///
/// The default implementation does nothing.
@MainActor public func dropEntered(info: DropInfo)
/// Tells the delegate that a validated drop moved inside the modified view.
///
/// Use this method to return a drop proposal containing the operation the
/// delegate intends to perform at the drop ``DropInfo/location``. The
/// default implementation of this method returns `nil`, which tells the
/// drop to use the last valid returned value or else
/// ``DropOperation/copy``.
@MainActor public func dropUpdated(info: DropInfo) -> DropProposal?
/// Tells the delegate a validated drop operation has exited the modified
/// view.
///
/// The default implementation does nothing.
@MainActor public func dropExited(info: DropInfo)
}
/// The current state of a drop.
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DropInfo {
/// The location of the drag in the coordinate space of the drop view.
public var location: CGPoint { get }
/// Indicates whether at least one item conforms to at least one of the
/// specified uniform type identifiers.
///
/// - Parameter contentTypes: The uniform type identifiers to query for.
/// - Returns: Whether at least one item conforms to one of `contentTypes`.
@available(iOS 14.0, macOS 11.0, *)
public func hasItemsConforming(to contentTypes: [UTType]) -> Bool
/// Finds item providers that conform to at least one of the specified
/// uniform type identifiers.
///
/// This function is only valid during the `performDrop()` action.
///
/// - Parameter contentTypes: The uniform type identifiers to query for.
/// - Returns: The item providers that conforms to `contentTypes`.
@available(iOS 14.0, macOS 11.0, *)
public func itemProviders(for contentTypes: [UTType]) -> [NSItemProvider]
}
@available(iOS, introduced: 13.4, deprecated: 100000.0, message: "Provide `UTType`s as the `types` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Provide `UTType`s as the `types` instead.")
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Provide `UTType`s as the `types` instead.")
extension DropInfo {
/// Returns whether at least one item conforms to at least one of the
/// specified uniform type identifiers.
public func hasItemsConforming(to types: [String]) -> Bool
/// Returns an Array of items that each conform to at least one of the
/// specified uniform type identifiers.
///
/// This function is only valid during the performDrop() action.
public func itemProviders(for types: [String]) -> [NSItemProvider]
}
/// Operation types that determine how a drag and drop session resolves when the
/// user drops a drag item.
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public enum DropOperation : Sendable {
/// Cancel the drag operation and transfer no data.
case cancel
/// The drop activity is not allowed at this time or location.
case forbidden
/// Copy the data to the modified view.
case copy
/// Move the data represented by the drag items instead of copying it.
case move
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: DropOperation, b: DropOperation) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DropOperation : Equatable {
}
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DropOperation : Hashable {
}
/// The behavior of a drop.
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DropProposal : Sendable {
/// The drop operation that the drop proposes to perform.
public let operation: DropOperation
public init(operation: DropOperation)
}
/// An interface for a stored variable that updates an external property of a
/// view.
///
/// The view gives values to these properties prior to recomputing the view's
/// ``View/body-swift.property``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol DynamicProperty {
/// Updates the underlying value of the stored value.
///
/// SwiftUI calls this function before rendering a view's
/// ``View/body-swift.property`` to ensure the view has the most recent
/// value.
mutating func update()
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension DynamicProperty {
/// Updates the underlying value of the stored value.
///
/// SwiftUI calls this function before rendering a view's
/// ``View/body-swift.property`` to ensure the view has the most recent
/// value.
public mutating func update()
}
/// A type of table row content that generates table rows from an underlying
/// collection of data.
///
/// This table row content type provides drag-and-drop support for tables. Use
/// the ``DynamicTableRowContent/onInsert(of:perform:)`` modifier to add an
/// action to call when the table inserts new contents into its underlying
/// collection.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol DynamicTableRowContent : TableRowContent {
/// The type of the underlying collection of data.
associatedtype Data : Collection
/// The collection of underlying data.
var data: Self.Data { get }
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DynamicTableRowContent {
/// Sets the insert action for the dynamic table rows.
///
///     struct Profile: Identifiable {
///         let givenName: String
///         let familyName: String
///         let id = UUID()
///     }
///
///     @State private var profiles: [Profile] = [
///         Person(givenName: "Juan", familyName: "Chavez"),
///         Person(givenName: "Mei", familyName: "Chen"),
///         Person(givenName: "Tom", familyName: "Clark"),
///         Person(givenName: "Gita", familyName: "Kumar")
///     ]
///
///     var body: some View {
///         Table {
///             TableColumn("Given Name", value: \.givenName)
///             TableColumn("Family Name", value: \.familyName)
///         } rows: {
///             ForEach(profiles) {
///                 TableRow($0)
///             }
///             .dropDestination(
///                 for: Profile.self
///             ) { offset, receivedProfiles in
///                 people.insert(contentsOf: receivedProfiles, at: offset)
///             }
///         }
///     }
///
/// - Parameters:
///   - payloadType: Type of the models that are dropped.
///   - action: A closure that SwiftUI invokes when elements are added to
///     the collection of rows.
///     The closure takes two arguments: The first argument is the
///     offset relative to the dynamic view's underlying collection of data.
///     The second argument is an array of `Transferable` items that
///     represents the data that you want to insert.
///
/// - Returns: A view that calls `action` when elements are inserted into
///   the original view.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func dropDestination<T>(for payloadType: T.Type = T.self, action: @escaping (Int, [T]) -> Void) -> ModifiedContent<Self, OnInsertTableRowModifier> where T : Transferable
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension DynamicTableRowContent {
/// Sets the insert action for the dynamic table rows.
///
/// - Parameters:
///   - supportedContentTypes: An array of universal type identifiers types that the rows supports.
///   - action: A closure that SwiftUI invokes when adding elements to
///     the collection of rows.
///     The closure takes two arguments. The first argument is the
///     offset relative to the dynamic view's underlying collection of data.
///     The second argument is an array of
///     <doc://com.apple.documentation/documentation/Foundation/NSItemProvider>
///     items that represents the data that you want to insert.
///
/// - Returns: A view that calls `action` when inserting elements into
///   the original view.
public func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> ModifiedContent<Self, OnInsertTableRowModifier>
}
/// A Dynamic Type size, which specifies how large scalable content should be.
///
/// For more information about Dynamic Type sizes in iOS, see iOS Human Interface Guidelines >
/// [Dynamic Type Sizes](https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography/#dynamic-type-sizes).
/// For more information about Dynamic Type sizes in watchOS, see watchOS Human Interface Guidelines >
/// [Dynamic Type Sizes](https://developer.apple.com/design/human-interface-guidelines/watchos/visual/typography/#dynamic-type-sizes).
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public enum DynamicTypeSize : Hashable, Comparable, CaseIterable, Sendable {
/// An extra small size.
case xSmall
/// A small size.
case small
/// A medium size.
case medium
/// A large size.
case large
/// An extra large size.
case xLarge
/// An extra extra large size.
case xxLarge
/// An extra extra extra large size.
case xxxLarge
/// The first accessibility size.
case accessibility1
/// The second accessibility size.
case accessibility2
/// The third accessibility size.
case accessibility3
/// The fourth accessibility size.
case accessibility4
/// The fifth accessibility size.
case accessibility5
/// A Boolean value indicating whether the size is one that is associated
/// with accessibility.
public var isAccessibilitySize: Bool { get }
/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func < (a: DynamicTypeSize, b: DynamicTypeSize) -> Bool
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: DynamicTypeSize, b: DynamicTypeSize) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [DynamicTypeSize]
/// A collection of all values of this type.
public static var allCases: [DynamicTypeSize] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, tvOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension DynamicTypeSize {
/// Create a Dynamic Type size from its `UIContentSizeCategory` equivalent.
public init?(_ uiSizeCategory: UIContentSizeCategory)
}
/// A type of view that generates views from an underlying collection of data.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol DynamicViewContent : View {
/// The type of the underlying collection of data.
associatedtype Data : Collection
/// The collection of underlying data.
var data: Self.Data { get }
}
extension DynamicViewContent {
/// Sets the insert action for the dynamic view.
///
///     struct Profile: Identifiable {
///         let givenName: String
///         let familyName: String
///         let id = UUID()
///     }
///
///     @State private var profiles: [Profile] = [
///         Person(givenName: "Juan", familyName: "Chavez"),
///         Person(givenName: "Mei", familyName: "Chen"),
///         Person(givenName: "Tom", familyName: "Clark"),
///         Person(givenName: "Gita", familyName: "Kumar")
///     ]
///
///     var body: some View {
///         List {
///             ForEach(profiles) { profile in
///                 Text(profile.givenName)
///             }
///             .dropDestination(for: Profile.self) { receivedProfiles, offset in
///                 profiles.insert(contentsOf: receivedProfiles, at: offset)
///             }
///         }
///     }
///
/// - Parameters:
///   - payloadType: Type of the models that are dropped.
///   - action: A closure that SwiftUI invokes when elements are added to
///     the view. The closure takes two arguments: The first argument is the
///     offset relative to the dynamic view's underlying collection of data.
///     The second argument is an array of `Transferable` items that
///     represents the data that you want to insert.
///
/// - Returns: A view that calls `action` when elements are inserted into
///   the original view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func dropDestination<T>(for payloadType: T.Type = T.self, action: @escaping ([T], Int) -> Void) -> some DynamicViewContent where T : Transferable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension DynamicViewContent {
/// Sets the insert action for the dynamic view.
///
/// - Parameters:
///   - supportedContentTypes: An array of UTI types that the dynamic
///     view supports.
///   - action: A closure that SwiftUI invokes when elements are added to
///     the view. The closure takes two arguments: The first argument is the
///     offset relative to the dynamic view's underlying collection of data.
///     The second argument is an array of
///     <doc://com.apple.documentation/documentation/Foundation/NSItemProvider> items that
///     represents the data that you want to insert.
///
/// - Returns: A view that calls `action` when elements are inserted into
///   the original view.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent
/// Sets the insert action for the dynamic view.
///
/// - Parameters:
///   - acceptedTypeIdentifiers: An array of UTI types that the dynamic
///     view supports.
///   - action: A closure that SwiftUI invokes when elements are added to
///     the view. The closure takes two arguments: The first argument is the
///     offset relative to the dynamic view's underlying collection of data.
///     The second argument is an array of `NSItemProvider` that represents
///     the data that you want to insert.
///
/// - Returns: A view that calls `action` when elements are inserted into
///   the original view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
public func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension DynamicViewContent {
/// Sets the move action for the dynamic view.
///
/// - Parameters:
///   - action: A closure that SwiftUI invokes when elements in the dynamic
///     view are moved. The closure takes two arguments that represent the
///     offset relative to the dynamic view's underlying collection of data.
///     Pass `nil` to disable the ability to move items.
///
/// - Returns: A view that calls `action` when elements are moved within the
///   original view.
@inlinable public func onMove(perform action: ((IndexSet, Int) -> Void)?) -> some DynamicViewContent
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension DynamicViewContent {
/// Sets the deletion action for the dynamic view.
///
/// - Parameter action: The action that you want SwiftUI to perform when
///   elements in the view are deleted. SwiftUI passes a set of indices to the
///   closure that's relative to the dynamic view's underlying collection of
///   data.
///
/// - Returns: A view that calls `action` when elements are deleted from the
///   original view.
@inlinable public func onDelete(perform action: ((IndexSet) -> Void)?) -> some DynamicViewContent
}
/// An enumeration to indicate one edge of a rectangle.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public enum Edge : Int8, CaseIterable {
case top
case leading
case bottom
case trailing
/// An efficient set of `Edge`s.
@frozen public struct Set : OptionSet {
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = Edge.Set
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int8
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int8)
public static let top: Edge.Set
public static let leading: Edge.Set
public static let bottom: Edge.Set
public static let trailing: Edge.Set
public static let all: Edge.Set
public static let horizontal: Edge.Set
public static let vertical: Edge.Set
/// Creates an instance containing just `e`
public init(_ e: Edge)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = Edge.Set.Element
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
}
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: Int8)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [Edge]
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
/// A collection of all values of this type.
public static var allCases: [Edge] { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int8 { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Edge : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Edge : Hashable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Edge : RawRepresentable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Edge : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Edge.Set : Sendable {
}
/// The inset distances for the sides of a rectangle.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EdgeInsets : Equatable {
public var top: CGFloat
public var leading: CGFloat
public var bottom: CGFloat
public var trailing: CGFloat
@inlinable public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat)
@inlinable public init()
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: EdgeInsets, b: EdgeInsets) -> Bool
}
extension EdgeInsets {
/// Create edge insets from the equivalent NSDirectionalEdgeInsets.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
@available(watchOS, unavailable)
public init(_ nsEdgeInsets: NSDirectionalEdgeInsets)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EdgeInsets : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGFloat, AnimatablePair<CGFloat, AnimatablePair<CGFloat, CGFloat>>>
/// The data to animate.
public var animatableData: EdgeInsets.AnimatableData
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EdgeInsets : Sendable {
}
/// A set of edit actions on a collection of data that a view can offer
/// to a user.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct EditActions<Data> : OptionSet, Sendable {
/// The raw value.
public let rawValue: Int
/// Creates a new set from a raw value.
///
/// - Parameter rawValue: The raw value with which to create the
/// collection edits.
public init(rawValue: Int)
/// All the edit actions available on this collection.
public static var all: EditActions<Data> { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = EditActions<Data>
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = EditActions<Data>
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EditActions where Data : RangeReplaceableCollection {
/// An edit action that allows the user to delete one or more elements
/// of a collection.
public static var delete: EditActions<Data> { get }
/// All the edit actions available on this collection.
public static var all: EditActions<Data> { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EditActions where Data : MutableCollection {
/// An edit action that allows the user to move elements of a
/// collection.
public static var move: EditActions<Data> { get }
/// All the edit actions available on this collection.
public static var all: EditActions<Data> { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EditActions where Data : MutableCollection, Data : RangeReplaceableCollection {
/// All the edit actions available on this collection.
public static var all: EditActions<Data> { get }
}
/// A button that toggles the edit mode environment value.
///
/// An edit button toggles the environment's ``EnvironmentValues/editMode``
/// value for content within a container that supports edit mode.
/// In the following example, an edit button placed inside a ``NavigationView``
/// supports editing of a ``List``:
///
///     @State private var fruits = [
///         "Apple",
///         "Banana",
///         "Papaya",
///         "Mango"
///     ]
///
///     var body: some View {
///         NavigationView {
///             List {
///                 ForEach(fruits, id: \.self) { fruit in
///                     Text(fruit)
///                 }
///                 .onDelete { fruits.remove(atOffsets: $0) }
///                 .onMove { fruits.move(fromOffsets: $0, toOffset: $1) }
///             }
///             .navigationTitle("Fruits")
///             .toolbar {
///                 EditButton()
///             }
///         }
///     }
///
/// Because the ``ForEach`` in the above example defines behaviors for
/// ``DynamicViewContent/onDelete(perform:)`` and
/// ``DynamicViewContent/onMove(perform:)``, the editable list displays the
/// delete and move UI when the user taps Edit. Notice that the Edit button
/// displays the title "Done" while edit mode is active:
///
/// ![A screenshot of an app with an Edit button in the navigation bar.
/// The button is labeled Done to indicate edit mode is active. Below the
/// navigation bar, a list labeled Fruits in edit mode. The list contains
/// four members, each showing a red circle containing a white dash to the
/// left of the item, and an icon composed of three horizontal lines to the
/// right of the item.](EditButton-1)
///
/// You can also create custom views that react to changes in the edit mode
/// state, as described in ``EditMode``.
@available(iOS 13.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct EditButton : View {
/// Creates an Edit button instance.
public init()
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A mode that indicates whether the user can edit a view's content.
///
/// You receive an optional binding to the edit mode state when you
/// read the ``EnvironmentValues/editMode`` environment value. The binding
/// contains an `EditMode` value that indicates whether edit mode is active,
/// and that you can use to change the mode. To learn how to read an environment
/// value, see ``EnvironmentValues``.
///
/// Certain built-in views automatically alter their appearance and behavior
/// in edit mode. For example, a ``List`` with a ``ForEach`` that's
/// configured with the ``DynamicViewContent/onDelete(perform:)`` or
/// ``DynamicViewContent/onMove(perform:)`` modifier provides controls to
/// delete or move list items while in edit mode. On devices without an attached
/// keyboard and mouse or trackpad, people can make multiple selections in lists
/// only when edit mode is active.
///
/// You can also customize your own views to react to edit mode.
/// The following example replaces a read-only ``Text`` view with
/// an editable ``TextField``, checking for edit mode by
/// testing the wrapped value's ``EditMode/isEditing`` property:
///
///     @Environment(\.editMode) private var editMode
///     @State private var name = "Maria Ruiz"
///
///     var body: some View {
///         Form {
///             if editMode?.wrappedValue.isEditing == true {
///                 TextField("Name", text: $name)
///             } else {
///                 Text(name)
///             }
///         }
///         .animation(nil, value: editMode?.wrappedValue)
///         .toolbar { // Assumes embedding this view in a NavigationView.
///             EditButton()
///         }
///     }
///
/// You can set the edit mode through the binding, or you can
/// rely on an ``EditButton`` to do that for you, as the example above
/// demonstrates. The button activates edit mode when the user
/// taps it, and disables the mode when the user taps again.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public enum EditMode : Sendable {
/// The user can't edit the view content.
///
/// The ``isEditing`` property is `false` in this state.
case inactive
/// The view is in a temporary edit mode.
///
/// The use of this state varies by platform and for different
/// controls. As an example, SwiftUI might engage temporary edit mode
/// over the duration of a swipe gesture.
///
/// The ``isEditing`` property is `true` in this state.
case transient
/// The user can edit the view content.
///
/// The ``isEditing`` property is `true` in this state.
case active
/// Indicates whether a view is being edited.
///
/// This property returns `true` if the mode is something other than
/// inactive.
public var isEditing: Bool { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: EditMode, b: EditMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension EditMode : Equatable {
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension EditMode : Hashable {
}
/// An opaque wrapper view that adds editing capabilities to a row in a list.
///
/// You don't use this type directly. Instead SwiftUI creates this type on
/// your behalf.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct EditableCollectionContent<Content, Data> {
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EditableCollectionContent : View where Content : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// An ellipse aligned inside the frame of the view containing it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Ellipse : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// Creates a new ellipse shape.
@inlinable public init()
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Ellipse : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A radial gradient that draws an ellipse.
///
/// The gradient maps its coordinate space to the unit space square
/// in which its center and radii are defined, then stretches that
/// square to fill its bounding rect, possibly also stretching the
/// circular gradient to have elliptical contours.
///
/// For example, an elliptical gradient centered on the view, filling
/// its bounds:
///
///     EllipticalGradient(gradient: .init(colors: [.red, .yellow]))
///
/// When using an elliptical gradient as a shape style, you can also use
/// ``ShapeStyle/ellipticalGradient(_:center:startRadiusFraction:endRadiusFraction:)-fmox``.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public struct EllipticalGradient : ShapeStyle, View, Sendable {
/// Creates an elliptical gradient.
///
/// For example, an elliptical gradient centered on the top-leading
/// corner of the view:
///
///     EllipticalGradient(
///         gradient: .init(colors: [.blue, .green]),
///         center: .topLeading,
///         startRadiusFraction: 0,
///         endRadiusFraction: 1)
///
/// - Parameters:
///  - gradient: The colors and their parametric locations.
///  - center: The center of the circle, in [0, 1] coordinates.
///  - startRadiusFraction: The start radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
///  - endRadiusFraction: The end radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
public init(gradient: Gradient, center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5)
/// Creates an elliptical gradient from a collection of colors.
///
/// For example, an elliptical gradient centered on the top-leading
/// corner of the view:
///
///     EllipticalGradient(
///         colors: [.blue, .green],
///         center: .topLeading,
///         startRadiusFraction: 0,
///         endRadiusFraction: 1)
///
/// - Parameters:
///  - colors: The colors, evenly distributed throughout the gradient.
///  - center: The center of the circle, in [0, 1] coordinates.
///  - startRadiusFraction: The start radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
///  - endRadiusFraction: The end radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
public init(colors: [Color], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5)
/// Creates an elliptical gradient from a collection of color stops.
///
/// For example, an elliptical gradient centered on the top-leading
/// corner of the view, with some extra green area:
///
///     EllipticalGradient(
///         stops: [
///             .init(color: .blue, location: 0.0),
///             .init(color: .green, location: 0.9),
///             .init(color: .green, location: 1.0),
///         ],
///         center: .topLeading,
///         startRadiusFraction: 0,
///         endRadiusFraction: 1)
///
/// - Parameters:
///  - stops: The colors and their parametric locations.
///  - center: The center of the circle, in [0, 1] coordinates.
///  - startRadiusFraction: The start radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
///  - endRadiusFraction: The end radius value, as a fraction
///    between zero and one. Zero maps to the center point, one
///    maps to the diameter of the unit circle.
public init(stops: [Gradient.Stop], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// An empty type for animatable data.
///
/// This type is suitable for use as the `animatableData` property of
/// types that do not have any animatable properties.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EmptyAnimatableData : VectorArithmetic {
@inlinable public init()
/// The zero value.
///
/// Zero is the identity element for addition. For any value,
/// `x + .zero == x` and `.zero + x == x`.
@inlinable public static var zero: EmptyAnimatableData { get }
/// Adds two values and stores the result in the left-hand-side variable.
///
/// - Parameters:
///   - lhs: The first value to add.
///   - rhs: The second value to add.
@inlinable public static func += (lhs: inout EmptyAnimatableData, rhs: EmptyAnimatableData)
/// Subtracts the second value from the first and stores the difference in the
/// left-hand-side variable.
///
/// - Parameters:
///   - lhs: A numeric value.
///   - rhs: The value to subtract from `lhs`.
@inlinable public static func -= (lhs: inout EmptyAnimatableData, rhs: EmptyAnimatableData)
/// Adds two values and produces their sum.
///
/// The addition operator (`+`) calculates the sum of its two arguments. For
/// example:
///
///     1 + 2                   // 3
///     -10 + 15                // 5
///     -15 + -5                // -20
///     21.5 + 3.25             // 24.75
///
/// You cannot use `+` with arguments of different types. To add values of
/// different types, convert one of the values to the other value's type.
///
///     let x: Int8 = 21
///     let y: Int = 1000000
///     Int(x) + y              // 1000021
///
/// - Parameters:
///   - lhs: The first value to add.
///   - rhs: The second value to add.
@inlinable public static func + (lhs: EmptyAnimatableData, rhs: EmptyAnimatableData) -> EmptyAnimatableData
/// Subtracts one value from another and produces their difference.
///
/// The subtraction operator (`-`) calculates the difference of its two
/// arguments. For example:
///
///     8 - 3                   // 5
///     -10 - 5                 // -15
///     100 - -5                // 105
///     10.5 - 100.0            // -89.5
///
/// You cannot use `-` with arguments of different types. To subtract values
/// of different types, convert one of the values to the other value's type.
///
///     let x: UInt8 = 21
///     let y: UInt = 1000000
///     y - UInt(x)             // 999979
///
/// - Parameters:
///   - lhs: A numeric value.
///   - rhs: The value to subtract from `lhs`.
@inlinable public static func - (lhs: EmptyAnimatableData, rhs: EmptyAnimatableData) -> EmptyAnimatableData
/// Multiplies each component of this value by the given value.
@inlinable public mutating func scale(by rhs: Double)
/// The dot-product of this animatable data instance with itself.
@inlinable public var magnitudeSquared: Double { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: EmptyAnimatableData, b: EmptyAnimatableData) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EmptyAnimatableData : Sendable {
}
/// An empty group of commands.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct EmptyCommands : Commands {
/// Creates an empty command hierarchy.
public init()
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = Never
}
/// An empty, or identity, modifier, used during development to switch
/// modifiers at compile time.
///
/// Use the empty modifier to switch modifiers at compile time during
/// development. In the example below, in a debug build the ``Text``
/// view inside `ContentView` has a yellow background and a red border.
/// A non-debug build reflects the default system, or container supplied
/// appearance.
///
///     struct EmphasizedLayout: ViewModifier {
///         func body(content: Content) -> some View {
///             content
///                 .background(Color.yellow)
///                 .border(Color.red)
///         }
///     }
///
///     struct ContentView: View {
///         var body: some View {
///             Text("Hello, World!")
///                 .modifier(modifier)
///         }
///
///         var modifier: some ViewModifier {
///             #if DEBUG
///                 return EmphasizedLayout()
///             #else
///                 return EmptyModifier()
///             #endif
///         }
///     }
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EmptyModifier : ViewModifier {
public static let identity: EmptyModifier
/// The type of view representing the body.
public typealias Body = Never
@inlinable public init()
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
@MainActor public func body(content: EmptyModifier.Content) -> EmptyModifier.Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EmptyModifier : Sendable {
}
/// A table row content that doesn't produce any rows.
///
/// You will rarely, if ever, need to create an `EmptyTableRowContent` directly.
/// Instead, `EmptyTableRowContent` represents the absence of a row.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct EmptyTableRowContent<Value> where Value : Identifiable {
/// The type of value represented by this table row content.
public typealias TableRowValue = Value
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension EmptyTableRowContent : TableRowContent {
}
/// A view that doesn't contain any content.
///
/// You will rarely, if ever, need to create an `EmptyView` directly. Instead,
/// `EmptyView` represents the absence of a view.
///
/// SwiftUI uses `EmptyView` in situations where a SwiftUI view type defines one
/// or more child views with generic parameters, and allows the child views to
/// be absent. When absent, the child view's type in the generic type parameter
/// is `EmptyView`.
///
/// The following example creates an indeterminate ``ProgressView`` without
/// a label. The ``ProgressView`` type declares two generic parameters,
/// `Label` and `CurrentValueLabel`, for the types used by its subviews.
/// When both subviews are absent, like they are here, the resulting type is
/// `ProgressView<EmptyView, EmptyView>`, as indicated by the example's output:
///
///     let progressView = ProgressView()
///     print("\(type(of:progressView))")
///     // Prints: ProgressView<EmptyView, EmptyView>
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EmptyView : View {
/// Creates an empty view.
@inlinable public init()
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EmptyView : Sendable {
}
/// The base visual effect that you apply additional effect to.
///
/// `EmptyVisualEffect` does not change the appearance of the view
/// that it is applied to.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct EmptyVisualEffect : VisualEffect {
/// Creates a new empty visual effect.
public init()
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
}
/// An empty widget configuration.
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
@frozen public struct EmptyWidgetConfiguration : WidgetConfiguration {
@inlinable public init()
/// The type of widget configuration representing the body of
/// this configuration.
///
/// When you create a custom widget, Swift infers this type from your
/// implementation of the required `body` property.
public typealias Body = Never
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension EmptyWidgetConfiguration : Sendable {
}
/// A selectability type that enables text selection by the person using your app.
///
/// Don't use this type directly. Instead, use ``TextSelectability/enabled``.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct EnabledTextSelectability : TextSelectability {
/// A Boolean value that indicates whether the selectability type allows
/// selection.
///
/// Conforming types, such as ``EnabledTextSelectability`` and
/// ``DisabledTextSelectability``, return `true` or `false` for this
/// property as appropriate. SwiftUI expects this value for a given
/// selectability type to be constant, unaffected by global state.
public static let allowsSelection: Bool
}
/// A property wrapper that reads a value from a view's environment.
///
/// Use the `Environment` property wrapper to read a value
/// stored in a view's environment. Indicate the value to read using an
/// ``EnvironmentValues`` key path in the property declaration. For example, you
/// can create a property that reads the color scheme of the current
/// view using the key path of the ``EnvironmentValues/colorScheme``
/// property:
///
///     @Environment(\.colorScheme) var colorScheme: ColorScheme
///
/// You can condition a view's content on the associated value, which
/// you read from the declared property's ``wrappedValue``. As with any property
/// wrapper, you access the wrapped value by directly referring to the property:
///
///     if colorScheme == .dark { // Checks the wrapped value.
///         DarkContent()
///     } else {
///         LightContent()
///     }
///
/// If the value changes, SwiftUI updates any parts of your view that depend on
/// the value. For example, that might happen in the above example if the user
/// changes the Appearance settings.
///
/// You can use this property wrapper to read --- but not set --- an environment
/// value. SwiftUI updates some environment values automatically based on system
/// settings and provides reasonable defaults for others. You can override some
/// of these, as well as set custom environment values that you define,
/// using the ``View/environment(_:_:)`` view modifier.
///
/// For the complete list of environment values provided by SwiftUI, see the
/// properties of the ``EnvironmentValues`` structure. For information about
/// creating custom environment values, see the ``EnvironmentKey`` protocol.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen @propertyWrapper public struct Environment<Value> : DynamicProperty {
/// Creates an environment property to read the specified key path.
///
/// Don’t call this initializer directly. Instead, declare a property
/// with the ``Environment`` property wrapper, and provide the key path of
/// the environment value that the property should reflect:
///
///     struct MyView: View {
///         @Environment(\.colorScheme) var colorScheme: ColorScheme
///
///         // ...
///     }
///
/// SwiftUI automatically updates any parts of `MyView` that depend on
/// the property when the associated environment value changes.
/// You can't modify the environment value using a property like this.
/// Instead, use the ``View/environment(_:_:)`` view modifier on a view to
/// set a value for a view hierarchy.
///
/// - Parameter keyPath: A key path to a specific resulting value.
@inlinable public init(_ keyPath: KeyPath<EnvironmentValues, Value>)
/// The current value of the environment property.
///
/// The wrapped value property provides primary access to the value's data.
/// However, you don't access `wrappedValue` directly. Instead, you read the
/// property variable created with the ``Environment`` property wrapper:
///
///     @Environment(\.colorScheme) var colorScheme: ColorScheme
///
///     var body: some View {
///         if colorScheme == .dark {
///             DarkContent()
///         } else {
///             LightContent()
///         }
///     }
///
@inlinable public var wrappedValue: Value { get }
}
extension Environment {
/// Creates an environment property to read an observable object from the
/// environment.
///
/// - Important: This initializer only accepts objects conforming to the
///   `Observable` protocol. For reading environment objects that conform to
///   `ObservableObject`, use ``EnvironmentObject`` instead.
///
/// Don’t call this initializer directly. Instead, declare a property with
/// the ``Environment`` property wrapper, passing the object's type to the
/// wrapper (using this syntax, the object type can be omitted from the end
/// of property declaration):
///
///     @Observable final class Profile { ... }
///
///     struct MyView: View {
///         @Environment(Profile.self) private var currentProfile
///
///         // ...
///     }
///
/// - Warning: If no object has been set in the view's environment, this
/// property will issue a fatal error when accessed. To safely check for the
/// existence of an environment object, initialize the environment property
/// with an optional object type instead.
///
/// SwiftUI automatically updates any parts of `MyView` that depend on the
/// property when the associated environment object changes.
///
/// You can't modify the environment object using a property like this.
/// Instead, use the ``View/environment(_:)`` view modifier on a view
/// to set an object for a view hierarchy.
///
/// - Parameter objectType: The type of the `Observable` object to read
///   from the environment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init(_ objectType: Value.Type) where Value : AnyObject, Value : Observable
/// Creates an environment property to read an observable object from the
/// environment, returning `nil` if no corresponding object has been set in
/// the current view's environment.
///
/// - Important: This initializer only accepts objects conforming to the
///   `Observable` protocol. For reading environment objects that conform to
///   `ObservableObject`, use ``EnvironmentObject`` instead.
///
/// Don’t call this initializer directly. Instead, declare an optional
/// property with the ``Environment`` property wrapper, passing the object's
/// type to the wrapper:
///
///     @Observable final class Profile { ... }
///
///     struct MyView: View {
///         @Environment(Profile.self) private var currentProfile: Profile?
///
///         // ...
///     }
///
/// If no object has been set in the view's environment, this property will
/// return `nil` as its wrapped value.
///
/// SwiftUI automatically updates any parts of `MyView` that depend on the
/// property when the associated environment object changes.
///
/// You can't modify the environment object using a property like this.
/// Instead, use the ``View/environment(_:)`` view modifier on a view
/// to set an object for a view hierarchy.
///
/// - Parameter objectType: The type of the `Observable` object to read
///   from the environment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init<T>(_ objectType: T.Type) where Value == T?, T : AnyObject, T : Observable
}
/// A key for accessing values in the environment.
///
/// You can create custom environment values by extending the
/// ``EnvironmentValues`` structure with new properties.
/// First declare a new environment key type and specify a value for the
/// required ``defaultValue`` property:
///
///     private struct MyEnvironmentKey: EnvironmentKey {
///         static let defaultValue: String = "Default value"
///     }
///
/// The Swift compiler automatically infers the associated ``Value`` type as the
/// type you specify for the default value. Then use the key to define a new
/// environment value property:
///
///     extension EnvironmentValues {
///         var myCustomValue: String {
///             get { self[MyEnvironmentKey.self] }
///             set { self[MyEnvironmentKey.self] = newValue }
///         }
///     }
///
/// Clients of your environment value never use the key directly.
/// Instead, they use the key path of your custom environment value property.
/// To set the environment value for a view and all its subviews, add the
/// ``View/environment(_:_:)`` view modifier to that view:
///
///     MyView()
///         .environment(\.myCustomValue, "Another string")
///
/// As a convenience, you can also define a dedicated view modifier to
/// apply this environment value:
///
///     extension View {
///         func myCustomValue(_ myCustomValue: String) -> some View {
///             environment(\.myCustomValue, myCustomValue)
///         }
///     }
///
/// This improves clarity at the call site:
///
///     MyView()
///         .myCustomValue("Another string")
///
/// To read the value from inside `MyView` or one of its descendants, use the
/// ``Environment`` property wrapper:
///
///     struct MyView: View {
///         @Environment(\.myCustomValue) var customValue: String
///
///         var body: some View {
///             Text(customValue) // Displays "Another string".
///         }
///     }
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol EnvironmentKey {
/// The associated type representing the type of the environment key's
/// value.
associatedtype Value
/// The default value for the environment key.
static var defaultValue: Self.Value { get }
}
/// A property wrapper type for an observable object that a parent or ancestor
/// view supplies.
///
/// An environment object invalidates the current view whenever the observable
/// object that conforms to
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// changes. If you declare a property as an environment object, be sure
/// to set a corresponding model object on an ancestor view by calling its
/// ``View/environmentObject(_:)`` modifier.
///
/// > Note: If your observable object conforms to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol, use ``Environment`` instead of `EnvironmentObject` and set the
/// model object in an ancestor view by calling its ``View/environment(_:)-4516h``
/// or ``View/environment(_:_:)`` modifiers.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen @propertyWrapper public struct EnvironmentObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject {
/// A wrapper of the underlying environment object that can create bindings
/// to its properties using dynamic member lookup.
@dynamicMemberLookup @frozen public struct Wrapper {
/// Returns a binding to the resulting value of a given key path.
///
/// - Parameter keyPath: A key path to a specific resulting value.
///
/// - Returns: A new binding.
public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<ObjectType, Subject>) -> Binding<Subject> { get }
}
/// The underlying value referenced by the environment object.
///
/// This property provides primary access to the value's data. However, you
/// don't access `wrappedValue` directly. Instead, you use the property
/// variable created with the ``EnvironmentObject`` attribute.
///
/// When a mutable value changes, the new value is immediately available.
/// However, a view displaying the value is updated asynchronously and may
/// not show the new value immediately.
@MainActor @inlinable public var wrappedValue: ObjectType { get }
/// A projection of the environment object that creates bindings to its
/// properties using dynamic member lookup.
///
/// Use the projected value to pass an environment object down a view
/// hierarchy.
@MainActor public var projectedValue: EnvironmentObject<ObjectType>.Wrapper { get }
/// Creates an environment object.
public init()
}
/// A collection of environment values propagated through a view hierarchy.
///
/// SwiftUI exposes a collection of values to your app's views in an
/// `EnvironmentValues` structure. To read a value from the structure,
/// declare a property using the ``Environment`` property wrapper and
/// specify the value's key path. For example, you can read the current locale:
///
///     @Environment(\.locale) var locale: Locale
///
/// Use the property you declare to dynamically control a view's layout.
/// SwiftUI automatically sets or updates many environment values, like
/// ``EnvironmentValues/pixelLength``, ``EnvironmentValues/scenePhase``, or
/// ``EnvironmentValues/locale``, based on device characteristics, system state,
/// or user settings. For others, like ``EnvironmentValues/lineLimit``, SwiftUI
/// provides a reasonable default value.
///
/// You can set or override some values using the ``View/environment(_:_:)``
/// view modifier:
///
///     MyView()
///         .environment(\.lineLimit, 2)
///
/// The value that you set affects the environment for the view that you modify
/// --- including its descendants in the view hierarchy --- but only up to the
/// point where you apply a different environment modifier.
///
/// SwiftUI provides dedicated view modifiers for setting some values, which
/// typically makes your code easier to read. For example, rather than setting
/// the ``EnvironmentValues/lineLimit`` value directly, as in the previous
/// example, you should instead use the ``View/lineLimit(_:)-513mb`` modifier:
///
///     MyView()
///         .lineLimit(2)
///
/// In some cases, using a dedicated view modifier provides additional
/// functionality. For example, you must use the
/// ``View/preferredColorScheme(_:)`` modifier rather than setting
/// ``EnvironmentValues/colorScheme`` directly to ensure that the new
/// value propagates up to the presenting container when presenting a view
/// like a popover:
///
///     MyView()
///         .popover(isPresented: $isPopped) {
///             PopoverContent()
///                 .preferredColorScheme(.dark)
///         }
///
/// Create custom environment values by defining a type that
/// conforms to the ``EnvironmentKey`` protocol, and then extending the
/// environment values structure with a new property. Use your key to get and
/// set the value, and provide a dedicated modifier for clients to use when
/// setting the value:
///
///     private struct MyEnvironmentKey: EnvironmentKey {
///         static let defaultValue: String = "Default value"
///     }
///
///     extension EnvironmentValues {
///         var myCustomValue: String {
///             get { self[MyEnvironmentKey.self] }
///             set { self[MyEnvironmentKey.self] = newValue }
///         }
///     }
///
///     extension View {
///         func myCustomValue(_ myCustomValue: String) -> some View {
///             environment(\.myCustomValue, myCustomValue)
///         }
///     }
///
/// Clients of your value then access the value in the usual way, reading it
/// with the ``Environment`` property wrapper, and setting it with the
/// `myCustomValue` view modifier.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct EnvironmentValues : CustomStringConvertible {
/// Creates an environment values instance.
///
/// You don't typically create an instance of ``EnvironmentValues``
/// directly. Doing so would provide access only to default values that
/// don't update based on system settings or device characteristics.
/// Instead, you rely on an environment values' instance
/// that SwiftUI manages for you when you use the ``Environment``
/// property wrapper and the ``View/environment(_:_:)`` view modifier.
public init()
/// Accesses the environment value associated with a custom key.
///
/// Create custom environment values by defining a key
/// that conforms to the ``EnvironmentKey`` protocol, and then using that
/// key with the subscript operator of the ``EnvironmentValues`` structure
/// to get and set a value for that key:
///
///     private struct MyEnvironmentKey: EnvironmentKey {
///         static let defaultValue: String = "Default value"
///     }
///
///     extension EnvironmentValues {
///         var myCustomValue: String {
///             get { self[MyEnvironmentKey.self] }
///             set { self[MyEnvironmentKey.self] = newValue }
///         }
///     }
///
/// You use custom environment values the same way you use system-provided
/// values, setting a value with the ``View/environment(_:_:)`` view
/// modifier, and reading values with the ``Environment`` property wrapper.
/// You can also provide a dedicated view modifier as a convenience for
/// setting the value:
///
///     extension View {
///         func myCustomValue(_ myCustomValue: String) -> some View {
///             environment(\.myCustomValue, myCustomValue)
///         }
///     }
///
public subscript<K>(key: K.Type) -> K.Value where K : EnvironmentKey
/// Accesses the environment value associated with a custom key.
///
/// Create custom environment values by defining a key
/// that conforms to the ``EnvironmentKey`` protocol, and then using that
/// key with the subscript operator of the ``EnvironmentValues`` structure
/// to get and set a value for that key:
///
///     private struct MyEnvironmentKey: EnvironmentKey {
///         static let defaultValue: String = "Default value"
///     }
///
///     extension EnvironmentValues {
///         var myCustomValue: String {
///             get { self[MyEnvironmentKey.self] }
///             set { self[MyEnvironmentKey.self] = newValue }
///         }
///     }
///
/// You use custom environment values the same way you use system-provided
/// values, setting a value with the ``View/environment(_:_:)`` view
/// modifier, and reading values with the ``Environment`` property wrapper.
/// You can also provide a dedicated view modifier as a convenience for
/// setting the value:
///
///     extension View {
///         func myCustomValue(_ myCustomValue: String) -> some View {
///             environment(\.myCustomValue, myCustomValue)
///         }
///     }
///
@available(iOS 17.0, tvOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public subscript<K>(key: K.Type) -> K.Value where K : UITraitBridgedEnvironmentKey
/// A string that represents the contents of the environment values
/// instance.
public var description: String { get }
}
extension EnvironmentValues {
/// Whether the Large Content Viewer is enabled.
///
/// The system can automatically provide a large content view
/// with ``View/accessibilityShowsLargeContentViewer()``
/// or you can provide your own with ``View/accessibilityShowsLargeContentViewer(_:)``.
///
/// While it is not necessary to check this value before adding
/// a large content view, it may be helpful if you need to
/// adjust the behavior of a gesture. For example, a button with
/// a long press handler might increase its long press duration
/// so the user can read the text in the large content viewer first.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public var accessibilityLargeContentViewerEnabled: Bool { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension EnvironmentValues {
/// The current redaction reasons applied to the view hierarchy.
public var redactionReasons: RedactionReasons
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// Whether the system preference for Differentiate without Color is enabled.
///
/// If this is true, UI should not convey information using color alone
/// and instead should use shapes or glyphs to convey information.
public var accessibilityDifferentiateWithoutColor: Bool { get }
/// Whether the system preference for Reduce Transparency is enabled.
///
/// If this property's value is true, UI (mainly window) backgrounds should
/// not be semi-transparent; they should be opaque.
public var accessibilityReduceTransparency: Bool { get }
/// Whether the system preference for Reduce Motion is enabled.
///
/// If this property's value is true, UI should avoid large animations,
/// especially those that simulate the third dimension.
public var accessibilityReduceMotion: Bool { get }
/// Whether the system preference for Invert Colors is enabled.
///
/// If this property's value is true then the display will be inverted.
/// In these cases it may be needed for UI drawing to be adjusted to in
/// order to display optimally when inverted.
public var accessibilityInvertColors: Bool { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension EnvironmentValues {
/// Whether the system preference for Show Button Shapes is enabled.
///
/// If this property's value is true, interactive custom controls
/// such as buttons should be drawn in such a way that their edges
/// and borders are clearly visible.
public var accessibilityShowButtonShapes: Bool { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension EnvironmentValues {
/// Whether the setting to reduce flashing or strobing lights in video
/// content is on. This setting can also be used to determine if UI in
/// playback controls should be shown to indicate upcoming content that
/// includes flashing or strobing lights.
public var accessibilityDimFlashingLights: Bool { get }
/// Whether the setting for playing animations in an animated image is
/// on. When this value is false, any presented image that contains
/// animation should not play automatically.
public var accessibilityPlayAnimatedImages: Bool { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the VoiceOver screen reader is in use.
///
/// The state changes as the user turns on or off the VoiceOver screen reader.
public var accessibilityVoiceOverEnabled: Bool { get }
/// A Boolean value that indicates whether the Switch Control motor accessibility feature is in use.
///
/// The state changes as the user turns on or off the Switch Control feature.
public var accessibilitySwitchControlEnabled: Bool { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension EnvironmentValues {
/// The prominence of the background underneath views associated with this
/// environment.
///
/// Foreground elements above an increased prominence background are
/// typically adjusted to have higher contrast against a potentially vivid
/// color, such as taking on a higher opacity monochrome appearance
/// according to the `colorScheme`. System styles like `primary`,
/// `secondary`, etc will automatically resolve to an appropriate style in
/// this context. The property can be read and used for custom styled
/// elements.
///
/// In the example below, a custom star rating element is in a list row
/// alongside some text. When the row is selected and has an increased
/// prominence appearance, the text and star rating will update their
/// appearance, the star rating replacing its use of yellow with the
/// standard `secondary` style.
///
///     struct RecipeList: View {
///         var recipes: [Recipe]
///         @Binding var selectedRecipe: Recipe.ID?
///
///         var body: some View {
///             List(recipes, selection: $selectedRecipe) {
///                 RecipeListRow(recipe: $0)
///             }
///         }
///     }
///
///     struct RecipeListRow: View {
///         var recipe: Recipe
///         var body: some View {
///             VStack(alignment: .leading) {
///                 HStack(alignment: .firstTextBaseline) {
///                     Text(recipe.name)
///                     Spacer()
///                     StarRating(rating: recipe.rating)
///                 }
///                 Text(recipe.description)
///                     .foregroundStyle(.secondary)
///                     .lineLimit(2, reservesSpace: true)
///             }
///         }
///     }
///
///     private struct StarRating: View {
///         var rating: Int
///
///         @Environment(\.backgroundProminence)
///         private var backgroundProminence
///
///         var body: some View {
///             HStack(spacing: 1) {
///                 ForEach(0..<rating, id: \.self) { _ in
///                     Image(systemName: "star.fill")
///                 }
///             }
///             .foregroundStyle(backgroundProminence == .increased ?
///                 AnyShapeStyle(.secondary) : AnyShapeStyle(.yellow))
///             .imageScale(.small)
///         }
///     }
///
/// Note that the use of `backgroundProminence` was used by a view that
/// was nested in additional stack containers within the row. This ensured
/// that the value correctly reflected the environment within the list row
/// itself, as opposed to the environment of the list as a whole. One way
/// to ensure correct resolution would be to prefer using this in a custom
/// ShapeStyle instead, for example:
///
///     private struct StarRating: View {
///         var rating: Int
///
///         var body: some View {
///             HStack(spacing: 1) {
///                 ForEach(0..<rating, id: \.self) { _ in
///                     Image(systemName: "star.fill")
///                 }
///             }
///             .foregroundStyle(FillStyle())
///             .imageScale(.small)
///         }
///     }
///
///     extension StarRating {
///         struct FillStyle: ShapeStyle {
///             func resolve(in env: EnvironmentValues) -> some ShapeStyle {
///                 switch env.backgroundProminence {
///                 case .increased: return AnyShapeStyle(.secondary)
///                 default: return AnyShapeStyle(.yellow)
///                 }
///             }
///         }
///     }
///
/// Views like `List` and `Table` as well as standard shape styles like
/// `ShapeStyle.selection` will automatically update the background
/// prominence of foreground views. For custom backgrounds, this environment
/// property can be explicitly set on views above custom backgrounds.
public var backgroundProminence: BackgroundProminence
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the current platform supports
/// opening multiple windows.
///
/// Read this property from the environment to determine if your app can
/// use the ``EnvironmentValues/openWindow`` action to open new windows:
///
///     struct NewMailViewerButton: View {
///         @Environment(\.supportsMultipleWindows) private var supportsMultipleWindows
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             Button("Open New Window") {
///                 openWindow(id: "mail-viewer")
///             }
///             .disabled(!supportsMultipleWindows)
///         }
///     }
///
/// The reported value depends on both the platform and how you configure
/// your app:
///
/// * In macOS, this property returns `true` for any app that uses the
///   SwiftUI app lifecycle.
/// * In iPadOS, this property returns `true` for any app that uses the
///   SwiftUI app lifecycle and has the Information Property List key
/// <doc://com.apple.documentation/documentation/bundleresources/information_property_list/uiapplicationscenemanifest/uiapplicationsupportsmultiplescenes> set to `true`.
/// * For all other platforms and configurations, the value returns `false`.
///
/// If the value is false and you try to open a window, SwiftUI
/// ignores the action and logs a runtime error.
public var supportsMultipleWindows: Bool { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// An action that dismisses the current presentation.
///
/// Use this environment value to get the ``DismissAction`` instance
/// for the current ``Environment``. Then call the instance
/// to perform the dismissal. You call the instance directly because
/// it defines a ``DismissAction/callAsFunction()``
/// method that Swift calls when you call the instance.
///
/// You can use this action to:
///  * Dismiss a modal presentation, like a sheet or a popover.
///  * Pop the current view from a ``NavigationStack``.
///  * Close a window that you create with ``WindowGroup`` or ``Window``.
///
/// The specific behavior of the action depends on where you call it from.
/// For example, you can create a button that calls the ``DismissAction``
/// inside a view that acts as a sheet:
///
///     private struct SheetContents: View {
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Button("Done") {
///                 dismiss()
///             }
///         }
///     }
///
/// When you present the `SheetContents` view, someone can dismiss
/// the sheet by tapping or clicking the sheet's button:
///
///     private struct DetailView: View {
///         @State private var isSheetPresented = false
///
///         var body: some View {
///             Button("Show Sheet") {
///                 isSheetPresented = true
///             }
///             .sheet(isPresented: $isSheetPresented) {
///                 SheetContents()
///             }
///         }
///     }
///
/// Be sure that you define the action in the appropriate environment.
/// For example, don't reorganize the `DetailView` in the example above
/// so that it creates the `dismiss` property and calls it from the
/// ``View/sheet(item:onDismiss:content:)`` view modifier's `content`
/// closure:
///
///     private struct DetailView: View {
///         @State private var isSheetPresented = false
///         @Environment(\.dismiss) private var dismiss // Applies to DetailView.
///
///         var body: some View {
///             Button("Show Sheet") {
///                 isSheetPresented = true
///             }
///             .sheet(isPresented: $isSheetPresented) {
///                 Button("Done") {
///                     dismiss() // Fails to dismiss the sheet.
///                 }
///             }
///         }
///     }
///
/// If you do this, the sheet fails to dismiss because the action applies
/// to the environment where you declared it, which is that of the detail
/// view, rather than the sheet. In fact, in macOS and iPadOS, if the
/// `DetailView` is the root view of a window, the dismiss action closes
/// the window instead.
///
/// The dismiss action has no effect on a view that isn't currently
/// presented. If you need to query whether SwiftUI is currently presenting
/// a view, read the ``EnvironmentValues/isPresented`` environment value.
public var dismiss: DismissAction { get }
/// A Boolean value that indicates whether the view associated with this
/// environment is currently presented.
///
/// You can read this value like any of the other ``EnvironmentValues``
/// by creating a property with the ``Environment`` property wrapper:
///
///     @Environment(\.isPresented) private var isPresented
///
/// Read the value inside a view if you need to know when SwiftUI
/// presents that view. For example, you can take an action when SwiftUI
/// presents a view by using the ``View/onChange(of:perform:)``
/// modifier:
///
///     .onChange(of: isPresented) { isPresented in
///         if isPresented {
///             // Do something when first presented.
///         }
///     }
///
/// This behaves differently than ``View/onAppear(perform:)``, which
/// SwiftUI can call more than once for a given presentation, like
/// when you navigate back to a view that's already in the
/// navigation hierarchy.
///
/// To dismiss the currently presented view, use
/// ``EnvironmentValues/dismiss``.
public var isPresented: Bool { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// An environment value that indicates how a text view aligns its lines
/// when the content wraps or contains newlines.
///
/// Set this value for a view hierarchy by applying the
/// ``View/multilineTextAlignment(_:)`` view modifier. Views in the
/// hierarchy that display text, like ``Text`` or ``TextEditor``, read the
/// value from the environment and adjust their text alignment accordingly.
///
/// This value has no effect on a ``Text`` view that contains only one
/// line of text, because a text view has a width that exactly matches the
/// width of its widest line. If you want to align an entire text view
/// rather than its contents, set the aligment of its container, like a
/// ``VStack`` or a frame that you create with the
/// ``View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)``
/// modifier.
///
/// > Note: You can use this value to control the alignment of a ``Text``
///   view that you create with the ``Text/init(_:style:)`` initializer
///   to display localized dates and times, including when the view uses
///   only a single line, but only when that view appears in a widget.
public var multilineTextAlignment: TextAlignment
/// A value that indicates how the layout truncates the last line of text to
/// fit into the available space.
///
/// The default value is ``Text/TruncationMode/tail``. Some controls,
/// however, might have a different default if appropriate.
public var truncationMode: Text.TruncationMode
/// The distance in points between the bottom of one line fragment and the
/// top of the next.
///
/// This value is always nonnegative.
public var lineSpacing: CGFloat
/// A Boolean value that indicates whether inter-character spacing should
/// tighten to fit the text into the available space.
///
/// The default value is `false`.
public var allowsTightening: Bool
/// The minimum permissible proportion to shrink the font size to fit
/// the text into the available space.
///
/// In the example below, a label with a `minimumScaleFactor` of `0.5`
/// draws its text in a font size as small as half of the actual font if
/// needed to fit into the space next to the text input field:
///
///     HStack {
///         Text("This is a very long label:")
///             .lineLimit(1)
///             .minimumScaleFactor(0.5)
///         TextField("My Long Text Field", text: $myTextField)
///             .frame(width: 250, height: 50, alignment: .center)
///     }
///
/// ![A screenshot showing the effects of setting the minimumScaleFactor on
///   the text in a view](SwiftUI-View-minimumScaleFactor.png)
///
/// You can set the minimum scale factor to any value greater than `0` and
/// less than or equal to `1`. The default value is `1`.
///
/// SwiftUI uses this value to shrink text that doesn't fit in a view when
/// it's okay to shrink the text. For example, a label with a
/// `minimumScaleFactor` of `0.5` draws its text in a font size as small as
/// half the actual font if needed.
public var minimumScaleFactor: CGFloat
/// A stylistic override to transform the case of `Text` when displayed,
/// using the environment's locale.
///
/// The default value is `nil`, displaying the `Text` without any case
/// changes.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public var textCase: Text.Case?
}
extension EnvironmentValues {
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "dynamicTypeSize")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "dynamicTypeSize")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "dynamicTypeSize")
public var sizeCategory: ContentSizeCategory
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// The allowed dynamic range for the view, or nil.
public var allowedDynamicRange: Image.DynamicRange?
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EnvironmentValues {
/// An optional style that overrides the default system background
/// style when set.
public var backgroundStyle: AnyShapeStyle?
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// An window presentation action stored in a view's environment.
///
/// Use the `openWindow` environment value to get an ``OpenWindowAction``
/// instance for a given ``Environment``. Then call the instance to open
/// a window. You call the instance directly because it defines a
/// ``OpenWindowAction/callAsFunction(id:)`` method that Swift calls
/// when you call the instance.
///
/// For example, you can define a button that opens a new mail viewer
/// window:
///
///     @main
///     struct Mail: App {
///         var body: some Scene {
///             WindowGroup(id: "mail-viewer") {
///                 MailViewer()
///             }
///         }
///     }
///
///     struct NewViewerButton: View {
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             Button("Open new mail viewer") {
///                 openWindow(id: "mail-viewer")
///             }
///         }
///     }
///
/// You indicate which scene to open by providing one of the following:
///  * A string identifier that you pass through the `id` parameter,
///    as in the above example.
///  * A `value` parameter that has a type that matches the type that
///    you specify in the scene's initializer.
///  * Both an identifier and a value. This enables you to define
///    multiple window groups that take input values of the same type like a
///    <doc://com.apple.documentation/documentation/Foundation/UUID>.
///
/// Use the first option to target either a ``WindowGroup`` or a
/// ``Window`` scene in your app that has a matching identifier. For a
/// `WindowGroup`, the system creates a new window for the group. If
/// the window group presents data, the system provides the default value
/// or `nil` to the window's root view. If the targeted scene is a
/// `Window`, the system orders it to the front.
///
/// Use the other two options to target a `WindowGroup` and provide
/// a value to present. If the interface already has a window from
/// the group that's presenting the specified value, the system brings the
/// window to the front. Otherwise, the system creates a new window and
/// passes a binding to the specified value.
public var openWindow: OpenWindowAction { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// The color scheme of this environment.
///
/// Read this environment value from within a view to find out if SwiftUI
/// is currently displaying the view using the ``ColorScheme/light`` or
/// ``ColorScheme/dark`` appearance. The value that you receive depends on
/// whether the user has enabled Dark Mode, possibly superseded by
/// the configuration of the current presentation's view hierarchy.
///
///     @Environment(\.colorScheme) private var colorScheme
///
///     var body: some View {
///         Text(colorScheme == .dark ? "Dark" : "Light")
///     }
///
/// You can set the `colorScheme` environment value directly,
/// but that usually isn't what you want. Doing so changes the color
/// scheme of the given view and its child views but *not* the views
/// above it in the view hierarchy. Instead, set a color scheme using the
/// ``View/preferredColorScheme(_:)`` modifier, which also propagates the
/// value up through the view hierarchy to the enclosing presentation, like
/// a sheet or a window.
///
/// When adjusting your app's user interface to match the color scheme,
/// consider also checking the ``EnvironmentValues/colorSchemeContrast``
/// property, which reflects a system-wide contrast setting that the user
/// controls. For information about using color and contrast in your app,
/// see [Color and Contrast](https://developer.apple.com/design/human-interface-guidelines/accessibility/overview/color-and-contrast/).
///
/// > Note: If you only need to provide different colors or
/// images for different color scheme and contrast settings, do that in
/// your app's Asset Catalog. See
/// <doc://com.apple.documentation/documentation/Xcode/Asset-Management>.
public var colorScheme: ColorScheme
/// The contrast associated with the color scheme of this environment.
///
/// Read this environment value from within a view to find out if SwiftUI
/// is currently displaying the view using ``ColorSchemeContrast/standard``
/// or ``ColorSchemeContrast/increased`` contrast. The value that you read
/// depends entirely on user settings, and you can't change it.
///
///     @Environment(\.colorSchemeContrast) private var colorSchemeContrast
///
///     var body: some View {
///         Text(colorSchemeContrast == .standard ? "Standard" : "Increased")
///     }
///
/// When adjusting your app's user interface to match the contrast,
/// consider also checking the ``EnvironmentValues/colorScheme`` property
/// to find out if SwiftUI is displaying the view with a light or dark
/// appearance. For information about using color and contrast in your app,
/// see [Color and Contrast](https://developer.apple.com/design/human-interface-guidelines/accessibility/overview/color-and-contrast/).
///
/// > Note: If you only need to provide different colors or
/// images for different color scheme and contrast settings, do that in
/// your app's Asset Catalog. See
/// <doc://com.apple.documentation/documentation/Xcode/Asset-Management>.
public var colorSchemeContrast: ColorSchemeContrast { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// The prominence to apply to section headers within a view.
///
/// The default is ``Prominence/standard``.
public var headerProminence: Prominence
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EnvironmentValues {
/// The preferred order of items for menus presented from this view.
///
/// Set this value for a view hierarchy by calling the
/// ``View/menuOrder(_:)`` view modifier.
public var menuOrder: MenuOrder
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension EnvironmentValues {
/// The behavior of spring loaded interactions for the views associated
/// with this environment.
///
/// Spring loading refers to a view being activated during a drag and drop
/// interaction. On iOS this can occur when pausing briefly on top of a
/// view with dragged content. On macOS this can occur with similar brief
/// pauses or on pressure-sensitive systems by "force clicking" during the
/// drag. This has no effect on tvOS or watchOS.
///
/// This is commonly used with views that have a navigation or presentation
/// effect, allowing the destination to be revealed without pausing the
/// drag interaction. For example, a button that reveals a list of folders
/// that a dragged item can be dropped onto.
///
/// A value of `enabled` means that a view should support spring loaded
/// interactions if it is able, and `disabled` means it should not.
/// A value of `automatic` means that a view should follow its default
/// behavior, such as a `TabView` automatically allowing spring loading,
/// but a `Picker` with `segmented` style would not.
public var springLoadingBehavior: SpringLoadingBehavior { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension EnvironmentValues {
/// The current phase of the scene.
///
/// The system sets this value to provide an indication of the
/// operational state of a scene or collection of scenes. The exact
/// meaning depends on where you access the value. For more information,
/// see ``ScenePhase``.
public var scenePhase: ScenePhase
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// The default minimum height of a row in a list.
public var defaultMinListRowHeight: CGFloat
/// The default minimum height of a header in a list.
///
/// When this value is `nil`, the system chooses the appropriate height. The
/// default is `nil`.
public var defaultMinListHeaderHeight: CGFloat?
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension EnvironmentValues {
/// An action that opens a URL.
///
/// Read this environment value to get an ``OpenURLAction``
/// instance for a given ``Environment``. Call the
/// instance to open a URL. You call the instance directly because it
/// defines a ``OpenURLAction/callAsFunction(_:)`` method that Swift
/// calls when you call the instance.
///
/// For example, you can open a web site when the user taps a button:
///
///     struct OpenURLExample: View {
///         @Environment(\.openURL) private var openURL
///
///         var body: some View {
///             Button {
///                 if let url = URL(string: "https://www.example.com") {
///                     openURL(url)
///                 }
///             } label: {
///                 Label("Get Help", systemImage: "person.fill.questionmark")
///             }
///         }
///     }
///
/// If you want to know whether the action succeeds, add a completion
/// handler that takes a Boolean value. In this case, Swift implicitly
/// calls the ``OpenURLAction/callAsFunction(_:completion:)`` method
/// instead. That method calls your completion handler after it determines
/// whether it can open the URL, but possibly before it finishes opening
/// the URL. You can add a handler to the example above so that
/// it prints the outcome to the console:
///
///     openURL(url) { accepted in
///         print(accepted ? "Success" : "Failure")
///     }
///
/// The system provides a default open URL action with behavior
/// that depends on the contents of the URL. For example, the default
/// action opens a Universal Link in the associated app if possible,
/// or in the user’s default web browser if not.
///
/// You can also set a custom action using the ``View/environment(_:_:)``
/// view modifier. Any views that read the action from the environment,
/// including the built-in ``Link`` view and ``Text`` views with markdown
/// links, or links in attributed strings, use your action. Initialize an
/// action by calling the ``OpenURLAction/init(handler:)`` initializer with
/// a handler that takes a URL and returns an ``OpenURLAction/Result``:
///
///     Text("Visit [Example Company](https://www.example.com) for details.")
///         .environment(\.openURL, OpenURLAction { url in
///             handleURL(url) // Define this method to take appropriate action.
///             return .handled
///         })
///
/// SwiftUI translates the value that your custom action's handler
/// returns into an appropriate Boolean result for the action call.
/// For example, a view that uses the action declared above
/// receives `true` when calling the action, because the
/// handler always returns ``OpenURLAction/Result/handled``.
public var openURL: OpenURLAction
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// The symbol variant to use in this environment.
///
/// You set this environment value indirectly by using the
/// ``View/symbolVariant(_:)`` view modifier. However, you access the
/// environment variable directly using the ``View/environment(_:_:)``
/// modifier. Do this when you want to use the ``SymbolVariants/none``
/// variant to ignore the value that's already in the environment:
///
///     HStack {
///         Image(systemName: "heart")
///         Image(systemName: "heart")
///             .environment(\.symbolVariants, .none)
///     }
///     .symbolVariant(.fill)
///
/// ![A screenshot of two heart symbols. The first is filled while the
/// second is outlined.](SymbolVariants-none-1)
public var symbolVariants: SymbolVariants
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// The layout direction associated with the current environment.
///
/// Use this value to determine or set whether the environment uses a
/// left-to-right or right-to-left direction.
public var layoutDirection: LayoutDirection
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// A binding to the current presentation mode of the view associated with
/// this environment.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use isPresented or dismiss")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use isPresented or dismiss")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use isPresented or dismiss")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use isPresented or dismiss")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use isPresented or dismiss")
public var presentationMode: Binding<PresentationMode> { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// A refresh action stored in a view's environment.
///
/// When this environment value contains an instance of the
/// ``RefreshAction`` structure, certain built-in views in the corresponding
/// ``Environment`` begin offering a refresh capability. They apply the
/// instance's handler to any refresh operation that the user initiates.
/// By default, the environment value is `nil`, but you can use the
/// ``View/refreshable(action:)`` modifier to create and store a new
/// refresh action that uses the handler that you specify:
///
///     List(mailbox.conversations) { conversation in
///         ConversationCell(conversation)
///     }
///     .refreshable {
///         await mailbox.fetch()
///     }
///
/// On iOS and iPadOS, the ``List`` in the example above offers a
/// pull to refresh gesture because it detects the refresh action. When
/// the user drags the list down and releases, the list calls the action's
/// handler. Because SwiftUI declares the handler as asynchronous, it can
/// safely make long-running asynchronous calls, like fetching network data.
///
/// ### Refreshing custom views
///
/// You can also offer refresh capability in your custom views.
/// Read the `refresh` environment value to get the ``RefreshAction``
/// instance for a given ``Environment``. If you find
/// a non-`nil` value, change your view's appearance or behavior to offer
/// the refresh to the user, and call the instance to conduct the
/// refresh. You can call the refresh instance directly because it defines
/// a ``RefreshAction/callAsFunction()`` method that Swift calls
/// when you call the instance:
///
///     struct RefreshableView: View {
///         @Environment(\.refresh) private var refresh
///
///         var body: some View {
///             Button("Refresh") {
///                 Task {
///                     await refresh?()
///                 }
///             }
///             .disabled(refresh == nil)
///         }
///     }
///
/// Be sure to call the handler asynchronously by preceding it
/// with `await`. Because the call is asynchronous, you can use
/// its lifetime to indicate progress to the user. For example,
/// you can reveal an indeterminate ``ProgressView`` before
/// calling the handler, and hide it when the handler completes.
///
/// If your code isn't already in an asynchronous context, create a
/// <doc://com.apple.documentation/documentation/Swift/Task> for the
/// method to run in. If you do this, consider adding a way for the
/// user to cancel the task. For more information, see
/// [Concurrency](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html)
/// in *The Swift Programming Language*.
public var refresh: RefreshAction? { get }
}
@available(iOS 17.0, tvOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// A Boolean value that indicates whether the view associated with this
/// environment allows hover effects to be displayed.
///
/// The default value is `true`.
public var isHoverEffectEnabled: Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EnvironmentValues {
/// The current size of sidebar rows.
///
/// On macOS, reflects the value of the "Sidebar icon size" in
/// System Settings' Appearance settings.
///
/// This can be used to update the content shown in the sidebar in
/// response to this size. And it can be overridden to force a sidebar to a
/// particularly size, regardless of the user preference.
///
/// On other platforms, the value is always `.medium` and setting a
/// different value has no effect.
///
/// SwiftUI views like `Label` automatically adapt to the sidebar row size.
public var sidebarRowSize: SidebarRowSize
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// The default font of this environment.
public var font: Font?
/// The display scale of this environment.
public var displayScale: CGFloat
/// The image scale for this environment.
@available(macOS 11.0, *)
public var imageScale: Image.Scale
/// The size of a pixel on the screen.
///
/// This value is usually equal to `1` divided by
/// ``EnvironmentValues/displayScale``.
public var pixelLength: CGFloat { get }
/// The font weight to apply to text.
///
/// This value reflects the value of the Bold Text display setting found in
/// the Accessibility settings.
public var legibilityWeight: LegibilityWeight?
/// The current locale that views should use.
public var locale: Locale
/// The current calendar that views should use when handling dates.
public var calendar: Calendar
/// The current time zone that views should use when handling dates.
public var timeZone: TimeZone
}
extension EnvironmentValues {
/// The horizontal size class of this environment.
///
/// You receive a ``UserInterfaceSizeClass`` value when you read this
/// environment value. The value tells you about the amount of horizontal
/// space available to the view that reads it. You can read this
/// size class like any other of the ``EnvironmentValues``, by creating a
/// property with the ``Environment`` property wrapper:
///
///     @Environment(\.horizontalSizeClass) private var horizontalSizeClass
///
/// SwiftUI sets this size class based on several factors, including:
///
/// * The current device type.
/// * The orientation of the device.
/// * The appearance of Slide Over and Split View on iPad.
///
/// Several built-in views change their behavior based on this size class.
/// For example, a ``NavigationView`` presents a multicolumn view when
/// the horizontal size class is ``UserInterfaceSizeClass/regular``,
/// but a single column otherwise. You can also adjust the appearance of
/// custom views by reading the size class and conditioning your views.
/// If you do, be prepared to handle size class changes while
/// your app runs, because factors like device orientation can change at
/// runtime.
///
/// In watchOS, the horizontal size class is always
/// ``UserInterfaceSizeClass/compact``. In macOS, and tvOS, it's always
/// ``UserInterfaceSizeClass/regular``.
///
/// Writing to the horizontal size class in the environment
/// before macOS 14.0, tvOS 17.0, and watchOS 10.0 is not supported.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@_backDeploy(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
public var horizontalSizeClass: UserInterfaceSizeClass?
/// The vertical size class of this environment.
///
/// You receive a ``UserInterfaceSizeClass`` value when you read this
/// environment value. The value tells you about the amount of vertical
/// space available to the view that reads it. You can read this
/// size class like any other of the ``EnvironmentValues``, by creating a
/// property with the ``Environment`` property wrapper:
///
///     @Environment(\.verticalSizeClass) private var verticalSizeClass
///
/// SwiftUI sets this size class based on several factors, including:
///
/// * The current device type.
/// * The orientation of the device.
///
/// You can adjust the appearance of custom views by reading this size
/// class and conditioning your views. If you do, be prepared to
/// handle size class changes while your app runs, because factors like
/// device orientation can change at runtime.
///
/// In watchOS, the vertical size class is always
/// ``UserInterfaceSizeClass/compact``. In macOS, and tvOS, it's always
/// ``UserInterfaceSizeClass/regular``.
///
/// Writing to the vertical size class in the environment
/// before macOS 14.0, tvOS 17.0, and watchOS 10.0 is not supported.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@_backDeploy(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
public var verticalSizeClass: UserInterfaceSizeClass?
}
extension EnvironmentValues {
/// Reads an observable object of the specified type from the environment.
///
/// - Important: This subscript only supports reading objects that conform
///   to the `Observable` protocol.
///
/// Use this subscript to read the environment object of a specific type
/// from an instance of ``EnvironmentValues``, such as when accessing the
/// ``GraphicsContext/environment`` property of a graphics context:
///
///     @Observable final class Profile { ... }
///
///     Canvas { context, size in
///         let currentProfile = context.environment[Profile.self]
///         ...
///     }
///
/// - Parameter objectType: The type of the `Observable` object to read
///   from the environment.
///
/// - Returns: The environment object of the specified type, or `nil` if no
///   object of that type has been set in this environment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public subscript<T>(objectType: T.Type) -> T? where T : AnyObject, T : Observable
}
extension EnvironmentValues {
/// The maximum number of lines that text can occupy in a view.
///
/// The maximum number of lines is `1` if the value is less than `1`. If the
/// value is `nil`, the text uses as many lines as required. The default is
/// `nil`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public var lineLimit: Int?
}
extension EnvironmentValues {
/// The visiblity to apply to scroll indicators of any
/// vertically scrollable content.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var verticalScrollIndicatorVisibility: ScrollIndicatorVisibility
/// The visibility to apply to scroll indicators of any
/// horizontally scrollable content.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var horizontalScrollIndicatorVisibility: ScrollIndicatorVisibility
}
extension EnvironmentValues {
/// A Boolean value that indicates whether any scroll views associated
/// with this environment allow scrolling to occur.
///
/// The default value is `true`. Use the ``View/scrollDisabled(_:)``
/// modifier to configure this property.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var isScrollEnabled: Bool
}
extension EnvironmentValues {
/// The way that scrollable content interacts with the software keyboard.
///
/// The default value is ``ScrollDismissesKeyboardMode/automatic``. Use the
/// ``View/scrollDismissesKeyboard(_:)`` modifier to configure this
/// property.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@available(visionOS, unavailable)
public var scrollDismissesKeyboardMode: ScrollDismissesKeyboardMode
}
extension EnvironmentValues {
/// The scroll bounce mode for the vertical axis of scrollable views.
///
/// Use the ``View/scrollBounceBehavior(_:axes:)`` view modifier to set this
/// value in the ``Environment``.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public var verticalScrollBounceBehavior: ScrollBounceBehavior
/// The scroll bounce mode for the horizontal axis of scrollable views.
///
/// Use the ``View/scrollBounceBehavior(_:axes:)`` view modifier to set this
/// value in the ``Environment``.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public var horizontalScrollBounceBehavior: ScrollBounceBehavior
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates when the user is searching.
///
/// You can read this value like any of the other ``EnvironmentValues``,
/// by creating a property with the ``Environment`` property wrapper:
///
///     @Environment(\.isSearching) private var isSearching
///
/// Get the value to find out when the user interacts with a search
/// field that's produced by one of the searchable modifiers, like
/// ``View/searchable(text:placement:prompt:)-18a8f``:
///
///     struct SearchingExample: View {
///         @State private var searchText = ""
///
///         var body: some View {
///             NavigationStack {
///                 SearchedView()
///                     .searchable(text: $searchText)
///             }
///         }
///     }
///
///     struct SearchedView: View {
///         @Environment(\.isSearching) private var isSearching
///
///         var body: some View {
///             Text(isSearching ? "Searching!" : "Not searching.")
///         }
///     }
///
/// When the user first taps or clicks in a search field, the
/// `isSearching` property becomes `true`. When the user cancels the
/// search operation, the property becomes `false`. To programmatically
/// set the value to `false` and dismiss the search operation, use
/// ``EnvironmentValues/dismissSearch``.
///
/// > Important: Access the value from inside the searched view, as the
///   example above demonstrates, rather than from the searched view’s
///   parent. SwiftUI sets the value in the environment of the view that
///   you apply the searchable modifier to, and doesn’t propagate the
///   value up the view hierarchy.
public var isSearching: Bool { get }
/// An action that ends the current search interaction.
///
/// Use this environment value to get the ``DismissSearchAction`` instance
/// for the current ``Environment``. Then call the instance to dismiss
/// the current search interaction. You call the instance directly because
/// it defines a ``DismissSearchAction/callAsFunction()`` method that Swift
/// calls when you call the instance.
///
/// When you dismiss search, SwiftUI:
///
/// * Sets ``EnvironmentValues/isSearching`` to `false`.
/// * Clears any text from the search field.
/// * Removes focus from the search field.
///
/// > Note: Calling this instance has no effect if the user isn't
/// interacting with a search field.
///
/// Use this action to dismiss a search operation based on
/// another user interaction. For example, consider a searchable
/// view with a ``Button`` that presents more information about the first
/// matching item from a collection:
///
///     struct ContentView: View {
///         @State private var searchText = ""
///
///         var body: some View {
///             NavigationStack {
///                 SearchedView(searchText: searchText)
///                     .searchable(text: $searchText)
///             }
///         }
///     }
///
///     private struct SearchedView: View {
///         let searchText: String
///
///         let items = ["a", "b", "c"]
///         var filteredItems: [String] { items.filter { $0 == searchText.lowercased() } }
///
///         @State private var isPresented = false
///         @Environment(\.dismissSearch) private var dismissSearch
///
///         var body: some View {
///             if let item = filteredItems.first {
///                 Button("Details about \(item)") {
///                     isPresented = true
///                 }
///                 .sheet(isPresented: $isPresented) {
///                     NavigationStack {
///                         DetailView(item: item, dismissSearch: dismissSearch)
///                     }
///                 }
///             }
///         }
///     }
///
/// The button becomes visible only after the user enters search text
/// that produces a match. When the user taps the button, SwiftUI shows
/// a sheet that provides more information about the item, including
/// an Add button for adding the item to a stored list of items:
///
///     private struct DetailView: View {
///         var item: String
///         var dismissSearch: DismissSearchAction
///
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Text("Information about \(item).")
///                 .toolbar {
///                     Button("Add") {
///                         // Store the item here...
///
///                         dismiss()
///                         dismissSearch()
///                     }
///                 }
///         }
///     }
///
/// People can dismiss the sheet by dragging it down, effectively
/// canceling the operation, leaving the in-progress search interaction
/// intact. Alternatively, people can tap the Add button to store the item.
/// Because the person using your app is likely to be done with both the
/// detail view and the search interaction at this point, the button's
/// closure also uses the ``EnvironmentValues/dismiss`` property to dismiss
/// the sheet, and the ``EnvironmentValues/dismissSearch`` property to
/// reset the search field.
///
/// > Important: Access the action from inside the searched view, as the
///   example above demonstrates, rather than from the searched view’s
///   parent, or another hierarchy, like that of a sheet. SwiftUI sets the
///   value in the environment of the view that you apply the searchable
///   modifier to, and doesn’t propagate the value up the view hierarchy.
public var dismissSearch: DismissSearchAction { get }
/// The current placement of search suggestions.
///
/// Search suggestions render based on the platform and surrounding context
/// in which you place the searchable modifier containing suggestions.
/// You can render search suggestions in two ways:
///
/// * In a menu attached to the search field.
/// * Inline with the main content of the app.
///
/// You find the current search suggestion placement by querying the
/// ``EnvironmentValues/searchSuggestionsPlacement`` in your
/// search suggestions.
///
///     enum FruitSuggestion: String, Identifiable {
///         case apple, banana, orange
///         var id: Self { self }
///     }
///
///     @State private var text: String = ""
///     @State private var suggestions: [FruitSuggestion] = []
///
///     var body: some View {
///         MainContent()
///             .searchable(text: $text) {
///                 FruitSuggestions(suggestions: suggestions)
///             }
///     }
///
///     struct FruitSuggestions: View {
///         var suggestions: [FruitSuggestion]
///
///         @Environment(\.searchSuggestionsPlacement)
///         private var placement
///
///         var body: some View {
///             if shouldRender {
///                 ForEach(suggestions) { suggestion in
///                     Text(suggestion.rawValue.capitalized)
///                         .searchCompletion(suggestion.rawValue)
///                 }
///             }
///         }
///
///         var shouldRender: Bool {
///             #if os(iOS)
///             placement == .menu
///             #else
///             true
///             #endif
///         }
///     }
///
/// In the above example, search suggestions only render in iOS
/// if the searchable modifier displays them in a menu. You might want
/// to do this to render suggestions in your own list alongside
/// your own search results when they would render in a list.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var searchSuggestionsPlacement: SearchSuggestionsPlacement { get }
}
extension EnvironmentValues {
/// The configuration of a document in a ``DocumentGroup``.
///
/// The value is `nil` for views that are not enclosed in a ``DocumentGroup``.
///
/// For example, if the app shows the document path in the footer
/// of each document, it can get the URL from the environment:
///
///     struct ContentView: View {
///         @Binding var document: TextDocument
///         @Environment(\.documentConfiguration) private var configuration: DocumentConfiguration?
///
///         var body: some View {
///             …
///             Label(
///                 configuration?.fileURL?.path ??
///                     "", systemImage: "folder.circle"
///             )
///         }
///     }
///
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public var documentConfiguration: DocumentConfiguration? { get }
}
extension EnvironmentValues {
/// The undo manager used to register a view's undo operations.
///
/// This value is `nil` when the environment represents a context that
/// doesn't support undo and redo operations. You can skip registration of
/// an undo operation when this value is `nil`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public var undoManager: UndoManager? { get }
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// An indication of whether the user can edit the contents of a view
/// associated with this environment.
///
/// Read this environment value to receive a optional binding to the
/// edit mode state. The binding contains an ``EditMode`` value
/// that indicates whether edit mode is active, and that you can use to
/// change the mode. To learn how to read an environment
/// value, see ``EnvironmentValues``.
///
/// Certain built-in views automatically alter their appearance and behavior
/// in edit mode. For example, a ``List`` with a ``ForEach`` that's
/// configured with the ``DynamicViewContent/onDelete(perform:)`` or
/// ``DynamicViewContent/onMove(perform:)`` modifier provides controls to
/// delete or move list items while in edit mode. On devices without an
/// attached keyboard and mouse or trackpad, people can make multiple
/// selections in lists only when edit mode is active.
///
/// You can also customize your own views to react to edit mode.
/// The following example replaces a read-only ``Text`` view with
/// an editable ``TextField``, checking for edit mode by
/// testing the wrapped value's ``EditMode/isEditing`` property:
///
///     @Environment(\.editMode) private var editMode
///     @State private var name = "Maria Ruiz"
///
///     var body: some View {
///         Form {
///             if editMode?.wrappedValue.isEditing == true {
///                 TextField("Name", text: $name)
///             } else {
///                 Text(name)
///             }
///         }
///         .animation(nil, value: editMode?.wrappedValue)
///         .toolbar { // Assumes embedding this view in a NavigationView.
///             EditButton()
///         }
///     }
///
/// You can set the edit mode through the binding, or you can
/// rely on an ``EditButton`` to do that for you, as the example above
/// demonstrates. The button activates edit mode when the user
/// taps the Edit button, and disables editing mode when the user taps Done.
@available(macOS, unavailable)
@available(watchOS, unavailable)
public var editMode: Binding<EditMode>?
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// The current Dynamic Type size.
///
/// This value changes as the user's chosen Dynamic Type size changes. The
/// default value is device-dependent.
///
/// When limiting the Dynamic Type size, consider if adding a
/// large content view with ``View/accessibilityShowsLargeContentViewer()``
/// would be appropriate.
///
/// On macOS, this value cannot be changed by users and does not affect the
/// text size.
public var dynamicTypeSize: DynamicTypeSize
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the user has enabled an assistive
/// technology.
public var accessibilityEnabled: Bool
}
extension EnvironmentValues {
/// A Boolean that indicates whether the quick actions feature is enabled.
///
/// The system uses quick actions to provide users with a
/// fast alternative interaction method. Quick actions can be
/// presented to users with a textual banner at the top of their
/// screen and/or an outline around a view that is already on screen.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var accessibilityQuickActionsEnabled: Bool { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 8.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the display or environment currently requires
/// reduced luminance.
///
/// When you detect this condition, lower the overall brightness of your view.
/// For example, you can change large, filled shapes to be stroked, and choose
/// less bright colors:
///
///     @Environment(\.isLuminanceReduced) var isLuminanceReduced
///
///     var body: some View {
///         if isLuminanceReduced {
///             Circle()
///                 .stroke(Color.gray, lineWidth: 10)
///         } else {
///             Circle()
///                 .fill(Color.white)
///         }
///     }
///
/// In addition to the changes that you make, the system could also
/// dim the display to achieve a suitable brightness. By reacting to
/// `isLuminanceReduced`, you can preserve contrast and readability
/// while helping to satisfy the reduced brightness requirement.
///
/// > Note: On watchOS, the system typically sets this value to `true` when the user
/// lowers their wrist, but the display remains on. Starting in watchOS 8, the system keeps your
/// view visible on wrist down by default. If you want the system to blur the screen
/// instead, as it did in earlier versions of watchOS, set the value for the
/// <doc://com.apple.documentation/documentation/BundleResources/Information_Property_List/WKSupportsAlwaysOnDisplay>
/// key in your app's
/// <doc://com.apple.documentation/documentation/BundleResources/Information_Property_List>
/// file to `false`.
public var isLuminanceReduced: Bool
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// The menu indicator visibility to apply to controls within a view.
///
/// - Note: On tvOS, the standard button styles do not include a menu
///         indicator, so this modifier will have no effect when using a
///         built-in button style. You can implement an indicator in your
///         own ``ButtonStyle`` implementation by checking the value of this
///         environment value.
public var menuIndicatorVisibility: Visibility
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension EnvironmentValues {
/// The current method of animating the contents of views.
public var contentTransition: ContentTransition
/// A Boolean value that controls whether views that render content
/// transitions use GPU-accelerated rendering.
///
/// Setting this value to `true` causes SwiftUI to wrap content transitions
/// with a ``View/drawingGroup(opaque:colorMode:)`` modifier.
public var contentTransitionAddsDrawingGroup: Bool
}
@available(iOS 15.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension EnvironmentValues {
/// The size to apply to controls within a view.
///
/// The default is ``ControlSize/regular``.
@available(tvOS, unavailable)
public var controlSize: ControlSize
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// The keyboard shortcut that buttons in this environment will be triggered
/// with.
///
/// This is particularly useful in button styles when a button's appearance
/// depends on the shortcut associated with it. On macOS, for example, when
/// a button is bound to the Return key, it is typically drawn with a
/// special emphasis. This happens automatically when using the built-in
/// button styles, and can be implemented manually in custom styles using
/// this environment key:
///
///     private struct MyButtonStyle: ButtonStyle {
///         @Environment(\.keyboardShortcut)
///         private var shortcut: KeyboardShortcut?
///
///         func makeBody(configuration: Configuration) -> some View {
///             let labelFont = Font.body
///                 .weight(shortcut == .defaultAction ? .bold : .regular)
///             configuration.label
///                 .font(labelFont)
///         }
///     }
///
/// If no keyboard shortcut has been applied to the view or its ancestor,
/// then the environment value will be `nil`.
public var keyboardShortcut: KeyboardShortcut? { get }
}
extension EnvironmentValues {
/// A Boolean value that determines whether the view hierarchy has
/// auto-correction enabled.
///
/// The default value is `false`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 8.0, *)
public var autocorrectionDisabled: Bool
}
extension EnvironmentValues {
/// A Boolean value that determines whether the view hierarchy has
/// auto-correction enabled.
///
/// When the value is `nil`, SwiftUI uses the system default. The default
/// value is `nil`.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "autocorrectionDisabled")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "autocorrectionDisabled")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "autocorrectionDisabled")
@available(watchOS, introduced: 8.0, deprecated: 100000.0, renamed: "autocorrectionDisabled")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "autocorrectionDisabled")
public var disableAutocorrection: Bool?
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
public var managedObjectContext: NSManagedObjectContext
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension EnvironmentValues {
/// Whether buttons with this associated environment should repeatedly
/// trigger their actions on prolonged interactions.
///
/// A value of `enabled` means that buttons will be able to repeatedly
/// trigger their action, and `disabled` means they should not. A value of
/// `automatic` means that buttons will defer to default behavior.
public var buttonRepeatBehavior: ButtonRepeatBehavior { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the view associated with this
/// environment allows focus effects to be displayed.
///
/// The default value is `true`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var isFocusEffectEnabled: Bool
}
extension EnvironmentValues {
/// Returns whether the nearest focusable ancestor has focus.
///
/// If there is no focusable ancestor, the value is `false`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public var isFocused: Bool { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// The current symbol rendering mode, or `nil` denoting that the
/// mode is picked automatically using the current image and
/// foreground style as parameters.
public var symbolRenderingMode: SymbolRenderingMode?
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension EnvironmentValues {
/// A window dismissal action stored in a view's environment.
///
/// Use the `dismissWindow` environment value to get an
/// ``DismissWindowAction`` instance for a given ``Environment``. Then call
/// the instance to dismiss a window. You call the instance directly because
/// it defines a ``DismissWindowAction/callAsFunction(id:)`` method that
/// Swift calls when you call the instance.
///
/// For example, you can define a button that dismisses an auxiliary window:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///             }
///             #if os(macOS)
///             Window("Auxiliary", id: "auxiliary") {
///                 AuxiliaryContentView()
///             }
///             #endif
///         }
///     }
///
///     struct DismissWindowButton: View {
///         @Environment(\.dismissWindow) private var dismissWindow
///
///         var body: some View {
///             Button("Close Auxiliary Window") {
///                 dismissWindow(id: "auxiliary")
///             }
///         }
///     }
public var dismissWindow: DismissWindowAction { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension EnvironmentValues {
/// The material underneath the current view.
///
/// This value is `nil` if the current background isn't one of the standard
/// materials. If you set a material, the standard content styles enable
/// their vibrant rendering modes.
///
/// You set this value by calling one of the background modifiers that takes
/// a ``ShapeStyle``, like ``View/background(_:ignoresSafeAreaEdges:)``
/// or ``View/background(_:in:fillStyle:)-89n7j``, and passing in a
/// ``Material``. You can also set the value manually, using
/// `nil` to disable vibrant rendering, or a ``Material`` instance to
/// enable the vibrancy style associated with the specified material.
public var backgroundMaterial: Material?
}
extension EnvironmentValues {
/// An action that activates the standard rename interaction.
///
/// Use the ``View/renameAction(_:)-6lghl`` modifier to configure the rename
/// action in the environment.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var rename: RenameAction? { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
extension EnvironmentValues {
/// The prominence to apply to badges associated with this environment.
///
/// The default is ``BadgeProminence/standard``.
public var badgeProminence: BadgeProminence
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EnvironmentValues {
/// A Boolean value that indicates whether the view associated with this
/// environment allows user interaction.
///
/// The default value is `true`.
public var isEnabled: Bool
}
/// A modifier that must resolve to a concrete modifier in an environment before
/// use.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol EnvironmentalModifier : ViewModifier where Self.Body == Never {
/// The type of modifier to use after being resolved.
associatedtype ResolvedModifier : ViewModifier
/// Resolve to a concrete modifier in the given `environment`.
func resolve(in environment: EnvironmentValues) -> Self.ResolvedModifier
}
/// A view type that compares itself against its previous value and prevents its
/// child updating if its new value is the same as its old value.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EquatableView<Content> : View where Content : Equatable, Content : View {
public var content: Content
@inlinable public init(content: Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A set of key modifiers that you can add to a gesture.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct EventModifiers : OptionSet {
/// The raw value.
public let rawValue: Int
/// Creates a new set from a raw value.
///
/// - Parameter rawValue: The raw value with which to create the key
///   modifier.
public init(rawValue: Int)
/// The Caps Lock key.
public static let capsLock: EventModifiers
/// The Shift key.
public static let shift: EventModifiers
/// The Control key.
public static let control: EventModifiers
/// The Option key.
public static let option: EventModifiers
/// The Command key.
public static let command: EventModifiers
/// Any key on the numeric keypad.
public static let numericPad: EventModifiers
/// The Function key.
@available(iOS, deprecated: 15.0, message: "Function modifier is reserved for system applications")
@available(macOS, deprecated: 12.0, message: "Function modifier is reserved for system applications")
@available(tvOS, deprecated: 15.0, message: "Function modifier is reserved for system applications")
@available(watchOS, deprecated: 8.0, message: "Function modifier is reserved for system applications")
@available(visionOS, deprecated: 1.0, message: "Function modifier is reserved for system applications")
public static let function: EventModifiers
/// All possible modifier keys.
public static let all: EventModifiers
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = EventModifiers
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = EventModifiers
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension EventModifiers : Sendable {
}
/// A schedule for updating a timeline view at the start of every minute.
///
/// You can also use ``TimelineSchedule/everyMinute`` to construct this
/// schedule.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct EveryMinuteTimelineSchedule : TimelineSchedule, Sendable {
/// The sequence of dates in an every minute schedule.
///
/// The ``EveryMinuteTimelineSchedule/entries(from:mode:)`` method returns
/// a value of this type, which is a
/// <doc://com.apple.documentation/documentation/Swift/Sequence>
/// of dates, one per minute, in ascending order. A ``TimelineView`` that
/// you create updates its content at the moments in time corresponding to
/// the dates included in the sequence.
public struct Entries : Sequence, IteratorProtocol, Sendable {
/// Advances to the next element and returns it, or `nil` if no next element
/// exists.
///
/// Repeatedly calling this method returns, in order, all the elements of the
/// underlying sequence. As soon as the sequence has run out of elements, all
/// subsequent calls return `nil`.
///
/// You must not call this method if any other copy of this iterator has been
/// advanced with a call to its `next()` method.
///
/// The following example shows how an iterator can be used explicitly to
/// emulate a `for`-`in` loop. First, retrieve a sequence's iterator, and
/// then call the iterator's `next()` method until it returns `nil`.
///
///     let numbers = [2, 3, 5, 7]
///     var numbersIterator = numbers.makeIterator()
///
///     while let num = numbersIterator.next() {
///         print(num)
///     }
///     // Prints "2"
///     // Prints "3"
///     // Prints "5"
///     // Prints "7"
///
/// - Returns: The next element in the underlying sequence, if a next element
///   exists; otherwise, `nil`.
public mutating func next() -> Date?
/// A type representing the sequence's elements.
public typealias Element = Date
/// A type that provides the sequence's iteration interface and
/// encapsulates its iteration state.
public typealias Iterator = EveryMinuteTimelineSchedule.Entries
}
/// Creates a per-minute update schedule.
///
/// Use the ``EveryMinuteTimelineSchedule/entries(from:mode:)`` method
/// to get the sequence of dates.
public init()
/// Provides a sequence of per-minute dates starting from a given date.
///
/// A ``TimelineView`` that you create with an every minute schedule
/// calls this method to ask the schedule when to update its content.
/// The method returns a sequence of per-minute dates in increasing
/// order, from earliest to latest, that represents
/// when the timeline view updates.
///
/// For a `startDate` that's exactly minute-aligned, the
/// schedule's sequence of dates starts at that time. Otherwise, it
/// starts at the beginning of the specified minute. For
/// example, for start dates of both `10:09:32` and `10:09:00`, the first
/// entry in the sequence is `10:09:00`.
///
/// - Parameters:
///   - startDate: The date from which the sequence begins.
///   - mode: The mode for the update schedule.
/// - Returns: A sequence of per-minute dates in ascending order.
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> EveryMinuteTimelineSchedule.Entries
}
/// A gesture that consists of two gestures where only one of them can succeed.
///
/// The `ExclusiveGesture` gives precedence to its first gesture.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ExclusiveGesture<First, Second> : Gesture where First : Gesture, Second : Gesture {
/// The value of an exclusive gesture that indicates which of two gestures
/// succeeded.
@frozen public enum Value {
/// The first of two gestures succeeded.
case first(First.Value)
/// The second of two gestures succeeded.
case second(Second.Value)
}
/// The first of two gestures.
public var first: First
/// The second of two gestures.
public var second: Second
/// Creates a gesture from two gestures where only one of them succeeds.
///
/// - Parameters:
///   - first: The first of two gestures. This gesture has precedence over
///     the other gesture.
///   - second: The second of two gestures.
@inlinable public init(_ first: First, _ second: Second)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ExclusiveGesture.Value : Sendable where First.Value : Sendable, Second.Value : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ExclusiveGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ExclusiveGesture<First, Second>.Value, b: ExclusiveGesture<First, Second>.Value) -> Bool
}
/// A schedule for updating a timeline view at explicit points in time.
///
/// You can also use ``TimelineSchedule/explicit(_:)`` to construct this
/// schedule.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct ExplicitTimelineSchedule<Entries> : TimelineSchedule where Entries : Sequence, Entries.Element == Date {
/// Creates a schedule composed of an explicit sequence of dates.
///
/// Use the ``ExplicitTimelineSchedule/entries(from:mode:)`` method
/// to get the sequence of dates.
///
/// - Parameter dates: The sequence of dates at which a timeline view
///   updates. Use a monotonically increasing sequence of dates,
///   and ensure that at least one is in the future.
public init(_ dates: Entries)
/// Provides the sequence of dates with which you initialized the schedule.
///
/// A ``TimelineView`` that you create with a schedule calls this
/// ``TimelineSchedule`` method to ask the schedule when to update its
/// content. The explicit timeline schedule implementation
/// of this method returns the unmodified sequence of dates that you
/// provided when you created the schedule with
/// ``TimelineSchedule/explicit(_:)``. As a result, this particular
/// implementation ignores the `startDate` and `mode` parameters.
///
/// - Parameters:
///   - startDate: The date from which the sequence begins. This
///     particular implementation of the protocol method ignores the start
///     date.
///   - mode: The mode for the update schedule. This particular
///     implementation of the protocol method ignores the mode.
/// - Returns: The sequence of dates that you provided at initialization.
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> Entries
}
/// A property wrapper type that retrieves entities from a Core Data persistent
/// store.
///
/// Use a `FetchRequest` property wrapper to declare a ``FetchedResults``
/// property that provides a collection of Core Data managed objects to a
/// SwiftUI view. The request infers the entity type from the `Result`
/// placeholder type that you specify. Condition the request with an optional
/// predicate and sort descriptors. For example, you can create a request to
/// list all `Quake` managed objects that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data, sorted by their
/// `time` property:
///
///     @FetchRequest(sortDescriptors: [SortDescriptor(\.time, order: .reverse)])
///     private var quakes: FetchedResults<Quake> // Define Quake in your model.
///
/// Alternatively, when you need more flexibility, you can initialize the
/// request with a configured
/// <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
/// instance:
///
///     @FetchRequest(fetchRequest: request)
///     private var quakes: FetchedResults<Quake>
///
/// Always declare properties that have a fetch request wrapper as private.
/// This lets the compiler help you avoid accidentally setting
/// the property from the memberwise initializer of the enclosing view.
///
/// The fetch request and its results use the managed object context stored
/// in the environment, which you can access using the
/// ``EnvironmentValues/managedObjectContext`` environment value. To
/// support user interface activity, you typically rely on the
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer/1640622-viewContext>
/// property of a shared
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer>
/// instance. For example, you can set a context on your top level content
/// view using a shared container that you define as part of your model:
///
///     ContentView()
///         .environment(
///             \.managedObjectContext,
///             QuakesProvider.shared.container.viewContext)
///
/// When you need to dynamically change the predicate or sort descriptors,
/// access the request's ``FetchRequest/Configuration`` structure.
/// To create a request that groups the fetched results according to a
/// characteristic that they share, use ``SectionedFetchRequest`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@MainActor @propertyWrapper public struct FetchRequest<Result> where Result : NSFetchRequestResult {
/// The fetched results of the fetch request.
///
/// SwiftUI returns the value associated with this property
/// when you use ``FetchRequest`` as a property wrapper, and then access
/// the wrapped property by name. For example, consider the following
/// `quakes` property declaration that fetches a `Quake` type that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines:
///
///     @FetchRequest(fetchRequest: request)
///     private var quakes: FetchedResults<Quake>
///
/// You access the request's `wrappedValue`, which contains a
/// ``FetchedResults`` instance, by referring to the `quakes` property
/// by name:
///
///     Text("Found \(quakes.count) earthquakes")
///
/// If you need to separate the request and the result
/// entities, you can declare `quakes` in two steps by
/// using the request's `wrappedValue` to obtain the results:
///
///     var fetchRequest = FetchRequest<Quake>(fetchRequest: request)
///     var quakes: FetchedResults<Quake> { fetchRequest.wrappedValue }
///
/// The `wrappedValue` property returns an empty array when there are no
/// fetched results --- for example, because no entities satisfy the
/// predicate, or because the data store is empty.
@MainActor public var wrappedValue: FetchedResults<Result> { get }
/// The request's configurable properties.
///
/// You initialize a ``FetchRequest`` with an optional predicate and
/// sort descriptors, either explicitly or using a configured
/// <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>.
/// Later, you can dynamically update the predicate and sort
/// parameters using the request's configuration structure.
///
/// You access or bind to a request's configuration components through
/// properties on the associated ``FetchedResults`` instance.
///
/// ### Configure using a binding
///
/// Get a ``Binding`` to a fetch request's configuration structure
/// by accessing the request's ``FetchRequest/projectedValue``, which you
/// do by using the dollar sign (`$`) prefix on the associated
/// results property. For example, you can create a request for `Quake`
/// entities --- a managed object type that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines --- that initially sorts the results by time:
///
///     @FetchRequest(sortDescriptors: [SortDescriptor(\.time, order: .reverse)])
///     private var quakes: FetchedResults<Quake>
///
/// Then you can bind the request's sort descriptors,
/// which you access through the `quakes` result, to those
/// of a ``Table`` instance:
///
///     Table(quakes, sortOrder: $quakes.sortDescriptors) {
///         TableColumn("Place", value: \.place)
///         TableColumn("Time", value: \.time) { quake in
///             Text(quake.time, style: .time)
///         }
///     }
///
/// A user who clicks on a table column header initiates the following
/// sequence of events:
/// 1. The table updates the sort descriptors through the binding.
/// 2. The modified sort descriptors reconfigure the request.
/// 3. The reconfigured request fetches new results.
/// 4. SwiftUI redraws the table in response to new results.
///
/// ### Set configuration directly
///
/// If you need to access the fetch request's configuration elements
/// directly, use the ``FetchedResults/nsPredicate`` and
/// ``FetchedResults/sortDescriptors`` or
/// ``FetchedResults/nsSortDescriptors`` properties of the
/// ``FetchedResults`` instance. Continuing the example above, to
/// enable the user to dynamically update the predicate, declare a
/// ``State`` property to hold a query string:
///
///     @State private var query = ""
///
/// Then add an ``View/onChange(of:perform:)`` modifier to the ``Table``
/// that sets a new predicate any time the query changes:
///
///     .onChange(of: query) { value in
///         quakes.nsPredicate = query.isEmpty
///             ? nil
///             : NSPredicate(format: "place CONTAINS %@", value)
///     }
///
/// To give the user control over the string, add a ``TextField`` in your
/// user interface that's bound to the `query` state:
///
///     TextField("Filter", text: $query)
///
/// When the user types into the text field, the predicate updates,
/// the request fetches new results, and SwiftUI redraws the table.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct Configuration {
/// The request's sort descriptors, accessed as reference types.
///
/// Set this configuration value to cause a ``FetchRequest`` to execute
/// a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances. If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances, set ``FetchRequest/Configuration/sortDescriptors``
/// instead.
///
/// Access this value of a ``FetchRequest/Configuration`` structure for
/// a given request by using the ``FetchedResults/nsSortDescriptors``
/// property on the associated ``FetchedResults`` instance, either
/// directly or through a ``Binding``.
public var nsSortDescriptors: [NSSortDescriptor]
/// The request's predicate.
///
/// Set this configuration value to cause a ``FetchRequest`` to execute
/// a fetch with a new predicate.
///
/// Access this value of a ``FetchRequest/Configuration`` structure for
/// a given request by using the ``FetchedResults/nsPredicate``
/// property on the associated ``FetchedResults`` instance, either
/// directly or through a ``Binding``.
public var nsPredicate: NSPredicate?
}
/// A binding to the request's mutable configuration properties.
///
/// SwiftUI returns the value associated with this property when you use
/// ``FetchRequest`` as a property wrapper on a ``FetchedResults`` instance,
/// and then access the results with a dollar sign (`$`) prefix. The value
/// that SwiftUI returns is a ``Binding`` to the request's
/// ``FetchRequest/Configuration`` structure, which dynamically
/// configures the request.
///
/// For example, consider the following fetch request for a type that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data, sorted based on
/// the `time` property:
///
///     @FetchRequest(sortDescriptors: [SortDescriptor(\.time, order: .reverse)])
///     private var quakes: FetchedResults<Quake>
///
/// You can use the projected value to enable a ``Table`` instance to make
/// updates:
///
///     Table(quakes, sortOrder: $quakes.sortDescriptors) {
///         TableColumn("Place", value: \.place)
///         TableColumn("Time", value: \.time) { quake in
///             Text(quake.time, style: .time)
///         }
///     }
///
/// Because you initialize the table using a binding to the descriptors,
/// the table can modify the sort in response to actions that the user
/// takes, like clicking a column header.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@MainActor public var projectedValue: Binding<FetchRequest<Result>.Configuration> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension FetchRequest : DynamicProperty {
/// Updates the fetched results.
///
/// SwiftUI calls this function before rendering a view's
/// ``View/body-swift.property`` to ensure the view has the most recent
/// fetched results.
@MainActor public mutating func update()
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension FetchRequest {
/// Creates a fetch request for a specified entity description, based on a
/// predicate and sort parameters.
///
/// Use this initializer if you need to explicitly specify the entity type
/// for the request. If you specify a placeholder `Result` type in the
/// request declaration, use the
/// ``init(sortDescriptors:predicate:animation:)-4obxy`` initializer to
/// let the request infer the entity type. If you need more control over
/// the fetch request configuration, use ``init(fetchRequest:animation:)``.
///
/// - Parameters:
///   - entity: The description of the Core Data entity to fetch.
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(entity: NSEntityDescription, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil)
/// Creates a fully configured fetch request that uses the specified
/// animation when updating results.
///
/// Use this initializer when you want to configure a fetch
/// request with more than a predicate and sort descriptors.
/// For example, you can vend a request from a `Quake` managed object
/// that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data.
/// Limit the number of results to `1000` by setting a
/// <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest/1506622-fetchLimit>
/// for the request:
///
///     extension Quake {
///         var request: NSFetchRequest<Quake> {
///             let request = NSFetchRequest<Quake>(entityName: "Quake")
///             request.sortDescriptors = [
///                 NSSortDescriptor(
///                     keyPath: \Quake.time,
///                     ascending: true)]
///             request.fetchLimit = 1000
///             return request
///         }
///     }
///
/// Use the request to define a ``FetchedResults`` property:
///
///     @FetchRequest(fetchRequest: Quake.request)
///     private var quakes: FetchedResults<Quake>
///
/// If you only need to configure the request's predicate and sort
/// descriptors, use ``init(sortDescriptors:predicate:animation:)-462jp``
/// instead. If you need to specify a ``Transaction`` rather than an
/// optional ``Animation``, use ``init(fetchRequest:transaction:)``.
///
/// - Parameters:
///   - fetchRequest: An
///     <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
///     instance that describes the search criteria for retrieving data
///     from the persistent store.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(fetchRequest: NSFetchRequest<Result>, animation: Animation? = nil)
/// Creates a fully configured fetch request that uses the specified
/// transaction when updating results.
///
/// Use this initializer if you need a fetch request with updates that
/// affect the user interface based on a ``Transaction``. Otherwise, use
/// ``init(fetchRequest:animation:)``.
///
/// - Parameters:
///   - fetchRequest: An
///     <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
///     instance that describes the search criteria for retrieving data
///     from the persistent store.
///   - transaction: A transaction to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(fetchRequest: NSFetchRequest<Result>, transaction: Transaction)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension FetchRequest where Result : NSManagedObject {
/// Creates a fetch request based on a predicate and reference type sort
/// parameters.
///
/// The request gets the entity type from the `Result` instance by calling
/// that managed object's
/// <doc://com.apple.documentation/documentation/CoreData/NSManagedObject/1640588-entity>
/// type method. If you need to specify the entity type explicitly, use the
/// ``init(entity:sortDescriptors:predicate:animation:)`` initializer
/// instead. If you need more control over the fetch request configuration,
/// use ``init(fetchRequest:animation:)``. For value type sort
/// descriptors, use ``init(sortDescriptors:predicate:animation:)-462jp``.
///
/// - Parameters:
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension FetchRequest where Result : NSManagedObject {
/// Creates a fetch request based on a predicate and value type sort
/// parameters.
///
/// The request gets the entity type from the `Result` instance by calling
/// that managed object's
/// <doc://com.apple.documentation/documentation/CoreData/NSManagedObject/1640588-entity>
/// type method. If you need to specify the entity type explicitly, use the
/// ``init(entity:sortDescriptors:predicate:animation:)`` initializer
/// instead. If you need more control over the fetch request configuration,
/// use ``init(fetchRequest:animation:)``. For reference type sort
/// descriptors, use ``init(sortDescriptors:predicate:animation:)-4obxy``.
///
/// - Parameters:
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(sortDescriptors: [SortDescriptor<Result>], predicate: NSPredicate? = nil, animation: Animation? = nil)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension FetchRequest.Configuration where Result : NSManagedObject {
/// The request's sort descriptors, accessed as value types.
///
/// Set this configuration value to cause a ``FetchRequest`` to execute a
/// fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances. If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances, set ``FetchRequest/Configuration/nsSortDescriptors`` instead.
///
/// Access this value of a ``FetchRequest/Configuration`` structure for
/// a given request by using the ``FetchedResults/sortDescriptors``
/// property on the associated ``FetchedResults`` instance, either
/// directly or through a ``Binding``.
public var sortDescriptors: [SortDescriptor<Result>]
}
/// A collection of results retrieved from a Core Data store.
///
/// Use a `FetchedResults` instance to show or edit Core Data managed objects in
/// your app's user interface. You request a particular set of results by
/// specifying a `Result` type as the entity type, and annotating the fetched
/// results property declaration with a ``FetchRequest`` property wrapper.
/// For example, you can create a request to list all `Quake` managed objects
/// that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data, sorted by their
/// `time` property:
///
///     @FetchRequest(sortDescriptors: [SortDescriptor(\.time, order: .reverse)])
///     private var quakes: FetchedResults<Quake>
///
/// The results instance conforms to
/// <doc://com.apple.documentation/documentation/Swift/RandomAccessCollection>,
/// so you access it like any other collection. For example, you can create
/// a ``List`` that iterates over all the results:
///
///     List(quakes) { quake in
///         NavigationLink(destination: QuakeDetail(quake: quake)) {
///             QuakeRow(quake: quake)
///         }
///     }
///
/// When you need to dynamically change the request's predicate or sort
/// descriptors, set the result instance's ``nsPredicate`` and
/// ``sortDescriptors`` or ``nsSortDescriptors`` properties, respectively.
///
/// The fetch request and its results use the managed object context stored
/// in the environment, which you can access using the
/// ``EnvironmentValues/managedObjectContext`` environment value. To
/// support user interface activity, you typically rely on the
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer/1640622-viewContext>
/// property of a shared
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer>
/// instance. For example, you can set a context on your top level content
/// view using a container that you define as part of your model:
///
///     ContentView()
///         .environment(
///             \.managedObjectContext,
///             QuakesProvider.shared.container.viewContext)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct FetchedResults<Result> : RandomAccessCollection where Result : NSFetchRequestResult {
/// The request's sort descriptors, accessed as reference types.
///
/// Set this value to cause the associated ``FetchRequest`` to execute
/// a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances.
/// The order of managed objects stored in the results collection may change
/// as a result.
///
/// If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances, set ``FetchedResults/sortDescriptors`` instead.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public var nsSortDescriptors: [NSSortDescriptor] { get nonmutating set }
/// The request's predicate.
///
/// Set this value to cause the associated ``FetchRequest`` to execute a
/// fetch with a new predicate, producing an updated collection of results.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public var nsPredicate: NSPredicate? { get nonmutating set }
/// The index of the first entity in the results collection.
public var startIndex: Int { get }
/// The index that's one greater than the last valid subscript argument.
public var endIndex: Int { get }
/// Gets the entity at the specified index.
public subscript(position: Int) -> Result { get }
/// A type representing the sequence's elements.
public typealias Element = Result
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public typealias Index = Int
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = Range<Int>
/// A type that provides the collection's iteration interface and
/// encapsulates its iteration state.
///
/// By default, a collection conforms to the `Sequence` protocol by
/// supplying `IndexingIterator` as its associated `Iterator`
/// type.
public typealias Iterator = IndexingIterator<FetchedResults<Result>>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<FetchedResults<Result>>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension FetchedResults where Result : NSManagedObject {
/// The request's sort descriptors, accessed as value types.
///
/// Set this value to cause the associated ``FetchRequest`` to execute a
/// fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances.
/// The order of entities stored in the results collection may change
/// as a result.
///
/// If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances, set ``FetchedResults/nsSortDescriptors`` instead.
public var sortDescriptors: [SortDescriptor<Result>] { get nonmutating set }
}
/// The way that file dialogs present the file system.
///
/// Apply the options using the ``View/fileDialogBrowserOptions(_:)`` modifier.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct FileDialogBrowserOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int)
/// Allows enumerating packages contents in contrast to the default behavior
/// when packages are represented flatly, similar to files.
public static let enumeratePackages: FileDialogBrowserOptions
/// Displays the files that are hidden by default.
public static let includeHiddenFiles: FileDialogBrowserOptions
/// On iOS, configures the `fileExporter`, `fileImporter`,
/// or `fileMover` to show or hide file extensions.
/// Default behavior is to hide them.
/// On macOS, this option has no effect.
public static let displayFileExtensions: FileDialogBrowserOptions
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = FileDialogBrowserOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = FileDialogBrowserOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension FileDialogBrowserOptions : Sendable {
}
/// A type that you use to serialize documents to and from file.
///
/// To store a document as a value type --- like a structure --- create a type
/// that conforms to the `FileDocument` protocol and implement the
/// required methods and properties. Your implementation:
///
/// * Provides a list of the content types that the document can read from and
///   write to by defining ``readableContentTypes``. If the list of content
///   types that the document can write to is different from those that it reads
///   from, you can optionally also define ``writableContentTypes-2opfc``.
/// * Loads documents from file in the ``init(configuration:)`` initializer.
/// * Stores documents to file by serializing their content in the
///   ``fileWrapper(configuration:)`` method.
///
/// > Important: If you store your document as a reference type --- like a
///   class --- use ``ReferenceFileDocument`` instead.
///
/// Ensure that types that conform to this protocol are thread-safe.
/// In particular, SwiftUI calls the protocol's methods on a background
/// thread. Don't use that thread to perform user interface updates.
/// Use it only to serialize and deserialize the document data.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol FileDocument {
/// The file and data types that the document reads from.
///
/// Define this list to indicate the content types that your document can
/// read. By default, SwiftUI assumes that your document can also write
/// the same set of content types. If you need to indicate a different set
/// of types for writing files, define the ``writableContentTypes-2opfc``
/// property in addition to this property.
static var readableContentTypes: [UTType] { get }
/// The file types that the document supports saving or exporting to.
///
/// By default, SwiftUI assumes that your document reads and writes the
/// same set of content types. Only define this property if you need to
/// indicate a different set of types for writing files. Otherwise, the
/// default implementation of this property returns the list that you
/// specify in your implementation of ``readableContentTypes``.
static var writableContentTypes: [UTType] { get }
/// Creates a document and initializes it with the contents of a file.
///
/// SwiftUI calls this initializer when someone opens a file type
/// that matches one of those that your document type supports.
/// Use the ``FileDocumentReadConfiguration/file`` property of the
/// `configuration` input to get document's data. Deserialize the data,
/// and store it in your document's data structure:
///
///     init(configuration: ReadConfiguration) throws {
///         guard let data = configuration.file.regularFileContents
///         else { /* Throw an error. */ }
///         model = try JSONDecoder().decode(Model.self, from: data)
///     }
///
/// The above example assumes that you define `Model` to contain
/// the document's data, that `Model` conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// and that you store a `model` property of that type inside your document.
///
/// > Note: SwiftUI calls this method on a background thread. Don't
///   make user interface changes from that thread.
///
/// - Parameter configuration: Information about the file that you read
///   document data from.
init(configuration: Self.ReadConfiguration) throws
/// The configuration for reading document contents.
///
/// This type is an alias for ``FileDocumentReadConfiguration``, which
/// contains a content type and a file wrapper that you use to access the
/// contents of a document file. You get a value of this type as an input
/// to the ``init(configuration:)`` initializer. Use it to load a
/// document from a file.
typealias ReadConfiguration = FileDocumentReadConfiguration
/// Serializes a document snapshot to a file wrapper.
///
/// To store a document --- for example, in response to a Save command ---
/// SwiftUI calls this method. Use it to serialize the document's data and
/// create or modify a file wrapper with the serialized data:
///
///     func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
///         let data = try JSONEncoder().encode(model)
///         return FileWrapper(regularFileWithContents: data)
///     }
///
/// > Note: SwiftUI calls this method on a background thread. Don't
///   make user interface changes from that thread.
///
/// - Parameters:
///   - configuration: Information about a file that already exists for the
///     document, if any.
///
/// - Returns: The destination to serialize the document contents to. The
///   value can be a newly created
///   <doc://com.apple.documentation/documentation/Foundation/FileWrapper>
///   or an update of the one provided in the `configuration` input.
func fileWrapper(configuration: Self.WriteConfiguration) throws -> FileWrapper
/// The configuration for writing document contents.
///
/// This type is an alias for ``FileDocumentWriteConfiguration``, which
/// contains a content type and a file wrapper that you use to access the
/// contents of a document file, if one already exists. You get a value
/// of this type as an input to the ``fileWrapper(configuration:)``
/// method.
typealias WriteConfiguration = FileDocumentWriteConfiguration
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension FileDocument {
/// The file types that the document supports saving or exporting to.
///
/// By default, SwiftUI assumes that your document reads and writes the
/// same set of content types. Only define this property if you need to
/// indicate a different set of types for writing files. Otherwise, the
/// default implementation of this property returns the list that you
/// specify in your implementation of ``readableContentTypes``.
public static var writableContentTypes: [UTType] { get }
}
/// The properties of an open file document.
///
/// You receive an instance of this structure when you create a
/// ``DocumentGroup`` with a value file type. Use it to access the
/// document in your viewer or editor.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct FileDocumentConfiguration<Document> where Document : FileDocument {
/// The current document model.
///
/// Setting a new value marks the document as having changes for later
/// saving and registers an undo action to restore the model to its
/// previous value.
///
/// If ``isEditable`` is `false`, setting a new value has no effect
/// because the document is in viewing mode.
@Binding public var document: Document { get nonmutating set }
public var $document: Binding<Document> { get }
/// The URL of the open file document.
public var fileURL: URL?
/// A Boolean that indicates whether you can edit the document.
///
/// This value is `false` if the document is in viewing mode, or if the
/// file is not writable.
public var isEditable: Bool
}
/// The configuration for reading file contents.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct FileDocumentReadConfiguration {
/// The expected uniform type of the file contents.
public let contentType: UTType
/// The file wrapper containing the document content.
public let file: FileWrapper
}
/// The configuration for serializing file contents.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct FileDocumentWriteConfiguration {
/// The expected uniform type of the file contents.
public let contentType: UTType
/// The file wrapper containing the current document content.
/// `nil` if the document is unsaved.
public let existingFile: FileWrapper?
}
/// A shape style that displays one of the overlay fills.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct FillShapeStyle : ShapeStyle {
/// An overlay fill style for filling shapes.
///
/// This shape style is appropriate for items situated on top of an existing
/// background color. It incorporates transparency to allow the background
/// color to show through.
///
/// Use the primary version of this style to fill thin or small shapes, such
/// as the track of a slider.
/// Use the secondary version of this style to fill medium-size shapes, such
/// as the background of a switch.
/// Use the tertiary version of this style to fill large shapes, such as
/// input fields, search bars, or buttons.
/// Use the quaternary version of this style to fill large areas that
/// contain complex content, such as an expanded table cell.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A shape provider that fills its shape.
///
/// You do not create this type directly, it is the return type of `Shape.fill`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct FillShapeView<Content, Style, Background> : ShapeView where Content : Shape, Style : ShapeStyle, Background : View {
/// The shape that this type draws and provides for other drawing
/// operations.
public var shape: Content
/// The style that fills this view's shape.
public var style: Style
/// The fill style used when filling this view's shape.
public var fillStyle: FillStyle
/// The background shown beneath this view.
public var background: Background
/// Create a FillShapeView.
public init(shape: Content, style: Style, fillStyle: FillStyle, background: Background)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A style for rasterizing vector shapes.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct FillStyle : Equatable {
/// A Boolean value that indicates whether to use the even-odd rule when
/// rendering a shape.
///
/// When `isOEFilled` is `false`, the style uses the non-zero winding number
/// rule.
public var isEOFilled: Bool
/// A Boolean value that indicates whether to apply antialiasing to the
/// edges of a shape.
public var isAntialiased: Bool
/// Creates a new fill style with the specified settings.
///
/// - Parameters:
///   - eoFill: A Boolean value that indicates whether to use the even-odd
///     rule for rendering a shape. Pass `false` to use the non-zero winding
///     number rule instead.
///   - antialiased: A Boolean value that indicates whether to use
///     antialiasing when rendering the edges of a shape.
@inlinable public init(eoFill: Bool = false, antialiased: Bool = true)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: FillStyle, b: FillStyle) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension FillStyle : Sendable {
}
/// Values describe different focus interactions that a view can support.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct FocusInteractions : OptionSet, Sendable {
/// The view has a primary action that can be activated via focus gestures.
///
/// On macOS and iOS, focus-driven activation interactions are only possible
/// when all-controls keyboard navigation is enabled. On tvOS and watchOS,
/// focus-driven activation interactions are always possible.
public static let activate: FocusInteractions
/// The view captures input from non-spatial sources like a keyboard or
/// Digital Crown.
///
/// Views that support focus-driven editing interactions become focused when
/// the user taps or clicks on them, or when the user issues a focus
/// movement command.
public static let edit: FocusInteractions
/// The view supports whatever focus-driven interactions are commonly
/// expected for interactive content on the current platform.
public static var automatic: FocusInteractions { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = FocusInteractions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = FocusInteractions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
/// A property wrapper type that can read and write a value that SwiftUI updates
/// as the placement of focus within the scene changes.
///
/// Use this property wrapper in conjunction with ``View/focused(_:equals:)``
/// and ``View/focused(_:)`` to
/// describe views whose appearance and contents relate to the location of
/// focus in the scene. When focus enters the modified view, the wrapped value
/// of this property updates to match a given prototype value. Similarly, when
/// focus leaves, the wrapped value of this property resets to `nil`
/// or `false`. Setting the property's value programmatically has the reverse
/// effect, causing focus to move to the view associated with the
/// updated value.
///
/// In the following example of a simple login screen, when the user presses the
/// Sign In button and one of the fields is still empty, focus moves to that
/// field. Otherwise, the sign-in process proceeds.
///
///     struct LoginForm {
///         enum Field: Hashable {
///             case username
///             case password
///         }
///
///         @State private var username = ""
///         @State private var password = ""
///         @FocusState private var focusedField: Field?
///
///         var body: some View {
///             Form {
///                 TextField("Username", text: $username)
///                     .focused($focusedField, equals: .username)
///
///                 SecureField("Password", text: $password)
///                     .focused($focusedField, equals: .password)
///
///                 Button("Sign In") {
///                     if username.isEmpty {
///                         focusedField = .username
///                     } else if password.isEmpty {
///                         focusedField = .password
///                     } else {
///                         handleLogin(username, password)
///                     }
///                 }
///             }
///         }
///     }
///
/// To allow for cases where focus is completely absent from a view tree, the
/// wrapped value must be either an optional or a Boolean. Set the focus binding
/// to `false` or `nil` as appropriate to remove focus from all bound fields.
/// You can also use this to remove focus from a ``TextField`` and thereby
/// dismiss the keyboard.
///
/// ### Avoid ambiguous focus bindings
///
/// The same view can have multiple focus bindings. In the following example,
/// setting `focusedField` to either `name` or `fullName` causes the field
/// to receive focus:
///
///     struct ContentView: View {
///         enum Field: Hashable {
///             case name
///             case fullName
///         }
///         @FocusState private var focusedField: Field?
///
///         var body: some View {
///             TextField("Full Name", ...)
///                 .focused($focusedField, equals: .name)
///                 .focused($focusedField, equals: .fullName)
///         }
///     }
///
/// On the other hand, binding the same value to two views is ambiguous. In
/// the following example, two separate fields bind focus to the `name` value:
///
///     struct ContentView: View {
///         enum Field: Hashable {
///             case name
///             case fullName
///         }
///         @FocusState private var focusedField: Field?
///
///         var body: some View {
///             TextField("Name", ...)
///                 .focused($focusedField, equals: .name)
///             TextField("Full Name", ...)
///                 .focused($focusedField, equals: .name) // incorrect re-use of .name
///         }
///     }
///
/// If the user moves focus to either field, the `focusedField` binding updates
/// to `name`. However, if the app programmatically sets the value to `name`,
/// SwiftUI chooses the first candidate, which in this case is the "Name"
/// field. SwiftUI also emits a runtime warning in this case, since the repeated
/// binding is likely a programmer error.
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen @propertyWrapper public struct FocusState<Value> : DynamicProperty where Value : Hashable {
/// A property wrapper type that can read and write a value that indicates
/// the current focus location.
@frozen @propertyWrapper public struct Binding {
/// The underlying value referenced by the bound property.
public var wrappedValue: Value { get nonmutating set }
/// A projection of the binding value that returns a binding.
///
/// Use the projected value to pass a binding value down a view
/// hierarchy.
public var projectedValue: FocusState<Value>.Binding { get }
}
/// The current state value, taking into account whatever bindings might be
/// in effect due to the current location of focus.
///
/// When focus is not in any view that is bound to this state, the wrapped
/// value will be `nil` (for optional-typed state) or `false` (for `Bool`-
/// typed state).
public var wrappedValue: Value { get nonmutating set }
/// A projection of the focus state value that returns a binding.
///
/// When focus is outside any view that is bound to this state, the wrapped
/// value is `nil` for optional-typed state or `false` for Boolean state.
///
/// In the following example of a simple navigation sidebar, when the user
/// presses the Filter Sidebar Contents button, focus moves to the sidebar's
/// filter text field. Conversely, if the user moves focus to the sidebar's
/// filter manually, then the value of `isFiltering` automatically
/// becomes `true`, and the sidebar view updates.
///
///     struct Sidebar: View {
///         @State private var filterText = ""
///         @FocusState private var isFiltering: Bool
///
///         var body: some View {
///             VStack {
///                 Button("Filter Sidebar Contents") {
///                     isFiltering = true
///                 }
///
///                 TextField("Filter", text: $filterText)
///                     .focused($isFiltering)
///             }
///         }
///     }
public var projectedValue: FocusState<Value>.Binding { get }
/// Creates a focus state that binds to a Boolean.
public init() where Value == Bool
/// Creates a focus state that binds to an optional type.
public init<T>() where Value == T?, T : Hashable
}
/// A convenience property wrapper for observing and automatically unwrapping
/// state bindings from the focused view or one of its ancestors.
///
/// If multiple views publish bindings using the same key, the wrapped property
/// will reflect the value of the binding from the view closest to focus.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@propertyWrapper public struct FocusedBinding<Value> : DynamicProperty {
/// A new property wrapper for the given key path.
///
/// The value of the property wrapper is updated dynamically as focus
/// changes and different published bindings go in and out of scope.
///
/// - Parameter keyPath: The key path for the focus value to read.
public init(_ keyPath: KeyPath<FocusedValues, Binding<Value>?>)
/// The unwrapped value for the focus key given the current scope and state
/// of the focused view hierarchy.
@inlinable public var wrappedValue: Value? { get nonmutating set }
/// A binding to the optional value.
///
/// The unwrapped value is `nil` when no focused view hierarchy has
/// published a corresponding binding.
public var projectedValue: Binding<Value?> { get }
}
/// A property wrapper type for an observable object supplied by the focused
/// view or one of its ancestors.
///
/// Focused objects invalidate the current view whenever the observable object
/// changes. If multiple views publish a focused object using the same key, the
/// wrapped property will reflect the object that's closest to the focused view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen @propertyWrapper public struct FocusedObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject {
/// A wrapper around the underlying focused object that can create bindings
/// to its properties using dynamic member lookup.
@dynamicMemberLookup @frozen public struct Wrapper {
/// Returns a binding to the value of a given key path.
///
/// - Parameter keyPath: A key path to a specific value on the
///   wrapped object.
/// - Returns: A new binding.
public subscript<T>(dynamicMember keyPath: ReferenceWritableKeyPath<ObjectType, T>) -> Binding<T> { get }
}
/// The underlying value referenced by the focused object.
///
/// This property provides primary access to the value's data. However, you
/// don't access `wrappedValue` directly. Instead, you use the property
/// variable created with the ``FocusedObject`` attribute.
///
/// When a mutable value changes, the new value is immediately available.
/// However, a view displaying the value is updated asynchronously and may
/// not show the new value immediately.
@MainActor @inlinable public var wrappedValue: ObjectType? { get }
/// A projection of the focused object that creates bindings to its
/// properties using dynamic member lookup.
///
/// Use the projected value to pass a focused object down a view hierarchy.
@MainActor public var projectedValue: FocusedObject<ObjectType>.Wrapper? { get }
/// Creates a focused object.
public init()
}
/// A property wrapper for observing values from the focused view or one of its
/// ancestors.
///
/// If multiple views publish values using the same key, the wrapped property
///  will reflect the value from the view closest to focus.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@propertyWrapper public struct FocusedValue<Value> : DynamicProperty {
/// A new property wrapper for the given key path.
///
/// The value of the property wrapper is updated dynamically as focus
/// changes and different published values go in and out of scope.
///
/// - Parameter keyPath: The key path for the focus value to read.
public init(_ keyPath: KeyPath<FocusedValues, Value?>)
/// The value for the focus key given the current scope and state of the
/// focused view hierarchy.
///
/// Returns `nil` when nothing in the focused view hierarchy exports a
/// value.
@inlinable public var wrappedValue: Value? { get }
}
extension FocusedValue {
/// A new property wrapper for the given object type.
///
/// Reads the focused value of the given object type.
///
/// - Important: This initializer only accepts objects conforming to the
///   `Observable` protocol. For reading environment objects that conform to
///   `ObservableObject`, use `FocusedObject`, instead.
///
/// To set the focused value that is read by this, use the `focusedValue(_:)` view modifier.
///
/// - Parameter objectType: The type of object to read the focus value for.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init(_ objectType: Value.Type) where Value : AnyObject, Value : Observable
}
/// A protocol for identifier types used when publishing and observing focused
/// values.
///
/// Unlike ``EnvironmentKey``, `FocusedValueKey` has no default value
/// requirement, because the default value for a key is always `nil`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol FocusedValueKey {
associatedtype Value
}
/// A collection of state exported by the focused view and its ancestors.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct FocusedValues {
/// Reads and writes values associated with a given focused value key.
public subscript<Key>(key: Key.Type) -> Key.Value? where Key : FocusedValueKey
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension FocusedValues : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: FocusedValues, rhs: FocusedValues) -> Bool
}
/// An environment-dependent font.
///
/// The system resolves a font's value at the time it uses the font in a given
/// environment because ``Font`` is a late-binding token.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Font : Hashable, Sendable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: Font, rhs: Font) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font {
/// Specifies a system font to use, along with the style, weight, and any
/// design parameters you want applied to the text.
///
/// Use this function to create a system font by specifying the size and
/// weight, and a type design together. The following styles the system font
/// as 17 point, ``Font/Weight/semibold`` text:
///
///     Text("Hello").font(.system(size: 17, weight: .semibold))
///
/// While the following styles the text as 17 point ``Font/Weight/bold``,
/// and applies a `serif` ``Font/Design`` to the system font:
///
///     Text("Hello").font(.system(size: 17, weight: .bold, design: .serif))
///
/// Both `weight` and `design` can be optional. When you do not provide a
/// `weight` or `design`, the system can pick one based on the current
/// context, which may not be ``Font/Weight/regular`` or
/// ``Font/Design/default`` in certain context. The following example styles
/// the text as 17 point system font using ``Font/Design/rounded`` design,
/// while its weight can depend on the current context:
///
///     Text("Hello").font(.system(size: 17, design: .rounded))
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func system(size: CGFloat, weight: Font.Weight? = nil, design: Font.Design? = nil) -> Font
/// Specifies a system font to use, along with the style, weight, and any
/// design parameters you want applied to the text.
///
/// Use this function to create a system font by specifying the size and
/// weight, and a type design together. The following styles the system font
/// as 17 point, ``Font/Weight/semibold`` text:
///
///     Text("Hello").font(.system(size: 17, weight: .semibold))
///
/// While the following styles the text as 17 point ``Font/Weight/bold``,
/// and applies a `serif` ``Font/Design`` to the system font:
///
///     Text("Hello").font(.system(size: 17, weight: .bold, design: .serif))
///
/// If you want to use the default ``Font/Weight``
/// (``Font/Weight/regular``), you don't need to specify the `weight` in the
/// method. The following example styles the text as 17 point
/// ``Font/Weight/regular``, and uses a ``Font/Design/rounded`` system font:
///
///     Text("Hello").font(.system(size: 17, design: .rounded))
///
/// This function has been deprecated, use the one with nullable `weight`
/// and `design` instead.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `system(size:weight:design:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `system(size:weight:design:)` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use `system(size:weight:design:)` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use `system(size:weight:design:)` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `system(size:weight:design:)` instead.")
public static func system(size: CGFloat, weight: Font.Weight = .regular, design: Font.Design = .default) -> Font
/// A design to use for fonts.
public enum Design : Hashable, Sendable {
case `default`
@available(watchOS 7.0, *)
case serif
case rounded
@available(watchOS 7.0, *)
case monospaced
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Font.Design, b: Font.Design) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font {
/// A font with the large title text style.
public static let largeTitle: Font
/// A font with the title text style.
public static let title: Font
/// Create a font for second level hierarchical headings.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static let title2: Font
/// Create a font for third level hierarchical headings.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static let title3: Font
/// A font with the headline text style.
public static let headline: Font
/// A font with the subheadline text style.
public static let subheadline: Font
/// A font with the body text style.
public static let body: Font
/// A font with the callout text style.
public static let callout: Font
/// A font with the footnote text style.
public static let footnote: Font
/// A font with the caption text style.
public static let caption: Font
/// Create a font with the alternate caption text style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static let caption2: Font
/// Gets a system font that uses the specified style, design, and weight.
///
/// Use this method to create a system font that has the specified
/// properties. The following example creates a system font with the
/// ``TextStyle/body`` text style, a ``Design/serif`` design, and
/// a ``Weight/bold`` weight, and applies the font to a ``Text`` view
/// using the ``View/font(_:)`` view modifier:
///
///     Text("Hello").font(.system(.body, design: .serif, weight: .bold))
///
/// The `design` and `weight` parameters are both optional. If you omit
/// either, the system uses a default value for that parameter. The
/// default values are typically ``Design/default`` and ``Weight/regular``,
/// respectively, but might vary depending on the context.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func system(_ style: Font.TextStyle, design: Font.Design? = nil, weight: Font.Weight? = nil) -> Font
/// Gets a system font with the given text style and design.
///
/// This function has been deprecated, use the one with nullable `design`
/// and `weight` instead.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `system(_:design:weight:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `system(_:design:weight:)` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use `system(_:design:weight:)` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use `system(_:design:weight:)` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `system(_:design:weight:)` instead.")
public static func system(_ style: Font.TextStyle, design: Font.Design = .default) -> Font
/// A dynamic text style to use for fonts.
public enum TextStyle : CaseIterable, Sendable {
/// The font style for large titles.
case largeTitle
/// The font used for first level hierarchical headings.
case title
/// The font used for second level hierarchical headings.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
case title2
/// The font used for third level hierarchical headings.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
case title3
/// The font used for headings.
case headline
/// The font used for subheadings.
case subheadline
/// The font used for body text.
case body
/// The font used for callouts.
case callout
/// The font used in footnotes.
case footnote
/// The font used for standard captions.
case caption
/// The font used for alternate captions.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
case caption2
/// A collection of all values of this type.
public static var allCases: [Font.TextStyle]
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Font.TextStyle, b: Font.TextStyle) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [Font.TextStyle]
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font {
/// Adds italics to the font.
public func italic() -> Font
/// Adjusts the font to enable all small capitals.
///
/// See ``Font/lowercaseSmallCaps()`` and ``Font/uppercaseSmallCaps()`` for
/// more details.
public func smallCaps() -> Font
/// Adjusts the font to enable lowercase small capitals.
///
/// This function turns lowercase characters into small capitals for the
/// font. It is generally used for display lines set in large and small
/// caps, such as titles. It may include forms related to small capitals,
/// such as old-style figures.
public func lowercaseSmallCaps() -> Font
/// Adjusts the font to enable uppercase small capitals.
///
/// This feature turns capital characters into small capitals. It is
/// generally used for words which would otherwise be set in all caps, such
/// as acronyms, but which are desired in small-cap form to avoid disrupting
/// the flow of text.
public func uppercaseSmallCaps() -> Font
/// Returns a modified font that uses fixed-width digits, while leaving
/// other characters proportionally spaced.
///
/// This modifier only affects numeric characters, and leaves all other
/// characters unchanged. If the base font doesn't support fixed-width,
/// or _monospace_ digits, the font remains unchanged.
///
/// The following example shows two text fields arranged in a ``VStack``.
/// Both text fields specify the 12-point system font, with the second
/// adding the `monospacedDigit()` modifier to the font. Because the text
/// includes the digit 1, normally a narrow character in proportional
/// fonts, the second text field becomes wider than the first.
///
///     @State private var userText = "Effect of monospacing digits: 111,111."
///
///     var body: some View {
///         VStack {
///             TextField("Proportional", text: $userText)
///                 .font(.system(size: 12))
///             TextField("Monospaced", text: $userText)
///                 .font(.system(size: 12).monospacedDigit())
///         }
///         .padding()
///         .navigationTitle(Text("Font + monospacedDigit()"))
///     }
///
/// ![A macOS window showing two text fields arranged vertically. Each
/// shows the text Effect of monospacing digits: 111,111. The even spacing
/// of the digit 1 in the second text field causes it to be noticably wider
/// than the first.](Environment-Font-monospacedDigit-1)
///
/// - Returns: A font that uses fixed-width numeric characters.
public func monospacedDigit() -> Font
/// Sets the weight of the font.
public func weight(_ weight: Font.Weight) -> Font
/// Sets the width of the font.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func width(_ width: Font.Width) -> Font
/// Adds bold styling to the font.
public func bold() -> Font
/// Returns a fixed-width font from the same family as the base font.
///
/// If there's no suitable font face in the same family, SwiftUI
/// returns a default fixed-width font.
///
/// The following example adds the `monospaced()` modifier to the default
/// system font, then applies this font to a ``Text`` view:
///
///     struct ContentView: View {
///         let myFont = Font
///             .system(size: 24)
///             .monospaced()
///
///         var body: some View {
///             Text("Hello, world!")
///                 .font(myFont)
///                 .padding()
///                 .navigationTitle("Monospaced")
///         }
///     }
///
///
/// ![A macOS window showing the text Hello, world in a 24-point
/// fixed-width font.](Environment-Font-monospaced-1)
///
/// SwiftUI may provide different fixed-width replacements for standard
/// user interface fonts (such as ``Font/title``, or a system font created
/// with ``Font/system(_:design:)``) than for those same fonts when created
/// by name with ``Font/custom(_:size:)``.
///
/// The ``View/font(_:)`` modifier applies the font to all text within
/// the view. To mix fixed-width text with other styles in the same
/// `Text` view, use the ``Text/init(_:)-1a4oh`` initializer to use an
/// appropropriately-styled
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString>
/// for the text view's content. You can use the
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString/3796160-init>
/// initializer to provide a Markdown-formatted string containing the
/// backtick-syntax (\`…\`) to apply code voice to specific ranges
/// of the attributed string.
///
/// - Returns: A fixed-width font from the same family as the base font,
/// if one is available, and a default fixed-width font otherwise.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func monospaced() -> Font
/// Adjusts the line spacing of a font.
///
/// You can change a font's line spacing while maintaining other
/// characteristics of the font by applying this modifier.
/// For example, you can decrease spacing of the ``body`` font by
/// applying the ``Leading/tight`` value to it:
///
///     let myFont = Font.body.leading(.tight)
///
/// The availability of leading adjustments depends on the font. For some
/// fonts, the modifier has no effect and returns the original font.
///
/// - Parameter leading: The line spacing adjustment to apply.
///
/// - Returns: A modified font that uses the specified line spacing, or
///   the original font if it doesn't support line spacing adjustments.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public func leading(_ leading: Font.Leading) -> Font
/// A weight to use for fonts.
@frozen public struct Weight : Hashable {
public static let ultraLight: Font.Weight
public static let thin: Font.Weight
public static let light: Font.Weight
public static let regular: Font.Weight
public static let medium: Font.Weight
public static let semibold: Font.Weight
public static let bold: Font.Weight
public static let heavy: Font.Weight
public static let black: Font.Weight
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Font.Weight, b: Font.Weight) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A width to use for fonts that have multiple widths.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct Width : Hashable, Sendable {
public var value: CGFloat
public static let compressed: Font.Width
public static let condensed: Font.Width
public static let standard: Font.Width
public static let expanded: Font.Width
public init(_ value: CGFloat)
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Font.Width, b: Font.Width) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A line spacing adjustment that you can apply to a font.
///
/// Apply one of the `Leading` values to a font using the
/// ``Font/leading(_:)`` method to increase or decrease the line spacing.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public enum Leading : Sendable {
/// The font's default line spacing.
///
/// If you modify a font to use a nonstandard line spacing like
/// ``tight`` or ``loose``, you can use this value to return to
/// the font's default line spacing.
case standard
/// Reduced line spacing.
///
/// This value typically reduces line spacing by 1 point for watchOS
/// and 2 points on other platforms.
case tight
/// Increased line spacing.
///
/// This value typically increases line spacing by 1 point for watchOS
/// and 2 points on other platforms.
case loose
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Font.Leading, b: Font.Leading) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font {
/// Create a custom font with the given `name` and `size` that scales with
/// the body text style.
public static func custom(_ name: String, size: CGFloat) -> Font
/// Create a custom font with the given `name` and `size` that scales
/// relative to the given `textStyle`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static func custom(_ name: String, size: CGFloat, relativeTo textStyle: Font.TextStyle) -> Font
/// Create a custom font with the given `name` and a fixed `size` that does
/// not scale with Dynamic Type.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static func custom(_ name: String, fixedSize: CGFloat) -> Font
/// Creates a custom font from a platform font instance.
///
/// Initializing ``Font`` with platform font instance
/// (<doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>) can bridge SwiftUI
/// ``Font`` with <doc://com.apple.documentation/documentation/AppKit/NSFont> or
/// <doc://com.apple.documentation/documentation/UIKit/UIFont>, both of which are
/// toll-free bridged to
/// <doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>. For example:
///
///     // Use native Core Text API to create desired ctFont.
///     let ctFont = CTFontCreateUIFontForLanguage(.system, 12, nil)!
///
///     // Create SwiftUI Text with the CTFont instance.
///     let text = Text("Hello").font(Font(ctFont))
public init(_ font: CTFont)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font.TextStyle : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font.TextStyle : Hashable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Font.Weight : Sendable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Font.Leading : Equatable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Font.Leading : Hashable {
}
/// A structure that computes views on demand from an underlying collection of
/// identified data.
///
/// Use `ForEach` to provide views based on a
/// <doc://com.apple.documentation/documentation/Swift/RandomAccessCollection>
/// of some data type. Either the collection's elements must conform to
/// <doc://com.apple.documentation/documentation/Swift/Identifiable> or you
/// need to provide an `id` parameter to the `ForEach` initializer.
///
/// The following example creates a `NamedFont` type that conforms to
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>, and an
/// array of this type called `namedFonts`. A `ForEach` instance iterates
/// over the array, producing new ``Text`` instances that display examples
/// of each SwiftUI ``Font`` style provided in the array.
///
///     private struct NamedFont: Identifiable {
///         let name: String
///         let font: Font
///         var id: String { name }
///     }
///
///     private let namedFonts: [NamedFont] = [
///         NamedFont(name: "Large Title", font: .largeTitle),
///         NamedFont(name: "Title", font: .title),
///         NamedFont(name: "Headline", font: .headline),
///         NamedFont(name: "Body", font: .body),
///         NamedFont(name: "Caption", font: .caption)
///     ]
///
///     var body: some View {
///         ForEach(namedFonts) { namedFont in
///             Text(namedFont.name)
///                 .font(namedFont.font)
///         }
///     }
///
/// ![A vertically arranged stack of labels showing various standard fonts,
/// such as Large Title and Headline.](SwiftUI-ForEach-fonts.png)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct ForEach<Data, ID, Content> where Data : RandomAccessCollection, ID : Hashable {
/// The collection of underlying identified data that SwiftUI uses to create
/// views dynamically.
public var data: Data
/// A function to create content on demand using the underlying data.
public var content: (Data.Element) -> Content
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ForEach {
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the identity of the underlying data.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity. If the `id` of a data element changes, the content view
/// generated from that data element loses any current state and animations.
///
/// When placed inside a `List` the edit actions (like delete or move)
/// can be automatically synthesized by specifying an appropriate
/// `EditActions`.
///
/// The following example shows a list of recipes whose elements can be
/// deleted and reordered:
///
///     List {
///         ForEach($recipes, editActions: [.delete, .move]) { $recipe in
///             RecipeCell($recipe)
///         }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// The following example shows a list of recipes whose elements can be
/// deleted only if they satisfy a condition:
///
///     List {
///         ForEach($recipes, editActions: .delete) { $recipe in
///             RecipeCell($recipe)
///                 .deleteDisabled(recipe.isFromMom)
///         }
///     }
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized actions.
/// Use this modifier if you need fine-grain control on how mutations are
/// applied to the data driving the `ForEach`. For example, if you need to
/// execute side effects or call into your existing model code.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically and can be edited by the user.
///   - editActions: The edit actions that are synthesized on `data`.
///   - content: The view builder that creates views dynamically.
public init<C, R>(_ data: Binding<C>, editActions: EditActions<C>, @ViewBuilder content: @escaping (Binding<C.Element>) -> R) where Data == IndexedIdentifierCollection<C, ID>, ID == C.Element.ID, Content == EditableCollectionContent<R, C>, C : MutableCollection, C : RandomAccessCollection, R : View, C.Element : Identifiable, C.Index : Hashable
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the identity of the underlying data.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity. If the `id` of a data element changes, the content view
/// generated from that data element loses any current state and animations.
///
/// When placed inside a `List` the edit actions (like delete or move)
/// can be automatically synthesized by specifying an appropriate
/// `EditActions`.
///
/// The following example shows a list of recipes whose elements can be
/// deleted and reordered:
///
///     List {
///         ForEach($recipes, editActions: [.delete, .move]) { $recipe in
///             RecipeCell($recipe)
///         }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// The following example shows a list of recipes whose elements can be
/// deleted only if they satisfy a condition:
///
///     List {
///         ForEach($recipes, editActions: .delete) { $recipe in
///             RecipeCell($recipe)
///                 .deleteDisabled(recipe.isFromMom)
///         }
///     }
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized actions.
/// Use this modifier if you need fine-grain control on how mutations are
/// applied to the data driving the `ForEach`. For example, if you need to
/// execute side effects or call into your existing model code.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically and can be edited by the user.
///   - id: The key path to the provided data's identifier.
///   - editActions: The edit actions that are synthesized on `data`.
///   - content: The view builder that creates views dynamically.
public init<C, R>(_ data: Binding<C>, id: KeyPath<C.Element, ID>, editActions: EditActions<C>, @ViewBuilder content: @escaping (Binding<C.Element>) -> R) where Data == IndexedIdentifierCollection<C, ID>, Content == EditableCollectionContent<R, C>, C : MutableCollection, C : RandomAccessCollection, R : View, C.Index : Hashable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach : DynamicViewContent where Content : View {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ForEach : AccessibilityRotorContent where Content : AccessibilityRotorContent {
/// The internal content of this `AccessibilityRotorContent`.
public var body: Never { get }
/// The type for the internal content of this `AccessibilityRotorContent`.
public typealias Body = Never
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ForEach where ID == Data.Element.ID, Content : AccessibilityRotorContent, Data.Element : Identifiable {
/// Creates an instance that generates Rotor content by combining, in order,
/// individual Rotor content for each element in the data given to this
/// `ForEach`.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically.
///   - content: The result builder that generates Rotor content for each
///     data element.
public init(_ data: Data, @AccessibilityRotorContentBuilder content: @escaping (Data.Element) -> Content)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ForEach where Content : AccessibilityRotorContent {
/// Creates an instance that generates Rotor content by combining, in order,
/// individual Rotor content for each element in the data given to this
/// `ForEach`.
///
/// It's important that the `id` of a data element doesn't change, unless
/// SwiftUI considers the data element to have been replaced with a new data
/// element that has a new identity.
///
/// - Parameters:
///   - data: The data that the ``ForEach`` instance uses to create views
///     dynamically.
///   - id: The key path to the provided data's identifier.
///   - content: The result builder that generates Rotor content for each
///     data element.
public init(_ data: Data, id: KeyPath<Data.Element, ID>, @AccessibilityRotorContentBuilder content: @escaping (Data.Element) -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach : View where Content : View {
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach where ID == Data.Element.ID, Content : View, Data.Element : Identifiable {
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the identity of the underlying data.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity. If the `id` of a data element changes, the content view
/// generated from that data element loses any current state and animations.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically.
///   - content: The view builder that creates views dynamically.
public init(_ data: Data, @ViewBuilder content: @escaping (Data.Element) -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach where Content : View {
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the provided key path to the underlying data's
/// identifier.
///
/// It's important that the `id` of a data element doesn't change, unless
/// SwiftUI considers the data element to have been replaced with a new data
/// element that has a new identity. If the `id` of a data element changes,
/// then the content view generated from that data element will lose any
/// current state and animations.
///
/// - Parameters:
///   - data: The data that the ``ForEach`` instance uses to create views
///     dynamically.
///   - id: The key path to the provided data's identifier.
///   - content: The view builder that creates views dynamically.
public init(_ data: Data, id: KeyPath<Data.Element, ID>, @ViewBuilder content: @escaping (Data.Element) -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach where Content : View {
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the identity of the underlying data.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity. If the `id` of a data element changes, the content view
/// generated from that data element loses any current state and animations.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically.
///   - content: The view builder that creates views dynamically.
public init<C>(_ data: Binding<C>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content) where Data == LazyMapSequence<C.Indices, (C.Index, ID)>, ID == C.Element.ID, C : MutableCollection, C : RandomAccessCollection, C.Element : Identifiable, C.Index : Hashable
/// Creates an instance that uniquely identifies and creates views across
/// updates based on the identity of the underlying data.
///
/// It's important that the `id` of a data element doesn't change unless you
/// replace the data element with a new data element that has a new
/// identity. If the `id` of a data element changes, the content view
/// generated from that data element loses any current state and animations.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create views dynamically.
///   - id: The key path to the provided data's identifier.
///   - content: The view builder that creates views dynamically.
public init<C>(_ data: Binding<C>, id: KeyPath<C.Element, ID>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content) where Data == LazyMapSequence<C.Indices, (C.Index, ID)>, C : MutableCollection, C : RandomAccessCollection, C.Index : Hashable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach where Data == Range<Int>, ID == Int, Content : View {
/// Creates an instance that computes views on demand over a given constant
/// range.
///
/// The instance only reads the initial value of the provided `data` and
/// doesn't need to identify views across updates. To compute views on
/// demand over a dynamic range, use ``ForEach/init(_:id:content:)``.
///
/// - Parameters:
///   - data: A constant range.
///   - content: The view builder that creates views dynamically.
public init(_ data: Range<Int>, @ViewBuilder content: @escaping (Int) -> Content)
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ForEach : TableRowContent where Content : TableRowContent {
/// The type of value represented by this table row content.
public typealias TableRowValue = Content.TableRowValue
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// Creates an instance that uniquely identifies and creates table rows
/// across updates based on the identity of the underlying data.
///
/// - Parameters:
///   - data: The identified data that the ``ForEach`` instance uses to
///     create table rows dynamically.
///   - content: The table row builder that creates rows dynamically.
public init<V>(_ data: Data, @TableRowBuilder<V> content: @escaping (Data.Element) -> Content) where ID == Data.Element.ID, V == Content.TableRowValue, Data.Element : Identifiable
/// Creates an instance that uniquely identifies and creates table rows
/// across updates based on the provided key path to the underlying data's
/// identifier.
///
/// - Parameters:
///   - data: The data that the ``ForEach`` instance uses to create table
///     rows dynamically.
///   - id: The key path to the provided data's identifier.
///   - content: The table row builder that creates rows dynamically.
public init<V>(_ data: Data, id: KeyPath<Data.Element, ID>, @TableRowBuilder<V> content: @escaping (Data.Element) -> Content) where V == Content.TableRowValue
/// Creates an instance that uniquely identifies and creates table rows
/// across updates based on the identity of the underlying data.
///
/// The following example creates a `Person` type that conforms to
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>, and an
/// array of this type called `people`. A `ForEach` instance iterates over
/// the array, producing new ``TableRow`` instances implicitly.
///
///     private struct Person: Identifiable {
///         var id = UUID()
///         var name: String
///     }
///
///     @State private var people: [Person] = /* ... */
///
///     Table(of: Person.self) {
///         TableColumn("ID", value: \.id.uuidString)
///         TableColumn("Name", value: \.name)
///     } rows: {
///         Section("Team") {
///             /* This is equivalent to the line below:
///             ForEach(people) { TableRow($0) }
///             */
///             ForEach(people)
///         }
///     }
///
/// - Parameter data: The identified data that the ``ForEach`` instance uses
///     to create table rows dynamically.
public init(_ data: Data) where ID == Data.Element.ID, Content == TableRow<Data.Element>, Data.Element : Identifiable
/// Creates an instance that computes table rows on demand over a given
/// constant range.
///
/// The instance only reads the initial value of the provided `data` and
/// doesn't need to identify rows across updates. To compute rows on
/// demand over a dynamic range, use ``ForEach/init(_:id:content:)``.
///
/// - Parameters:
///   - data: A constant range.
///   - content: The table row builder that creates rows dynamically.
public init<V>(_ data: Range<Int>, @TableRowBuilder<V> content: @escaping (Int) -> Content) where Data == Range<Int>, ID == Int, V == Content.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ForEach : DynamicTableRowContent where Content : TableRowContent {
}
/// The foreground style in the current context.
///
/// You can also use ``ShapeStyle/foreground`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ForegroundStyle : ShapeStyle {
/// Creates a foreground style instance.
@inlinable public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A container for grouping controls used for data entry, such as in settings
/// or inspectors.
///
/// SwiftUI applies platform-appropriate styling to views contained inside a
/// form, to group them together. Form-specific styling applies to
/// things like buttons, toggles, labels, lists, and more. Keep in mind that
/// these stylings may be platform-specific. For example, forms apppear as
/// grouped lists on iOS, and as aligned vertical stacks on macOS.
///
/// The following example shows a simple data entry form on iOS, grouped into
/// two sections. The supporting types (`NotifyMeAboutType` and
/// `ProfileImageSize`) and state variables (`notifyMeAbout`, `profileImageSize`,
/// `playNotificationSounds`, and `sendReadReceipts`) are omitted for
/// simplicity.
///
///     var body: some View {
///         NavigationView {
///             Form {
///                 Section(header: Text("Notifications")) {
///                     Picker("Notify Me About", selection: $notifyMeAbout) {
///                         Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
///                         Text("Mentions").tag(NotifyMeAboutType.mentions)
///                         Text("Anything").tag(NotifyMeAboutType.anything)
///                     }
///                     Toggle("Play notification sounds", isOn: $playNotificationSounds)
///                     Toggle("Send read receipts", isOn: $sendReadReceipts)
///                 }
///                 Section(header: Text("User Profiles")) {
///                     Picker("Profile Image Size", selection: $profileImageSize) {
///                         Text("Large").tag(ProfileImageSize.large)
///                         Text("Medium").tag(ProfileImageSize.medium)
///                         Text("Small").tag(ProfileImageSize.small)
///                     }
///                     Button("Clear Image Cache") {}
///                 }
///             }
///         }
///     }
///
///
/// ![A form on iOS, presented as a grouped list with two sections. The
/// first section is labeled Notifications and contains a navigation link with
/// the label Notify Me About and the current value Direct Messages. The section
/// also contains two toggles, Play Notification Sounds and Send Read Receipts,
/// the first of which is set to the on position. A second section named User
/// Profiles has a navigation link labeled Profile Image Size and the value
/// Medium, followed by a button labeled Clear Image
/// Cache.](SwiftUI-Form-iOS.png)
///
/// On macOS, a similar form renders as a vertical stack. To adhere to macOS
/// platform conventions, this version doesn't use sections, and uses colons at
/// the end of its labels. It also sets the picker to use
/// the ``PickerStyle/inline`` style, which produces radio buttons on macOS.
///
///     var body: some View {
///         Spacer()
///         HStack {
///             Spacer()
///             Form {
///                 Picker("Notify Me About:", selection: $notifyMeAbout) {
///                     Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
///                     Text("Mentions").tag(NotifyMeAboutType.mentions)
///                     Text("Anything").tag(NotifyMeAboutType.anything)
///                 }
///                 Toggle("Play notification sounds", isOn: $playNotificationSounds)
///                 Toggle("Send read receipts", isOn: $sendReadReceipts)
///
///                 Picker("Profile Image Size:", selection: $profileImageSize) {
///                     Text("Large").tag(ProfileImageSize.large)
///                     Text("Medium").tag(ProfileImageSize.medium)
///                     Text("Small").tag(ProfileImageSize.small)
///                 }
///                 .pickerStyle(.inline)
///
///                 Button("Clear Image Cache") {}
///             }
///             Spacer()
///         }
///         Spacer()
///     }
///
/// ![A form on iOS, presented as a vertical stack of views. At top, it shows
/// a pop-up menu with the label label Notify Me about and the current value
/// Direct Messages. Below this are two checkboxes, labeled Play Notification
/// Sounds and Send Read Receipts, the first of which is set on. Below this
/// is the label Profile Image Size with three radio buttons -- Large, Medium,
/// and Small -- with Medium currently selected. At the bottom of the form,
/// there is a button titled Clear Image Cache.](SwiftUI-Form-macOS.png)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Form<Content> : View where Content : View {
/// Creates a form with the provided content.
/// - Parameter content: A ``SwiftUI/ViewBuilder`` that provides the content for the
/// form.
public init(@ViewBuilder content: () -> Content)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Form where Content == FormStyleConfiguration.Content {
/// Creates a form based on a form style configuration.
///
/// - Parameter configuration: The properties of the form.
public init(_ configuration: FormStyleConfiguration)
}
/// The appearance and behavior of a form.
///
/// To configure the style for a single ``Form`` or for all form instances
/// in a view hierarchy, use the ``View/formStyle(_:)`` modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol FormStyle {
/// A view that represents the appearance and interaction of a form.
associatedtype Body : View
/// Creates a view that represents the body of a form.
///
/// - Parameter configuration: The properties of the form.
/// - Returns: A view that has behavior and appearance that enables it
///   to function as a ``Form``.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a form instance.
///
/// You receive a `configuration` parameter of this type --- which is an
/// alias for the ``FormStyleConfiguration`` type --- when you implement
/// the required ``makeBody(configuration:)`` method in a custom form
/// style implementation.
typealias Configuration = FormStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension FormStyle where Self == ColumnsFormStyle {
/// A non-scrolling form style with a trailing aligned column of labels
/// next to a leading aligned column of values.
public static var columns: ColumnsFormStyle { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension FormStyle where Self == GroupedFormStyle {
/// A form style with grouped rows.
///
/// Rows in a grouped rows form have leading aligned labels and trailing
/// aligned controls within visually grouped sections.
public static var grouped: GroupedFormStyle { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension FormStyle where Self == AutomaticFormStyle {
/// The default form style.
public static var automatic: AutomaticFormStyle { get }
}
/// The properties of a form instance.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct FormStyleConfiguration {
/// A type-erased content of a form.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that is the content of the form.
public let content: FormStyleConfiguration.Content
}
/// A view that shows a value within a range.
///
/// A gauge is a view that shows a current level of a value in relation
/// to a specified finite capacity, very much like a fuel gauge in an
/// automobile. Gauge displays are configurable; they can show
/// any combination of the gauge's current value, the range the gauge can
/// display, and a label describing the purpose of the gauge itself.
///
/// In its most basic form, a gauge displays a single value along the path of
/// the gauge mapped into a range from 0 to 100 percent. The example below sets
/// the gauge's indicator to a position 40 percent along the gauge's path:
///
///     struct SimpleGauge: View {
///         @State private var batteryLevel = 0.4
///
///         var body: some View {
///             Gauge(value: batteryLevel) {
///                 Text("Battery Level")
///             }
///         }
///     }
///
/// ![A linear gauge displaying a current value set to 40 percent in a range of 0
///  to 1.](SwiftUI-Gauge-ValueLabelLinear.png)
///
/// You can make a gauge more descriptive by describing its purpose, showing
/// its current value and its start and end values. This example shows the
/// gauge variant that accepts a range and adds labels using multiple
/// trailing closures describing the current value and the minimum
/// and maximum values of the gauge:
///
///     struct LabeledGauge: View {
///         @State private var current = 67.0
///         @State private var minValue = 0.0
///         @State private var maxValue = 170.0
///
///         var body: some View {
///             Gauge(value: current, in: minValue...maxValue) {
///                 Text("BPM")
///             } currentValueLabel: {
///                 Text("\(Int(current))")
///             } minimumValueLabel: {
///                 Text("\(Int(minValue))")
///             } maximumValueLabel: {
///                 Text("\(Int(maxValue))")
///             }
///         }
///     }
///
/// ![A linear gauge describing heart-rate in beats per minute with its
/// value set to 67 in a range of 0 to
/// 170.](SwiftUI-Gauge-Label-CurrentValueLinear.png)
///
/// As shown above, the default style for gauges is a linear, continuous bar
/// with an indicator showing the current value, and optional labels describing
/// the gauge's purpose, current, minimum, and maximum values.
///
/// > Note: Some visual presentations of `Gauge` don't display all the
///   labels required by the API. However, the accessibility system does use
///   the label content and you should use these labels to fully describe
///   the gauge for accessibility users.
///
/// To change the style of a gauge, use the ``View/gaugeStyle(_:)``
/// view modifier and supply an initializer for a specific gauge style. For
/// example, to display the same gauge in a circular style, apply the
/// ``GaugeStyle/circular`` style to the view:
///
///     struct LabeledGauge: View {
///         @State private var current = 67.0
///         @State private var minValue = 0.0
///         @State private var maxValue = 170.0
///
///         var body: some View {
///             Gauge(value: current, in: minValue...maxValue) {
///                 Text("BPM")
///             } currentValueLabel: {
///                 Text("\(Int(current))")
///             } minimumValueLabel: {
///                 Text("\(Int(minValue))")
///             } maximumValueLabel: {
///                 Text("\(Int(maxValue))")
///             }
///             .gaugeStyle(.circular)
///         }
///     }
///
/// ![A circular gauge describing heart rate in beats per minute with its
/// value set to 67 in a range of 0 to 170.](SwiftUI-Gauge-LabeledCircular.png)
///
/// To style elements of a gauge's presentation, you apply view modifiers to
/// the elements that you want to change. In the example below, the current
/// value, minimum and maximum value labels have custom colors:
///
///     struct StyledGauge: View {
///         @State private var current = 67.0
///         @State private var minValue = 50.0
///         @State private var maxValue = 170.0
///
///         var body: some View {
///             Gauge(value: current, in: minValue...maxValue) {
///                 Image(systemName: "heart.fill")
///                     .foregroundColor(.red)
///             } currentValueLabel: {
///                 Text("\(Int(current))")
///                     .foregroundColor(Color.green)
///             } minimumValueLabel: {
///                 Text("\(Int(minValue))")
///                     .foregroundColor(Color.green)
///             } maximumValueLabel: {
///                 Text("\(Int(maxValue))")
///                     .foregroundColor(Color.red)
///             }
///             .gaugeStyle(.circular)
///         }
///     }
///
/// ![A circular gauge describing heart rate in beats per minute with its
/// value set to 67 on a range of 0 to 170. The style of each label is
/// individually set showing custom label
/// colors.](SwiftUI-Gauge-CircularStyled.png)
///
/// You can further style a gauge's appearance by supplying a tint color or
/// a gradient to the style's initializer. The following example shows the
/// effect of a gradient in the initialization of a ``CircularGaugeStyle``
/// gauge with a colorful gradient across the length of the gauge:
///
///     struct StyledGauge: View {
///         @State private var current = 67.0
///         @State private var minValue = 50.0
///         @State private var maxValue = 170.0
///         let gradient = Gradient(colors: [.green, .yellow, .orange, .red])
///
///         var body: some View {
///             Gauge(value: current, in: minValue...maxValue) {
///                 Image(systemName: "heart.fill")
///                     .foregroundColor(.red)
///             } currentValueLabel: {
///                 Text("\(Int(current))")
///                     .foregroundColor(Color.green)
///             } minimumValueLabel: {
///                 Text("\(Int(minValue))")
///                     .foregroundColor(Color.green)
///             } maximumValueLabel: {
///                 Text("\(Int(maxValue))")
///                     .foregroundColor(Color.red)
///             }
///             .gaugeStyle(CircularGaugeStyle(tint: gradient))
///         }
///     }
/// ![A screenshot showing a circular gauge with a gradient
///  tint.](SwiftUI-Gauge-Circular-Gradient.png)
///
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
public struct Gauge<Label, CurrentValueLabel, BoundsLabel, MarkedValueLabels> : View where Label : View, CurrentValueLabel : View, BoundsLabel : View, MarkedValueLabels : View {
/// Creates a gauge showing a value within a range and describes the
/// gauge's purpose and current value.
///
/// Use this modifier to create a gauge that shows the value at its
/// relative position along the gauge and a label describing the gauge's
/// purpose. In the example below, the gauge has a range of `0...1`, the
/// indicator is set to `0.4`, or 40 percent of the distance along the
/// gauge:
///
///     struct SimpleGauge: View {
///         @State private var batteryLevel = 0.4
///
///         var body: some View {
///             Gauge(value: batteryLevel) {
///                 Text("Battery Level")
///             }
///         }
///     }
///
/// ![A linear gauge that shows an indicator at 40 percent along the length
/// of the gauge.](SwiftUI-Gauge-ValueLabelLinear.png)
///
/// - Parameters:
///     - value: The value to show in the gauge.
///     - bounds: The range of the valid values. Defaults to `0...1`.
///     - label: A view that describes the purpose of the gauge.
public init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label) where CurrentValueLabel == EmptyView, BoundsLabel == EmptyView, MarkedValueLabels == EmptyView, V : BinaryFloatingPoint
/// Creates a gauge showing a value within a range and that describes the
/// gauge's purpose and current value.
///
/// Use this method to create a gauge that displays a value within a range
/// you supply with labels that describe the purpose of the gauge and its
/// current value. In the example below, a gauge using the
/// ``GaugeStyle/circular`` style shows its current value of `67` along with a
/// label describing the (BPM) for the gauge:
///
///     struct SimpleGauge: View {
///         @State private var current = 67.0
///
///         var body: some View {
///             Gauge(value: currrent, in: 0...170) {
///                 Text("BPM")
///             } currentValueLabel: {
///                 Text("\(current)")
///             }
///             .gaugeStyle(.circular)
///        }
///     }
///
/// ![A screenshot showing a circular gauge describing heart rate in beats
/// per minute, with the indicator and the current value label indicating a
/// value of 67.](SwiftUI-Gauge-LabelCurrentValueCircular.png)
///
/// - Parameters:
///     - value: The value to show on the gauge.
///     - bounds: The range of the valid values. Defaults to `0...1`.
///     - label: A view that describes the purpose of the gauge.
///     - currentValueLabel: A view that describes the current value of
///       the gauge.
public init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel) where BoundsLabel == EmptyView, MarkedValueLabels == EmptyView, V : BinaryFloatingPoint
/// Creates a gauge showing a value within a range and describes the
/// gauge's current, minimum, and maximum values.
///
/// Use this method to create a gauge that shows a value within a
/// prescribed bounds. The gauge has labels that describe its purpose,
/// and for the gauge's current, minimum, and maximum values.
///
///     struct LabeledGauge: View {
///         @State private var current = 67.0
///         @State private var minValue = 0.0
///         @State private var maxValue = 170.0
///
///         var body: some View {
///             Gauge(value: current, in: minValue...maxValue) {
///                 Text("BPM")
///             } currentValueLabel: {
///                 Text("\(Int(current))")
///             } minimumValueLabel: {
///                 Text("\(Int(minValue))")
///             } maximumValueLabel: {
///                 Text("\(Int(maxValue))")
///             }
///         }
///     }
///
/// ![A screenshot of a gauge, labeled BPM, that's represented by a
/// semicircle showing its current value of 67 along a range of 0
/// to 170.](SwiftUI-Gauge-LabeledCircular.png)
///
/// - Parameters:
///     - value: The value to show on the gauge.
///     - bounds: The range of the valid values. Defaults to `0...1`.
///     - label: A view that describes the purpose of the gauge.
///     - currentValueLabel: A view that describes the current value of
///       the gauge.
///     - minimumValueLabel: A view that describes the lower bounds of the
///       gauge.
///     - maximumValueLabel: A view that describes the upper bounds of the
///       gauge.
public init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel, @ViewBuilder minimumValueLabel: () -> BoundsLabel, @ViewBuilder maximumValueLabel: () -> BoundsLabel) where MarkedValueLabels == EmptyView, V : BinaryFloatingPoint
/// Creates a gauge representing a value within a range.
///
/// - Parameters:
///     - value: The value to show in the instance.
///     - bounds: The range of the valid values. Defaults to `0...1`.
///     - label: A view that describes the purpose of the gauge.
///     - currentValueLabel: A view that describes the current value of
///       the gauge.
///     - minimumValueLabel: A view that describes the lower bounds of the
///       gauge.
///     - maximumValueLabel: A view that describes the upper bounds of the
///       gauge.
///     - markedValueLabels: A view builder containing tagged views,
///       each of which describes a particular value of the gauge.
///       The method ignores this parameter.
public init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel, @ViewBuilder markedValueLabels: () -> MarkedValueLabels) where BoundsLabel == EmptyView, V : BinaryFloatingPoint
/// Creates a gauge representing a value within a range.
///
/// - Parameters:
///     - value: The value to show in the gauge.
///     - bounds: The range of the valid values. Defaults to `0...1`.
///     - label: A view that describes the purpose of the gauge.
///     - currentValueLabel: A view that describes the current value of
///       the gauge.
///     - minimumValueLabel: A view that describes the lower bounds of the
///       gauge.
///     - maximumValueLabel: A view that describes the upper bounds of the
///       gauge.
///     - markedValueLabels: A view builder containing tagged views.
///       each of which describes a particular value of the gauge.
///       The method ignores this parameter.
public init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel, @ViewBuilder minimumValueLabel: () -> BoundsLabel, @ViewBuilder maximumValueLabel: () -> BoundsLabel, @ViewBuilder markedValueLabels: () -> MarkedValueLabels) where V : BinaryFloatingPoint
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// Defines the implementation of all gauge instances within a view
/// hierarchy.
///
/// To configure the style for all the ``Gauge`` instances in a view hierarchy,
/// use the ``View/gaugeStyle(_:)`` modifier. For example, you can configure
/// a gauge to use the ``circular`` style:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.circular)
///
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
public protocol GaugeStyle {
/// A view representing the body of a gauge.
associatedtype Body : View
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a gauge instance.
typealias Configuration = GaugeStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == AccessoryCircularCapacityGaugeStyle {
/// A gauge style that displays a closed ring that's partially filled in to
/// indicate the gauge's current value.
///
/// Apply this style to a ``Gauge`` or to a view hierarchy that contains
/// gauges using the ``View/gaugeStyle(_:)`` modifier:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.accessoryCircularCapacity)
///
/// This style displays the gauge's `currentValueLabel` value at the center
/// of the gauge.
public static var accessoryCircularCapacity: AccessoryCircularCapacityGaugeStyle { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == LinearCapacityGaugeStyle {
/// A gauge style that displays a bar that fills from leading to trailing
/// edges as the gauge's current value increases.
///
/// Apply this style to a ``Gauge`` or to a view hierarchy that contains
/// gauges using the ``View/gaugeStyle(_:)`` modifier:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.linearCapacity)
///
/// If you provide `minimumValueLabel` and `maximumValueLabel`
/// parameters when you create the gauge, they appear on leading and
/// trailing edges of the bar, respectively. The `label` appears above
/// the gauge, and the `currentValueLabel` appears below.
public static var linearCapacity: LinearCapacityGaugeStyle { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == AccessoryLinearGaugeStyle {
/// A gauge style that displays bar with a marker that appears at a
/// point along the bar to indicate the gauge's current value.
///
/// Apply this style to a ``Gauge`` or to a view hierarchy that contains
/// gauges using the ``View/gaugeStyle(_:)`` modifier:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.accessoryLinear)
///
/// If you provide `minimumValueLabel` and `maximumValueLabel`
/// parameters when you create the gauge, they appear on leading and
/// trailing edges of the bar, respectively. Otherwise, the gauge displays
/// the `currentValueLabel` value on the leading edge.
public static var accessoryLinear: AccessoryLinearGaugeStyle { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == AccessoryLinearCapacityGaugeStyle {
/// A gauge style that displays bar that fills from leading to trailing
/// edges as the gauge's current value increases.
///
/// Apply this style to a ``Gauge`` or to a view hierarchy that contains
/// gauges using the ``View/gaugeStyle(_:)`` modifier:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.accessoryLinearCapacity)
///
/// If you provide `minimumValueLabel` and `maximumValueLabel`
/// parameters when you create the gauge, they appear on leading and
/// trailing edges of the bar, respectively. The `label` appears above
/// the gauge, and the `currentValueLabel` appears below.
public static var accessoryLinearCapacity: AccessoryLinearCapacityGaugeStyle { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == DefaultGaugeStyle {
/// The default gauge view style in the current context of the view being
/// styled.
public static var automatic: DefaultGaugeStyle { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension GaugeStyle where Self == AccessoryCircularGaugeStyle {
/// A gauge style that displays an open ring with a marker that appears at a
/// point along the ring to indicate the gauge's current value.
///
/// Apply this style to a ``Gauge`` or to a view hierarchy that contains
/// gauges using the ``View/gaugeStyle(_:)`` modifier:
///
///     Gauge(value: batteryLevel, in: 0...100) {
///         Text("Battery Level")
///     }
///     .gaugeStyle(.accessoryCircular)
///
/// This style displays the gauge's `currentValueLabel` value at the center
/// of the gauge. If you provide `minimumValueLabel` and `maximumValueLabel`
/// parameters when you create the gauge, they appear in the opening at the
/// bottom of the ring. Otherwise, the gauge places its label in that
/// location.
public static var accessoryCircular: AccessoryCircularGaugeStyle { get }
}
/// The properties of a gauge instance.
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
public struct GaugeStyleConfiguration {
/// A type-erased label of a gauge, describing its purpose.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased value label of a gauge that contains the current value.
public struct CurrentValueLabel : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased value label of a gauge describing the minimum value.
public struct MinimumValueLabel : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased value label of a gauge describing the maximum value.
public struct MaximumValueLabel : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased label describing a specific value of a gauge.
public struct MarkedValueLabel : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The current value of the gauge.
///
/// The valid range is  `0.0...1.0`.
public var value: Double
/// A view that describes the purpose of the gauge.
public var label: GaugeStyleConfiguration.Label
/// A view that describes the current value.
public var currentValueLabel: GaugeStyleConfiguration.CurrentValueLabel?
/// A view that describes the minimum of the range for the current value.
public var minimumValueLabel: GaugeStyleConfiguration.MinimumValueLabel?
/// A view that describes the maximum of the range for the current value.
public var maximumValueLabel: GaugeStyleConfiguration.MaximumValueLabel?
}
/// An effect that changes the visual appearance of a view, largely without
/// changing its ancestors or descendants.
///
/// The only change the effect makes to the view's ancestors and descendants is
/// to change the coordinate transform to and from them.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol GeometryEffect : Animatable, ViewModifier where Self.Body == Never {
/// Returns the current value of the effect.
func effectValue(size: CGSize) -> ProjectionTransform
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension GeometryEffect {
/// Returns an effect that produces the same geometry transform as this
/// effect, but only applies the transform while rendering its view.
///
/// Use this method to disable layout changes during transitions. The view
/// ignores the transform returned by this method while the view is
/// performing its layout calculations.
@inlinable public func ignoredByLayout() -> _IgnoredByLayoutEffect<Self>
}
/// A proxy for access to the size and coordinate space (for anchor resolution)
/// of the container view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct GeometryProxy {
/// The size of the container view.
public var size: CGSize { get }
/// Resolves the value of `anchor` to the container view.
public subscript<T>(anchor: Anchor<T>) -> T { get }
/// The safe area inset of the container view.
public var safeAreaInsets: EdgeInsets { get }
/// Returns the container view's bounds rectangle, converted to a defined
/// coordinate space.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
public func frame(in coordinateSpace: CoordinateSpace) -> CGRect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension GeometryProxy {
/// Returns the given coordinate space's bounds rectangle, converted to the
/// local coordinate space.
public func bounds(of coordinateSpace: NamedCoordinateSpace) -> CGRect?
/// Returns the container view's bounds rectangle, converted to a defined
/// coordinate space.
public func frame(in coordinateSpace: some CoordinateSpaceProtocol) -> CGRect
}
/// A container view that defines its content as a function of its own size and
/// coordinate space.
///
/// This view returns a flexible preferred size to its parent layout.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct GeometryReader<Content> : View where Content : View {
public var content: (GeometryProxy) -> Content
@inlinable public init(@ViewBuilder content: @escaping (GeometryProxy) -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// An instance that matches a sequence of events to a gesture, and returns a
/// stream of values for each of its states.
///
/// Create custom gestures by declaring types that conform to the `Gesture`
/// protocol.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol Gesture<Value> {
/// The type representing the gesture's value.
associatedtype Value
/// The type of gesture representing the body of `Self`.
associatedtype Body : Gesture
/// The content and behavior of the gesture.
var body: Self.Body { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Sequences a gesture with another one to create a new gesture, which
/// results in the second gesture only receiving events after the first
/// gesture succeeds.
///
/// - Parameter other: A gesture you want to combine with another gesture to
///   create a new, sequenced gesture.
///
/// - Returns: A gesture that's a sequence of two gestures.
@inlinable public func sequenced<Other>(before other: Other) -> SequenceGesture<Self, Other> where Other : Gesture
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Updates the provided gesture state property as the gesture's value
/// changes.
///
/// Use this callback to update transient UI state as described in
/// <doc:Adding-Interactivity-with-Gestures>.
///
/// - Parameters:
///   - state: A binding to a view's ``GestureState`` property.
///   - body: The callback that SwiftUI invokes as the gesture's value
///     changes. Its `currentState` parameter is the updated state of the
///     gesture. The `gestureState` parameter is the previous state of the
///     gesture, and the `transaction` is the context of the gesture.
///
/// - Returns: A version of the gesture that updates the provided `state` as
///   the originating gesture's value changes and that resets the `state`
///   to its initial value when the user or the system ends or cancels the
///   gesture.
@inlinable public func updating<State>(_ state: GestureState<State>, body: @escaping (Self.Value, inout State, inout Transaction) -> Void) -> GestureStateGesture<Self, State>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Combines a gesture with another gesture to create a new gesture that
/// recognizes both gestures at the same time.
///
/// - Parameter other: A gesture that you want to combine with your gesture
///   to create a new, combined gesture.
///
/// - Returns: A gesture with two simultaneous gestures.
@inlinable public func simultaneously<Other>(with other: Other) -> SimultaneousGesture<Self, Other> where Other : Gesture
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Adds an action to perform when the gesture ends.
///
/// - Parameter action: The action to perform when this gesture ends. The
///   `action` closure's parameter contains the final value of the gesture.
///
/// - Returns: A gesture that triggers `action` when the gesture ends.
public func onEnded(_ action: @escaping (Self.Value) -> Void) -> _EndedGesture<Self>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture where Self.Value : Equatable {
/// Adds an action to perform when the gesture's value changes.
///
/// - Parameter action: The action to perform when this gesture's value
///   changes. The `action` closure's parameter contains the gesture's new
///   value.
///
/// - Returns: A gesture that triggers `action` when this gesture's value
///   changes.
public func onChanged(_ action: @escaping (Self.Value) -> Void) -> _ChangedGesture<Self>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Returns a gesture that's the result of mapping the given closure over
/// the gesture.
public func map<T>(_ body: @escaping (Self.Value) -> T) -> _MapGesture<Self, T>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gesture {
/// Combines two gestures exclusively to create a new gesture where only one
/// gesture succeeds, giving precedence to the first gesture.
///
/// - Parameter other: A gesture you combine with your gesture, to create a
///   new, combined gesture.
///
/// - Returns: A gesture that's the result of combining two gestures where
///   only one of them can succeed. SwiftUI gives precedence to the first
///   gesture.
@inlinable public func exclusively<Other>(before other: Other) -> ExclusiveGesture<Self, Other> where Other : Gesture
}
/// Options that control how adding a gesture to a view affects other gestures
/// recognized by the view and its subviews.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct GestureMask : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: UInt32)
/// Disable all gestures in the subview hierarchy, including the added
/// gesture.
public static let none: GestureMask
/// Enable the added gesture but disable all gestures in the subview
/// hierarchy.
public static let gesture: GestureMask
/// Enable all gestures in the subview hierarchy but disable the added
/// gesture.
public static let subviews: GestureMask
/// Enable both the added gesture as well as all other gestures on the view
/// and its subviews.
public static let all: GestureMask
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GestureMask
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GestureMask
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension GestureMask : Sendable {
}
/// A property wrapper type that updates a property while the user performs a
/// gesture and resets the property back to its initial state when the gesture
/// ends.
///
/// Declare a property as `@GestureState`, pass as a binding to it as a
/// parameter to a gesture's ``Gesture/updating(_:body:)`` callback, and receive
/// updates to it. A property that's declared as `@GestureState` implicitly
/// resets when the gesture becomes inactive, making it suitable for tracking
/// transient state.
///
/// Add a long-press gesture to a ``Circle``, and update the interface during
/// the gesture by declaring a property as `@GestureState`:
///
///     struct SimpleLongPressGestureView: View {
///         @GestureState private var isDetectingLongPress = false
///
///         var longPress: some Gesture {
///             LongPressGesture(minimumDuration: 3)
///                 .updating($isDetectingLongPress) { currentState, gestureState, transaction in
///                     gestureState = currentState
///                 }
///         }
///
///         var body: some View {
///             Circle()
///                 .fill(self.isDetectingLongPress ? Color.red : Color.green)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .gesture(longPress)
///         }
///     }
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@propertyWrapper @frozen public struct GestureState<Value> : DynamicProperty {
/// Creates a view state that's derived from a gesture.
///
/// - Parameter wrappedValue: A wrapped value for the gesture state
///   property.
public init(wrappedValue: Value)
/// Creates a view state that's derived from a gesture with an initial
/// value.
///
/// - Parameter initialValue: An initial value for the gesture state
///   property.
public init(initialValue: Value)
/// Creates a view state that's derived from a gesture with a wrapped state
/// value and a transaction to reset it.
///
/// - Parameters:
///   - wrappedValue: A wrapped value for the gesture state property.
///   - resetTransaction: A transaction that provides metadata for view
///     updates.
public init(wrappedValue: Value, resetTransaction: Transaction)
/// Creates a view state that's derived from a gesture with an initial state
/// value and a transaction to reset it.
///
/// - Parameters:
///   - initialValue: An initial state value.
///   - resetTransaction: A transaction that provides metadata for view
///     updates.
public init(initialValue: Value, resetTransaction: Transaction)
/// Creates a view state that's derived from a gesture with a wrapped state
/// value and a closure that provides a transaction to reset it.
///
/// - Parameters:
///   - wrappedValue: A wrapped value for the gesture state property.
///   - reset: A closure that provides a ``Transaction``.
public init(wrappedValue: Value, reset: @escaping (Value, inout Transaction) -> Void)
/// Creates a view state that's derived from a gesture with an initial state
/// value and a closure that provides a transaction to reset it.
///
/// - Parameters:
///   - initialValue: An initial state value.
///   - reset: A closure that provides a ``Transaction``.
public init(initialValue: Value, reset: @escaping (Value, inout Transaction) -> Void)
/// The wrapped value referenced by the gesture state property.
public var wrappedValue: Value { get }
/// A binding to the gesture state property.
public var projectedValue: GestureState<Value> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension GestureState where Value : ExpressibleByNilLiteral {
/// Creates a view state that's derived from a gesture with a transaction to
/// reset it.
///
/// - Parameter resetTransaction: A transaction that provides metadata for
///   view updates.
public init(resetTransaction: Transaction = Transaction())
/// Creates a view state that's derived from a gesture with a closure that
/// provides a transaction to reset it.
///
/// - Parameter reset: A closure that provides a ``Transaction``.
public init(reset: @escaping (Value, inout Transaction) -> Void)
}
/// A gesture that updates the state provided by a gesture's updating callback.
///
/// A gesture's ``Gesture/updating(_:body:)`` callback returns a
/// `GestureStateGesture` instance for updating a transient state property
/// that's annotated with the ``GestureState`` property wrapper.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct GestureStateGesture<Base, State> : Gesture where Base : Gesture {
/// The type representing the gesture's value.
public typealias Value = Base.Value
/// The originating gesture.
public var base: Base
/// A value that changes as the user performs the gesture.
public var state: GestureState<State>
/// The updating gesture containing the originating gesture's value, the
/// updated state of the gesture, and a transaction.
public var body: (GestureStateGesture<Base, State>.Value, inout State, inout Transaction) -> Void
/// Creates a new gesture that's the result of an ongoing gesture.
///
/// - Parameters:
///   - base: The originating gesture.
///   - state: The wrapped value of a ``GestureState`` property.
///   - body: The callback that SwiftUI invokes as the gesture's value
///     changes.
@inlinable public init(base: Base, state: GestureState<State>, body: @escaping (GestureStateGesture<Base, State>.Value, inout State, inout Transaction) -> Void)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// The global coordinate space at the root of the view hierarchy.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct GlobalCoordinateSpace : CoordinateSpaceProtocol {
public init()
/// The resolved coordinate space.
public var coordinateSpace: CoordinateSpace { get }
}
/// A color gradient represented as an array of color stops, each having a
/// parametric location value.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Gradient : Equatable {
/// One color stop in the gradient.
@frozen public struct Stop : Equatable {
/// The color for the stop.
public var color: Color
/// The parametric location of the stop.
///
/// This value must be in the range `[0, 1]`.
public var location: CGFloat
/// Creates a color stop with a color and location.
public init(color: Color, location: CGFloat)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Gradient.Stop, b: Gradient.Stop) -> Bool
}
/// The array of color stops.
public var stops: [Gradient.Stop]
/// Creates a gradient from an array of color stops.
public init(stops: [Gradient.Stop])
/// Creates a gradient from an array of colors.
///
/// The gradient synthesizes its location values to evenly space the colors
/// along the gradient.
public init(colors: [Color])
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Gradient, b: Gradient) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Gradient : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Gradient : ShapeStyle {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Gradient {
/// A method of interpolating between the colors in a gradient.
public struct ColorSpace : Hashable, Sendable {
/// Interpolates gradient colors in the output color space.
public static let device: Gradient.ColorSpace
/// Interpolates gradient colors in a perceptual color space.
public static let perceptual: Gradient.ColorSpace
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Gradient.ColorSpace, b: Gradient.ColorSpace) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Returns a version of the gradient that will use a specified
/// color space for interpolating between its colors.
///
///     Rectangle().fill(.linearGradient(
///         colors: [.white, .blue]).colorSpace(.perceptual))
///
/// - Parameters:
///   - space: The color space the new gradient will use to
///     interpolate its constituent colors.
///
/// - Returns: A new gradient that interpolates its colors in the
///   specified color space.
///
public func colorSpace(_ space: Gradient.ColorSpace) -> AnyGradient
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Gradient.Stop : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Gradient.Stop : Sendable {
}
/// A date picker style that displays an interactive calendar or clock.
///
/// You can also use ``DatePickerStyle/graphical`` to construct this style.
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct GraphicalDatePickerStyle : DatePickerStyle {
/// Creates an instance of the graphical date picker style.
public init()
/// Returns the appearance and interaction content for a `DatePicker`.
///
/// The system calls this method for each ``DatePicker`` instance in a view
/// hierarchy where this style is the current date picker style.
///
/// - Parameter configuration : The properties of the date picker.
@available(iOS 16.0, macOS 13.0, *)
public func makeBody(configuration: GraphicalDatePickerStyle.Configuration) -> some View
/// A view representing the appearance and interaction of a `DatePicker`.
public typealias Body = some View
}
/// An immediate mode drawing destination, and its current state.
///
/// Use a context to execute 2D drawing primitives. For example, you can draw
/// filled shapes using the ``fill(_:with:style:)`` method inside a ``Canvas``
/// view:
///
///     Canvas { context, size in
///         context.fill(
///             Path(ellipseIn: CGRect(origin: .zero, size: size)),
///             with: .color(.green))
///     }
///     .frame(width: 300, height: 200)
///
/// The example above draws an ellipse that just fits inside a canvas that's
/// constrained to 300 points wide and 200 points tall:
///
/// ![A screenshot of a view that shows a green ellipse.](GraphicsContext-1)
///
/// In addition to outlining or filling paths, you can draw images, text,
/// and SwiftUI views. You can also use the context to perform many common
/// graphical operations, like adding masks, applying filters and
/// transforms, and setting a blend mode. For example you can add
/// a mask using the ``clip(to:style:options:)`` method:
///
///     let halfSize = size.applying(CGAffineTransform(scaleX: 0.5, y: 0.5))
///     context.clip(to: Path(CGRect(origin: .zero, size: halfSize)))
///     context.fill(
///         Path(ellipseIn: CGRect(origin: .zero, size: size)),
///         with: .color(.green))
///
/// The rectangular mask hides all but one quadrant of the ellipse:
///
/// ![A screenshot of a view that shows the upper left quarter of a green
/// ellipse.](GraphicsContext-2)
///
/// The order of operations matters. Changes that you make to the state of
/// the context, like adding a mask or a filter, apply to later
/// drawing operations. If you reverse the fill and clip operations in
/// the example above, so that the fill comes first, the mask doesn't
/// affect the ellipse.
///
/// Each context references a particular layer in a tree of transparency layers,
/// and also contains a full copy of the drawing state. You can modify the
/// state of one context without affecting the state of any other, even if
/// they refer to the same layer. For example you can draw the masked ellipse
/// from the previous example into a copy of the main context, and then add a
/// rectangle into the main context:
///
///     // Create a copy of the context to draw a clipped ellipse.
///     var maskedContext = context
///     let halfSize = size.applying(CGAffineTransform(scaleX: 0.5, y: 0.5))
///     maskedContext.clip(to: Path(CGRect(origin: .zero, size: halfSize)))
///     maskedContext.fill(
///         Path(ellipseIn: CGRect(origin: .zero, size: size)),
///         with: .color(.green))
///
///     // Go back to the original context to draw the rectangle.
///     let origin = CGPoint(x: size.width / 4, y: size.height / 4)
///     context.fill(
///         Path(CGRect(origin: origin, size: halfSize)),
///         with: .color(.blue))
///
/// The mask doesn't clip the rectangle because the mask isn't part of the
/// main context. However, both contexts draw into the same view because
/// you created one context as a copy of the other:
///
/// ![A screenshot of a view that shows the upper left quarter of a green
/// ellipse, overlaid by a blue rectangle centered in the
/// view.](GraphicsContext-3)
///
/// The context has access to an ``EnvironmentValues`` instance called
/// ``environment`` that's initially copied from the environment of its
/// enclosing view. SwiftUI uses environment values --- like the display
/// resolution and color scheme --- to resolve types like ``Image`` and
/// ``Color`` that appear in the context. You can also access values stored
/// in the environment for your own purposes.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public struct GraphicsContext {
/// The ways that a graphics context combines new content with background
/// content.
///
/// Use one of these values to set the
/// ``GraphicsContext/blendMode-swift.property`` property of a
/// ``GraphicsContext``. The value that you set affects how content
/// that you draw replaces or combines with content that you
/// previously drew into the context.
///
@frozen public struct BlendMode : RawRepresentable, Equatable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int32
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
@inlinable public init(rawValue: Int32)
/// A mode that paints source image samples over the background image
/// samples.
///
/// This is the default blend mode.
@inlinable public static var normal: GraphicsContext.BlendMode { get }
/// A mode that multiplies the source image samples with the background
/// image samples.
///
/// Drawing in this mode results in colors that are at least as
/// dark as either of the two contributing sample colors.
@inlinable public static var multiply: GraphicsContext.BlendMode { get }
/// A mode that multiplies the inverse of the source image samples with
/// the inverse of the background image samples.
///
/// Drawing in this mode results in colors that are at least as light
/// as either of the two contributing sample colors.
@inlinable public static var screen: GraphicsContext.BlendMode { get }
/// A mode that either multiplies or screens the source image samples
/// with the background image samples, depending on the background
/// color.
///
/// Drawing in this mode overlays the existing image samples
/// while preserving the highlights and shadows of the
/// background. The background color mixes with the source
/// image to reflect the lightness or darkness of the
/// background.
@inlinable public static var overlay: GraphicsContext.BlendMode { get }
/// A mode that creates composite image samples by choosing the darker
/// samples from either the source image or the background.
///
/// When you draw in this mode, source image samples that are darker
/// than the background replace the background.
/// Otherwise, the background image samples remain unchanged.
@inlinable public static var darken: GraphicsContext.BlendMode { get }
/// A mode that creates composite image samples by choosing the lighter
/// samples from either the source image or the background.
///
/// When you draw in this mode, source image samples that are lighter
/// than the background replace the background.
/// Otherwise, the background image samples remain unchanged.
@inlinable public static var lighten: GraphicsContext.BlendMode { get }
/// A mode that brightens the background image samples to reflect the
/// source image samples.
///
/// Source image sample values that
/// specify black do not produce a change.
@inlinable public static var colorDodge: GraphicsContext.BlendMode { get }
/// A mode that darkens background image samples to reflect the source
/// image samples.
///
/// Source image sample values that specify
/// white do not produce a change.
@inlinable public static var colorBurn: GraphicsContext.BlendMode { get }
/// A mode that either darkens or lightens colors, depending on the
/// source image sample color.
///
/// If the source image sample color is
/// lighter than 50% gray, the background is lightened, similar
/// to dodging. If the source image sample color is darker than
/// 50% gray, the background is darkened, similar to burning.
/// If the source image sample color is equal to 50% gray, the
/// background is not changed. Image samples that are equal to
/// pure black or pure white produce darker or lighter areas,
/// but do not result in pure black or white. The overall
/// effect is similar to what you'd achieve by shining a
/// diffuse spotlight on the source image. Use this to add
/// highlights to a scene.
@inlinable public static var softLight: GraphicsContext.BlendMode { get }
/// A mode that either multiplies or screens colors, depending on the
/// source image sample color.
///
/// If the source image sample color
/// is lighter than 50% gray, the background is lightened,
/// similar to screening. If the source image sample color is
/// darker than 50% gray, the background is darkened, similar
/// to multiplying. If the source image sample color is equal
/// to 50% gray, the source image is not changed. Image samples
/// that are equal to pure black or pure white result in pure
/// black or white. The overall effect is similar to what you'd
/// achieve by shining a harsh spotlight on the source image.
/// Use this to add highlights to a scene.
@inlinable public static var hardLight: GraphicsContext.BlendMode { get }
/// A mode that subtracts the brighter of the source image sample color
/// or the background image sample color from the other.
///
/// Source image sample values that are black produce no change; white
/// inverts the background color values.
@inlinable public static var difference: GraphicsContext.BlendMode { get }
/// A mode that produces an effect similar to that produced by the
/// difference blend mode, but with lower contrast.
///
/// Source image sample values that are black don't produce a change;
/// white inverts the background color values.
@inlinable public static var exclusion: GraphicsContext.BlendMode { get }
/// A mode that uses the luminance and saturation values of the
/// background with the hue of the source image.
@inlinable public static var hue: GraphicsContext.BlendMode { get }
/// A mode that uses the luminance and hue values of the background with
/// the saturation of the source image.
///
/// Areas of the background that have no saturation --- namely,
/// pure gray areas --- don't produce a change.
@inlinable public static var saturation: GraphicsContext.BlendMode { get }
/// A mode that uses the luminance values of the background with the hue
/// and saturation values of the source image.
///
/// This mode preserves the gray levels in the image. You can use this
/// mode to color monochrome images or to tint color images.
@inlinable public static var color: GraphicsContext.BlendMode { get }
/// A mode that uses the hue and saturation of the background with the
/// luminance of the source image.
///
/// This mode creates an effect that is inverse to the effect created
/// by the ``color`` mode.
@inlinable public static var luminosity: GraphicsContext.BlendMode { get }
/// A mode that clears any pixels that the source image overwrites.
///
/// With this mode, you can use the source image like an eraser.
///
/// This mode implements the equation `R = 0` where
/// `R` is the composite image.
@inlinable public static var clear: GraphicsContext.BlendMode { get }
/// A mode that replaces background image samples with source image
/// samples.
///
/// Unlike the ``normal`` mode, the source image completely replaces
/// the background, so that even transparent pixels in the source image
/// replace opaque pixels in the background, rather than letting the
/// background show through.
///
/// This mode implements the equation `R = S` where
/// * `R` is the composite image.
/// * `S` is the source image.
@inlinable public static var copy: GraphicsContext.BlendMode { get }
/// A mode that you use to paint the source image, including
/// its transparency, onto the opaque parts of the background.
///
/// This mode implements the equation `R = S*Da` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `Da` is the source background's alpha value.
@inlinable public static var sourceIn: GraphicsContext.BlendMode { get }
/// A mode that you use to paint the source image onto the
/// transparent parts of the background, while erasing the background.
///
/// This mode implements the equation `R = S*(1 - Da)` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `Da` is the source background's alpha value.
@inlinable public static var sourceOut: GraphicsContext.BlendMode { get }
/// A mode that you use to paint the opaque parts of the
/// source image onto the opaque parts of the background.
///
/// This mode implements the equation `R = S*Da + D*(1 - Sa)` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
/// * `Sa` is the source image's alpha value.
/// * `Da` is the source background's alpha value.
@inlinable public static var sourceAtop: GraphicsContext.BlendMode { get }
/// A mode that you use to paint the source image under
/// the background.
///
/// This mode implements the equation `R = S*(1 - Da) + D` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
/// * `Da` is the source background's alpha value.
@inlinable public static var destinationOver: GraphicsContext.BlendMode { get }
/// A mode that you use to erase any of the background that
/// isn't covered by opaque source pixels.
///
/// This mode implements the equation `R = D*Sa` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `Da` is the source background's alpha value.
@inlinable public static var destinationIn: GraphicsContext.BlendMode { get }
/// A mode that you use to erase any of the background that
/// is covered by opaque source pixels.
///
/// This mode implements the equation `R = D*(1 - Sa)` where
/// * `R` is the composite image.
/// * `D` is the background.
/// * `Sa` is the source image's alpha value.
@inlinable public static var destinationOut: GraphicsContext.BlendMode { get }
/// A mode that you use to paint the source image under
/// the background, while erasing any of the background not matched
/// by opaque pixels from the source image.
///
/// This mode implements the equation `R = S*(1 - Da) + D*Sa` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
/// * `Sa` is the source image's alpha value.
/// * `Da` is the source background's alpha value.
@inlinable public static var destinationAtop: GraphicsContext.BlendMode { get }
/// A mode that you use to clear pixels where both the source and
/// background images are opaque.
///
/// This mode implements the equation `R = S*(1 - Da) + D*(1 - Sa)` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
/// * `Sa` is the source image's alpha value.
/// * `Da` is the source background's alpha value.
///
/// This XOR mode is only nominally related to the classical bitmap
/// XOR operation, which SwiftUI doesn't support.
@inlinable public static var xor: GraphicsContext.BlendMode { get }
/// A mode that adds the inverse of the color components of the source
/// and background images, and then inverts the result, producing
/// a darkened composite.
///
/// This mode implements the equation `R = MAX(0, 1 - ((1 - D) + (1 - S)))` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
@inlinable public static var plusDarker: GraphicsContext.BlendMode { get }
/// A mode that adds the components of the source and background images,
/// resulting in a lightened composite.
///
/// This mode implements the equation `R = MIN(1, S + D)` where
/// * `R` is the composite image.
/// * `S` is the source image.
/// * `D` is the background.
@inlinable public static var plusLighter: GraphicsContext.BlendMode { get }
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int32
}
/// The opacity of drawing operations in the context.
///
/// Set this value to affect the opacity of content that you subsequently
/// draw into the context. Changing this value has no impact on the
/// content you previously drew into the context.
public var opacity: Double
/// The blend mode used by drawing operations in the context.
///
/// Set this value to affect how any content that you subsequently draw
/// into the context blends with content that's already in the context.
/// Use one of the ``GraphicsContext/BlendMode-swift.struct`` values.
public var blendMode: GraphicsContext.BlendMode
/// The environment associated with the graphics context.
///
/// SwiftUI initially sets this to the environment of the context's
/// enclosing view. The context uses values like display
/// resolution and the color scheme from the environment to resolve types
/// like ``Image`` and ``Color``. You can also access values stored in the
/// environment for your own purposes.
public var environment: EnvironmentValues { get }
/// The current transform matrix, defining user space coordinates.
///
/// Modify this matrix to transform content that you subsequently
/// draw into the context. Changes that you make don't affect
/// existing content.
public var transform: CGAffineTransform
/// Scales subsequent drawing operations by an amount in each dimension.
///
/// Calling this method is equivalent to updating the context's
/// ``transform`` directly using the given scale factors:
///
///     transform = transform.scaledBy(x: x, y: y)
///
/// - Parameters:
///   - x: The amount to scale in the horizontal direction.
///   - y: The amount to scale in the vertical direction.
public mutating func scaleBy(x: CGFloat, y: CGFloat)
/// Moves subsequent drawing operations by an amount in each dimension.
///
/// Calling this method is equivalent to updating the context's
/// ``transform`` directly using the given translation amount:
///
///     transform = transform.translatedBy(x: x, y: y)
///
/// - Parameters:
///   - x: The amount to move in the horizontal direction.
///   - y: The amount to move in the vertical direction.
public mutating func translateBy(x: CGFloat, y: CGFloat)
/// Rotates subsequent drawing operations by an angle.
///
/// Calling this method is equivalent to updating the context's
/// ``transform`` directly using the `angle` parameter:
///
///     transform = transform.rotated(by: angle.radians)
///
/// - Parameters:
///   - angle: The amount to rotate.
public mutating func rotate(by angle: Angle)
/// Appends the given transform to the context's existing transform.
///
/// Calling this method is equivalent to updating the context's
/// ``transform`` directly using the `matrix` parameter:
///
///     transform = matrix.concatenating(transform)
///
/// - Parameter matrix: A transform to append to the existing transform.
public mutating func concatenate(_ matrix: CGAffineTransform)
/// Options that affect the use of clip shapes.
///
/// Use these options to affect how SwiftUI interprets a clip shape
/// when you call ``clip(to:style:options:)`` to add a path to the array of
/// clip shapes, or when you call ``clipToLayer(opacity:options:content:)``
/// to add a clipping layer.
@frozen public struct ClipOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// An option to invert the shape or layer alpha as the clip mask.
///
/// When you use this option, SwiftUI uses `1 - alpha` instead of
/// `alpha` for the given clip shape.
@inlinable public static var inverse: GraphicsContext.ClipOptions { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GraphicsContext.ClipOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GraphicsContext.ClipOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// The bounding rectangle of the intersection of all current clip
/// shapes in the current user space.
public var clipBoundingRect: CGRect { get }
/// Adds a path to the context's array of clip shapes.
///
/// Call this method to add a shape to the array of clip shapes that
/// the context uses to define a clipping mask. Shapes that you add
/// affect only subsequent drawing operations.
///
/// - Parameters:
///   - path: A ``Path`` that defines the shape of the clipping mask.
///   - style: A ``FillStyle`` that defines how to rasterize the shape.
///   - options: Clip options that tell SwiftUI how to interpret the `path`
///     as a clip shape. For example, you can invert the clip
///     shape by setting the ``ClipOptions/inverse`` option.
public mutating func clip(to path: Path, style: FillStyle = FillStyle(), options: GraphicsContext.ClipOptions = ClipOptions())
/// Adds a clip shape that you define in a new layer to the context's array
/// of clip shapes.
///
/// Call this method to add a shape to the array of clip shapes that
/// the context uses to define a clipping mask. Shapes that you add
/// affect only subsequent drawing operations.
///
/// - Parameters:
///   - opacity: A value that SwiftUI uses to multiply the alpha channel of
///     the rasterized layer that you define in the `content` closure. The
///     alpha values that result define the clip shape.
///   - options: A set of options that tell SwiftUI how to interpret the
///     clip shape. For example, you can invert the clip
///     shape by setting the ``ClipOptions/inverse`` option.
///   - content: A closure that receives as input a new ``GraphicsContext``,
///     which represents a new transparency layer. The alpha channel of
///     content that you draw into this context, multiplied by the `opacity`
///     parameter, defines the clip shape.
public mutating func clipToLayer(opacity: Double = 1, options: GraphicsContext.ClipOptions = ClipOptions(), content: (inout GraphicsContext) throws -> Void) rethrows
/// A type that applies image processing operations to rendered content.
///
/// Create and configure a filter that produces an image processing effect,
/// like adding a drop shadow or a blur effect, by calling one of the
/// factory methods defined by the `Filter` structure. Call the
/// ``addFilter(_:options:)`` method to add the filter to a
/// ``GraphicsContext``. The filter only affects content that you draw
/// into the context after adding the filter.
public struct Filter : Sendable {
/// Returns a filter that that transforms the rasterized form
/// of subsequent graphics primitives.
///
/// - Parameters:
///   - matrix: A projection transform to apply to the rasterized
///     form of graphics primitives.
/// - Returns: A filter that applies a transform.
public static func projectionTransform(_ matrix: ProjectionTransform) -> GraphicsContext.Filter
/// Returns a filter that adds a shadow.
///
/// SwiftUI produces the shadow by blurring the alpha channel of the
/// object receiving the shadow, multiplying the result by a color,
/// optionally translating the shadow by an amount,
/// and then blending the resulting shadow into a new layer below the
/// source primitive. You can customize some of these steps by adding
/// one or more shadow options.
///
/// - Parameters:
///   - color: A ``Color`` that tints the shadow.
///   - radius: A measure of how far the shadow extends from the edges
///     of the content receiving the shadow.
///   - x: An amount to translate the shadow horizontally.
///   - y: An amount to translate the shadow vertically.
///   - blendMode: The ``GraphicsContext/BlendMode-swift.struct`` to use
///     when blending the shadow into the background layer.
///   - options: A set of options that you can use to customize the
///     process of adding the shadow. Use one or more of the options
///     in ``GraphicsContext/ShadowOptions``.
/// - Returns: A filter that adds a shadow style.
public static func shadow(color: Color = Color(.sRGBLinear, white: 0, opacity: 0.33), radius: CGFloat, x: CGFloat = 0, y: CGFloat = 0, blendMode: GraphicsContext.BlendMode = .normal, options: GraphicsContext.ShadowOptions = ShadowOptions()) -> GraphicsContext.Filter
/// Returns a filter that multiplies each color component by
/// the matching component of a given color.
///
/// - Parameters:
///   - color: The color that the filter uses for the multiplication
///     operation.
/// - Returns: A filter that multiplies color components.
public static func colorMultiply(_ color: Color) -> GraphicsContext.Filter
/// Returns a filter that multiplies by a given color matrix.
///
/// This filter is equivalent to the `feColorMatrix` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// The filter creates the output color `[R', G', B', A']` at each pixel
/// from an input color `[R, G, B, A]` by multiplying the input color by
/// the square matrix formed by the first four columns of the
/// ``ColorMatrix``, then adding the fifth column to the result:
///
///     R' = r1 ✕ R + r2 ✕ G + r3 ✕ B + r4 ✕ A + r5
///     G' = g1 ✕ R + g2 ✕ G + g3 ✕ B + g4 ✕ A + g5
///     B' = b1 ✕ R + b2 ✕ G + b3 ✕ B + b4 ✕ A + b5
///     A' = a1 ✕ R + a2 ✕ G + a3 ✕ B + a4 ✕ A + a5
///
/// - Parameters:
///   - matrix: A ``ColorMatrix`` instance used by the filter.
/// - Returns: A filter that transforms color using the given matrix.
public static func colorMatrix(_ matrix: ColorMatrix) -> GraphicsContext.Filter
/// Returns a filter that applies a hue rotation adjustment.
///
/// This filter is equivalent to the `hue-rotate` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// - Parameters:
///   - angle: The amount by which to rotate the hue value of each
///     pixel.
/// - Returns: A filter that applies a hue rotation adjustment.
public static func hueRotation(_ angle: Angle) -> GraphicsContext.Filter
/// Returns a filter that applies a saturation adjustment.
///
/// This filter is equivalent to the `saturate` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// - Parameters:
///   - amount: The amount of the saturation adjustment. A value
///     of zero to completely desaturates each pixel, while a value of
///     one makes no change. You can use values greater than one.
/// - Returns: A filter that applies a saturation adjustment.
public static func saturation(_ amount: Double) -> GraphicsContext.Filter
/// Returns a filter that applies a brightness adjustment.
///
/// This filter is different than `brightness` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
/// You can obtain an effect like that filter using a ``grayscale(_:)``
/// color multiply. However, this filter does match the
/// <doc://com.apple.documentation/documentation/CoreImage/CIColorControls>
/// filter's brightness adjustment.
///
/// - Parameters:
///   - amount: An amount to add to the pixel's color components.
/// - Returns: A filter that applies a brightness adjustment.
public static func brightness(_ amount: Double) -> GraphicsContext.Filter
/// Returns a filter that applies a contrast adjustment.
///
/// This filter is equivalent to the `contrast` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// - Parameters:
///   - amount: An amount to adjust the contrast. A value of
///     zero leaves the result completely gray. A value of one leaves
///     the result unchanged. You can use values greater than one.
/// - Returns: A filter that applies a contrast adjustment.
public static func contrast(_ amount: Double) -> GraphicsContext.Filter
/// Returns a filter that inverts the color of their results.
///
/// This filter is equivalent to the `invert` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// - Parameters:
///   - amount: The inversion amount. A value of one results in total
///     inversion, while a value of zero leaves the result unchanged.
///     Other values apply a linear multiplier effect.
/// - Returns: A filter that applies a color inversion.
public static func colorInvert(_ amount: Double = 1) -> GraphicsContext.Filter
/// Returns a filter that applies a grayscale adjustment.
///
/// This filter is equivalent to the `grayscale` filter primitive
/// defined by the Scalable Vector Graphics (SVG) specification.
///
/// - Parameters:
///   - amount: An amount that controls the effect. A value of one
///     makes the image completely gray. A value of zero leaves the
///     result unchanged. Other values apply a linear multiplier effect.
/// - Returns: A filter that applies a grayscale adjustment.
public static func grayscale(_ amount: Double) -> GraphicsContext.Filter
/// Returns a filter that sets the opacity of each pixel based on its
/// luminance.
///
/// The filter computes the luminance of each pixel
/// and uses it to define the opacity of the result, combined
/// with black (zero) color components.
///
/// - Returns: A filter that applies a luminance to alpha transformation.
public static var luminanceToAlpha: GraphicsContext.Filter { get }
/// Returns a filter that applies a Gaussian blur.
///
/// - Parameters:
///   - radius: The standard deviation of the Gaussian blur.
///   - options: A set of options controlling the application of the
///     effect.
/// - Returns: A filter that applies Gaussian blur.
public static func blur(radius: CGFloat, options: GraphicsContext.BlurOptions = BlurOptions()) -> GraphicsContext.Filter
/// Returns a filter that replaces each pixel with alpha components
/// within a range by a constant color, or transparency otherwise.
///
/// - Parameters:
///   - min: The minimum alpha threshold. Pixels whose alpha
///     component is less than this value will render as
///     transparent. Results are undefined unless `min < max`.
///   - max: The maximum alpha threshold. Pixels whose alpha
///     component is greater than this value will render
///     as transparent. Results are undefined unless `min < max`.
///   - color: The color that is output for pixels with an alpha
///     component between the two threshold values.
/// - Returns: A filter that applies a threshold to alpha values.
public static func alphaThreshold(min: Double, max: Double = 1, color: Color = Color.black) -> GraphicsContext.Filter
/// Returns a filter that applies `shader` to the color of each
/// source pixel.
///
/// For a shader function to act as a color filter it must have
/// a function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position, half4 color, args...)
///
/// where `position` is the user-space coordinates of the pixel
/// applied to the shader and `color` its source color, as a
/// pre-multiplied color in the destination color space. `args...`
/// should be compatible with the uniform arguments bound to
/// `shader`. The function should return the modified color value.
///
/// - Parameters:
///   - shader: The shader to apply to `self` as a color filter.
///
/// - Returns: A filter that applies the shader  as a color
///   filter.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public static func colorShader(_ shader: Shader) -> GraphicsContext.Filter
/// Returns a filter that applies `shader` as a geometric
/// distortion effect on the location of each pixel.
///
/// For a shader function to act as a distortion effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] float2 name(float2 position, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader. `args...` should be
/// compatible with the uniform arguments bound to `shader`. The
/// function should return the user-space coordinates of the
/// corresponding source pixel.
///
/// - Parameters:
///   - shader: The shader to apply as a distortion effect.
///   - maxSampleOffset: The maximum distance in each axis
///     between the returned source pixel position and the
///     destination pixel position, for all source pixels.
///
/// - Returns: A new filter that applies the shader as a
///   distortion effect.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public static func distortionShader(_ shader: Shader, maxSampleOffset: CGSize) -> GraphicsContext.Filter
/// Returns a filter that applies `shader` to the contents of
/// the source layer.
///
/// For a shader function to act as a layer effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position,
///       SwiftUI::Layer layer, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader, and `layer` is a
/// rasterized subregion of the source layer. `args...` should
/// be compatible with the uniform arguments bound to `shader`.
///
/// The `SwiftUI::Layer` type is defined in the
/// `<SwiftUI/SwiftUI.h>` header file. It exports a single
/// `sample()` function that returns a linearly-filtered pixel
/// value from a position in the source content, as a
/// premultiplied RGBA pixel value:
///
///     namespace SwiftUI {
///       struct Layer {
///         half4 sample(float2 position) const;
///       };
///     };
///
/// The function should return the color mapping to the
/// destination pixel, typically by sampling one or more pixels
/// from `layer` at location(s) derived from `position` and
/// them applying some kind of transformation to produce a new
/// color.
///
/// - Parameters:
///   - shader: The shader to apply as a layer effect.
///   - maxSampleOffset: If the shader function samples from
///     the layer at locations not equal to the destination
///     position, this value must specify the maximum sampling
///     distance in each axis, for all source pixels.
///
/// - Returns: A filter applies the shader as a layer effect.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public static func layerShader(_ shader: Shader, maxSampleOffset: CGSize) -> GraphicsContext.Filter
}
/// Options that configure the graphics context filter that creates shadows.
///
/// You can use a set of these options when you call
/// ``Filter/shadow(color:radius:x:y:blendMode:options:)`` to create a
/// ``Filter`` that adds a drop shadow to an object that you draw into a
/// ``GraphicsContext``.
@frozen public struct ShadowOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// An option that causes the filter to draw the shadow above the
/// object, rather than below it.
@inlinable public static var shadowAbove: GraphicsContext.ShadowOptions { get }
/// An option that causes the filter to draw only the shadow, and
/// omit the source object.
@inlinable public static var shadowOnly: GraphicsContext.ShadowOptions { get }
/// An option that causes the filter to invert the alpha of the shadow.
///
/// You can create an "inner shadow" effect by combining this option
/// with ``shadowAbove`` and using the
/// ``GraphicsContext/BlendMode-swift.struct/sourceAtop`` blend mode.
@inlinable public static var invertsAlpha: GraphicsContext.ShadowOptions { get }
/// An option that causes the filter to composite the object and its
/// shadow separately in the current layer.
@inlinable public static var disablesGroup: GraphicsContext.ShadowOptions { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GraphicsContext.ShadowOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GraphicsContext.ShadowOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// Options that configure the graphics context filter that creates blur.
///
/// You can use a set of these options when you call
/// ``Filter/blur(radius:options:)`` to create a ``Filter`` that adds
/// blur to an object that you draw into a ``GraphicsContext``.
@frozen public struct BlurOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// An option that causes the filter to ensure the result is completely
/// opaque.
///
/// The filter ensure opacity by dividing each pixel by its alpha
/// value. The result may be undefined if the input to the filter
/// isn't also completely opaque.
@inlinable public static var opaque: GraphicsContext.BlurOptions { get }
/// An option that causes the filter to dither the result, to reduce
/// banding.
@inlinable public static var dithersResult: GraphicsContext.BlurOptions { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GraphicsContext.BlurOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GraphicsContext.BlurOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// Options that configure a filter that you add to a graphics context.
///
/// You can use filter options to configure a ``Filter`` that you apply
/// to a ``GraphicsContext`` with the ``addFilter(_:options:)`` method.
@frozen public struct FilterOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// An option that causes the filter to perform calculations in a
/// linear color space.
@inlinable public static var linearColor: GraphicsContext.FilterOptions { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GraphicsContext.FilterOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GraphicsContext.FilterOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// Adds a filter that applies to subsequent drawing operations.
///
/// To draw with filtering, SwiftUI:
///
/// - Rasterizes the drawing operation to an implicit transparency layer
///   without blending, adjusting opacity, or applying any clipping.
/// - Applies the filter to the layer containing the rasterized image.
/// - Composites the layer onto the background, using the context's
///   current blend mode, opacity setting, and clip shapes.
///
/// When SwiftUI draws with a filter, the blend mode might apply to regions
/// outside the drawing operation's intrinsic shape, but inside its clip
/// shape. That might result in unexpected behavior for certain blend
/// modes like ``GraphicsContext/BlendMode-swift.struct/copy``, where
/// the drawing operation completely overwrites the background even if
/// the source alpha is zero.
///
/// - Parameters:
///   - filter: A graphics context filter that you create by calling one
///     of the ``Filter`` factory methods.
///   - options: A set of options from ``FilterOptions`` that you can use to
///     configure filter operations.
public mutating func addFilter(_ filter: GraphicsContext.Filter, options: GraphicsContext.FilterOptions = FilterOptions())
/// A color or pattern that you can use to outline or fill a path.
///
/// Use a shading instance to describe the color or pattern of a path that
/// you outline with a method like ``stroke(_:with:style:)``, or of the
/// interior of a region that you fill with the ``fill(_:with:style:)``
/// method. Get a shading instance by calling one of the `Shading`
/// structure's factory methods. You can base shading on:
/// - A ``Color``.
/// - A ``Gradient``.
/// - Any type that conforms to ``ShapeStyle``.
/// - An ``Image``.
/// - What you've already drawn into the context.
/// - A collection of other shading instances.
public struct Shading : Sendable {
/// A shading instance that draws a copy of the current background.
public static var backdrop: GraphicsContext.Shading { get }
/// A shading instance that fills with the foreground style from
/// the graphics context's environment.
public static var foreground: GraphicsContext.Shading { get }
/// Returns a multilevel shading instance constructed from an
/// array of shading instances.
///
/// - Parameter array: An array of shading instances. The array must
///   contain at least one element.
/// - Returns: A shading instance composed from the given instances.
public static func palette(_ array: [GraphicsContext.Shading]) -> GraphicsContext.Shading
/// Returns a shading instance that fills with a color.
///
/// - Parameter color: A ``Color`` instance that defines the color
///   of the shading.
/// - Returns: A shading instance filled with a color.
public static func color(_ color: Color) -> GraphicsContext.Shading
/// Returns a shading instance that fills with a color in the given
/// color space.
///
/// - Parameters:
///   - colorSpace: The RGB color space used to define the color. The
///     default is ``Color/RGBColorSpace/sRGB``.
///   - red: The red component of the color.
///   - green: The green component of the color.
///   - blue: The blue component of the color.
///   - opacity: The opacity of the color. The default is `1`, which
///     means fully opaque.
/// - Returns: A shading instance filled with a color.
public static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1) -> GraphicsContext.Shading
/// Returns a shading instance that fills with a monochrome color in
/// the given color space.
///
/// - Parameters:
///   - colorSpace: The RGB color space used to define the color. The
///     default is ``Color/RGBColorSpace/sRGB``.
///   - white: The value to use for each of the red, green, and blue
///     components of the color.
///   - opacity: The opacity of the color. The default is `1`, which
///     means fully opaque.
/// - Returns: A shading instance filled with a color.
public static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, white: Double, opacity: Double = 1) -> GraphicsContext.Shading
/// Returns a shading instance that fills with the results of
/// querying a shader for each pixel.
///
/// For a shader function to act as a shape fill it must have a
/// function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position, args...)
///
/// where `position` is the user-space coordinates of the pixel applied
/// to the shader, and `args...` should be compatible with the uniform
/// arguments bound to `shader`. The function should return the
/// premultiplied color value in the color space of the destination
/// (typically sRGB).
///
/// - Parameters:
///   - shader: The shader defining the filled colors.
///   - bounds: The rect used to define any `bounds` arguments
///     of the shader.
///
/// - Returns: A shading instance that fills using the shader.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public static func shader(_ shader: Shader, bounds: CGRect = .zero) -> GraphicsContext.Shading
/// Returns a shading instance that fills with the given shape style.
///
/// Styles with geometry defined in a unit coordinate space
/// map that space to the rectangle associated with the drawn
/// object. You can adjust that using the ``ShapeStyle/in(_:)``
/// method. The shape style might affect the blend mode and opacity
/// of the drawn object.
///
/// - Parameter style: A ``ShapeStyle`` instance to draw with.
/// - Returns: A shading instance filled with a shape style.
public static func style<S>(_ style: S) -> GraphicsContext.Shading where S : ShapeStyle
/// Returns a shading instance that fills a linear (axial) gradient.
///
/// The shading instance defines an axis from `startPoint` to `endPoint`
/// in the current user space and maps colors from `gradient`
/// to lines perpendicular to the axis.
///
/// - Parameters:
///   - gradient: A ``Gradient`` instance that defines the colors
///     of the gradient.
///   - startPoint: The start point of the gradient axis.
///   - endPoint: The end point of the gradient axis.
///   - options: Options that you use to configure the gradient.
/// - Returns: A shading instance filled with a linear gradient.
public static func linearGradient(_ gradient: Gradient, startPoint: CGPoint, endPoint: CGPoint, options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading
/// Returns a shading instance that fills a radial gradient.
///
/// - Parameters:
///   - gradient: A ``Gradient`` instance that defines the colors
///     of the gradient.
///   - center: The point in the current user space on which SwiftUI
///     centers the gradient.
///   - startRadius: The distance from the center where the gradient
///     starts.
///   - endRadius:The distance from the center where the gradient ends.
///   - options: Options that you use to configure the gradient.
/// - Returns: A shading instance filled with a radial gradient.
public static func radialGradient(_ gradient: Gradient, center: CGPoint, startRadius: CGFloat, endRadius: CGFloat, options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading
/// Returns a shading instance that fills a conic (angular) gradient.
///
/// - Parameters:
///   - gradient: A ``Gradient`` instance that defines the colors
///     of the gradient.
///   - center: The point in the current user space on which SwiftUI
///     centers the gradient.
///   - angle: The angle about the center that SwiftUI uses to start and
///     finish the gradient. The gradient sweeps all the way around the
///     center.
///   - options: Options that you use to configure the gradient.
/// - Returns: A shading instance filled with a conic gradient.
public static func conicGradient(_ gradient: Gradient, center: CGPoint, angle: Angle = Angle(), options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading
/// Returns a shading instance that tiles an image across the infinite
/// plane.
///
/// - Parameters:
///   - image: An ``Image`` to use as fill.
///   - origin: The point in the current user space where SwiftUI
///     places the bottom left corner of the part of the image
///     defined by `sourceRect`. The image repeats as needed.
///   - sourceRect: A unit space subregion of the image. The default
///     is a unit rectangle, which selects the whole image.
///   - scale: A factor that you can use to control the image size.
/// - Returns: A shading instance filled with a tiled image.
public static func tiledImage(_ image: Image, origin: CGPoint = .zero, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1) -> GraphicsContext.Shading
}
/// Options that affect the rendering of color gradients.
///
/// Use these options to affect how SwiftUI manages a gradient that you
/// create for a ``Shading`` instance for use in a ``GraphicsContext``.
@frozen public struct GradientOptions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// An option that repeats the gradient outside its nominal range.
///
/// Use this option to cause the gradient to repeat its pattern in
/// areas that exceed the bounds of its start and end points.
/// The repetitions use the same start and end value for each
/// repetition.
///
/// Without this option or ``mirror``, the gradient stops at
/// the end of its range. The ``mirror`` option takes precendence if
/// you set both this one and that one.
@inlinable public static var `repeat`: GraphicsContext.GradientOptions { get }
/// An option that repeats the gradient outside its nominal range,
/// reflecting every other instance.
///
/// Use this option to cause the gradient to repeat its pattern in
/// areas that exceed the bounds of its start and end points.
/// The repetitions alternately reverse the start and end points,
/// producing a pattern like `0 -> 1`, `1 -> 0`, `0 -> 1`, and so on.
///
/// Without either this option or ``repeat``, the gradient stops at
/// the end of its range. This option takes precendence if
/// you set both this one and ``repeat``.
@inlinable public static var mirror: GraphicsContext.GradientOptions { get }
/// An option that interpolates between colors in a linear color space.
@inlinable public static var linearColor: GraphicsContext.GradientOptions { get }
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = GraphicsContext.GradientOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = GraphicsContext.GradientOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// Returns a version of a shading resolved with the current values
/// of the graphics context's environment.
///
/// Calling this function once and then drawing multiple times with
/// the result will often have less overhead than drawing with the
/// original shading multiple times.
public func resolve(_ shading: GraphicsContext.Shading) -> GraphicsContext.Shading
/// Draws a new layer, created by drawing code that you provide, into the
/// context.
///
/// - Parameter context: A closure that receives a new ``GraphicsContext``
///   as input. This context represents a new transparency layer that you
///   can draw into. When the closure returns, SwiftUI draws the new layer
///   into the current context.
public func drawLayer(content: (inout GraphicsContext) throws -> Void) rethrows
/// Draws a path into the context and fills the outlined region.
///
/// The current drawing state of the context defines the
/// full drawing operation. For example, the current transformation and
/// clip shapes, and any styles applied to the result, affect the final
/// result.
///
/// - Parameters:
///   - path: The outline of the region to fill.
///   - shading: The color or pattern to use when filling the region
///     bounded by `path`.
///   - style: A style that indicates how to rasterize the path.
public func fill(_ path: Path, with shading: GraphicsContext.Shading, style: FillStyle = FillStyle())
/// Draws a path into the context with a specified stroke style.
///
/// If you only need to control the style's ``StrokeStyle/lineWidth``
/// property, use ``stroke(_:with:lineWidth:)`` instead.
///
/// - Parameters:
///   - path: The path to outline.
///   - shading: The color or pattern to use when outlining the `path`.
///   - style: A style that indicates how to outline the path.
public func stroke(_ path: Path, with shading: GraphicsContext.Shading, style: StrokeStyle)
/// Draws a path into the context with a specified line width.
///
/// When you call this method, all ``StrokeStyle`` properties other than
/// ``StrokeStyle/lineWidth`` take their default values. To control other
/// style properties, use ``stroke(_:with:style:)`` instead.
///
/// - Parameters:
///   - path: The path to outline.
///   - shading: The color or pattern to use when outlining the `path`.
///   - lineWidth: The width of the stroke, which defaults to `1`.
public func stroke(_ path: Path, with shading: GraphicsContext.Shading, lineWidth: CGFloat = 1)
/// An image resolved to a particular environment.
///
/// You resolve an ``Image`` in preparation for drawing it into a context,
/// either manually by calling ``resolve(_:)-898z6``, or automatically
/// when calling ``draw(_:in:style:)-blhz`` or ``draw(_:at:anchor:)-1z5wt``.
/// The resolved image takes into account environment values like the
/// display resolution and current color scheme.
public struct ResolvedImage {
/// The size of the image.
public var size: CGSize { get }
/// The distance from the top of the image to its baseline.
///
/// If the image has no baseline, this value is equivalent to the
/// image's height.
public let baseline: CGFloat
/// An optional shading to fill the image with.
///
/// The value of this property defaults to
/// ``GraphicsContext/Shading/foreground`` for template images, and
/// to `nil` otherwise.
public var shading: GraphicsContext.Shading?
}
/// Gets a version of an image that's fixed with the current values of
/// the graphics context's environment.
///
/// You can measure the resolved image by looking at its
/// ``ResolvedImage/size`` and ``ResolvedImage/baseline`` properties.
/// You can draw the resolved image with the context's
/// ``draw(_:in:style:)-7rvee`` or ``draw(_:at:anchor:)-1z5wt`` method.
///
/// - Parameter image: The ``Image`` to resolve.
/// - Returns: An image that's resolved into the current context's
///   environment, taking into account environment values like the
///   display resolution and current color scheme.
public func resolve(_ image: Image) -> GraphicsContext.ResolvedImage
/// Draws a resolved image into the context, using the specified rectangle
/// as a layout frame.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the image.
///
/// - Parameters:
///   - image: The ``ResolvedImage`` to draw. Get a resolved image from an
///     ``Image`` by calling ``resolve(_:)-898z6``. Alternatively, you can
///     call ``draw(_:in:style:)-blhz`` with an ``Image``, and that method
///     performs the resolution automatically.
///   - rect: The rectangle in the current user space to draw the image in.
///   - style: A fill style to use when rasterizing the image.
public func draw(_ image: GraphicsContext.ResolvedImage, in rect: CGRect, style: FillStyle = FillStyle())
/// Draws a resolved image into the context, aligning an anchor within the
/// image to a point in the context.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the image.
///
/// - Parameters:
///   - image: The ``ResolvedImage`` to draw. Get a resolved image from an
///     ``Image`` by calling ``resolve(_:)-898z6``. Alternatively, you can
///     call ``draw(_:at:anchor:)-7l217`` with an ``Image``, and that method
///     performs the resolution automatically.
///   - point: A point within the rectangle of the resolved image to anchor
///     to a point in the context.
///   - anchor: A ``UnitPoint`` within the context to align the image with.
///     The default is ``UnitPoint/center``.
public func draw(_ image: GraphicsContext.ResolvedImage, at point: CGPoint, anchor: UnitPoint = .center)
/// Draws an image into the context, using the specified rectangle
/// as a layout frame.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the image.
///
/// - Parameters:
///   - image: The ``Image`` to draw. Before drawing, the method converts
///     the image to a ``ResolvedImage`` by calling ``resolve(_:)-898z6``.
///   - rect: The rectangle in the current user space to draw the image in.
///   - style: A fill style to use when rasterizing the image.
public func draw(_ image: Image, in rect: CGRect, style: FillStyle = FillStyle())
/// Draws an image into the context, aligning an anchor within the image
/// to a point in the context.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the image.
///
/// - Parameters:
///   - image: The ``Image`` to draw. Before drawing, the method converts
///     the image to a ``ResolvedImage`` by calling ``resolve(_:)-898z6``.
///   - point: A point within the rectangle of the resolved image to anchor
///     to a point in the context.
///   - anchor: A ``UnitPoint`` within the context to align the image with.
///     The default is ``UnitPoint/center``.
public func draw(_ image: Image, at point: CGPoint, anchor: UnitPoint = .center)
/// A text view resolved to a particular environment.
///
/// You resolve a ``Text`` view in preparation for drawing it into a context,
/// either manually by calling ``resolve(_:)-4dx65`` or automatically
/// when calling ``draw(_:in:)-5opqf`` or ``draw(_:at:anchor:)-5dgmd``.
/// The resolved text view takes into account environment values like the
/// display resolution and current color scheme.
public struct ResolvedText {
/// The shading to fill uncolored text regions with.
///
/// This value defaults to the ``GraphicsContext/Shading/foreground``
/// shading.
public var shading: GraphicsContext.Shading
/// Measures the size of the resolved text for a given
/// area into which the text should be placed.
///
/// - Parameter size: The area to place the ``Text`` view in.
public func measure(in size: CGSize) -> CGSize
/// Gets the distance from the first line's ascender to its baseline.
public func firstBaseline(in size: CGSize) -> CGFloat
/// Gets the distance from the first line's ascender to the last
/// line's baseline.
public func lastBaseline(in size: CGSize) -> CGFloat
}
/// Gets a version of a text view that's fixed with the current values of
/// the graphics context's environment.
///
/// You can measure the resolved text by calling its
/// ``ResolvedText/measure(in:)`` method.
/// You can draw the resolved text with the context's
/// ``draw(_:in:)-69ad8`` or ``draw(_:at:anchor:)-6xr87`` method.
///
/// - Parameter text: The ``Text`` view to resolve.
/// - Returns: A text view that's resolved into the current context's
///   environment, taking into account environment values like the
///   display resolution and current color scheme.
public func resolve(_ text: Text) -> GraphicsContext.ResolvedText
/// Draws resolved text into the context using the specified rectangle
/// as a layout frame.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the text.
///
/// - Parameters:
///   - text: The ``ResolvedText`` to draw. Get resolved text from a
///     ``Text`` view by calling ``resolve(_:)-4dx65``. Alternatively, you
///     can call ``draw(_:in:)-5opqf`` with a ``Text`` view, and that
///     method performs the resolution automatically.
///   - rect: The rectangle in the current user space to draw the text in.
public func draw(_ text: GraphicsContext.ResolvedText, in rect: CGRect)
/// Draws resolved text into the context, aligning an anchor within the
/// ideal size of the text to a point in the context.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the text.
///
/// - Parameters:
///   - text: The ``ResolvedText`` to draw. Get resolved text from a
///     ``Text`` view by calling ``resolve(_:)-4dx65``. Alternatively, you
///     can call ``draw(_:at:anchor:)-5dgmd`` with a ``Text`` view, and that
///     method performs the resolution automatically.
///   - point: A point within the rectangle of the ideal size of the
///     resolved text to anchor to a point in the context.
///   - anchor: A ``UnitPoint`` within the context to align the text with.
///     The default is ``UnitPoint/center``.
public func draw(_ text: GraphicsContext.ResolvedText, at point: CGPoint, anchor: UnitPoint = .center)
/// Draws text into the context using the specified rectangle
/// as a layout frame.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the text.
///
/// - Parameters:
///   - text: The ``Text`` view to draw. Before drawing, the method converts
///     the view to ``ResolvedText`` by calling ``resolve(_:)-4dx65``.
///   - rect: The rectangle in the current user space to draw the text in.
public func draw(_ text: Text, in rect: CGRect)
/// Draws text into the context, aligning an anchor within the ideal size
/// of the rendered text to a point in the context.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the text.
///
/// - Parameters:
///   - text: The ``Text`` view to draw. Before drawing, the method converts
///     the view to ``ResolvedText`` by calling ``resolve(_:)-4dx65``.
///   - point: A point within the rectangle of the resolved text to anchor
///     to a point in the context.
///   - anchor: A ``UnitPoint`` within the context to align the text with.
///     The default is ``UnitPoint/center``.
public func draw(_ text: Text, at point: CGPoint, anchor: UnitPoint = .center)
/// A static sequence of drawing operations that may be drawn
/// multiple times, preserving their resolution independence.
///
/// You resolve a child view in preparation for drawing it into a context
/// by calling ``resolveSymbol(id:)``. The resolved view takes into account
/// environment values like the display resolution and current color scheme.
public struct ResolvedSymbol {
/// The dimensions of the resolved symbol.
public var size: CGSize { get }
}
/// Gets the identified child view as a resolved symbol, if the view exists.
///
/// - Parameter id: The value that you used to tag the view when you
///   define it in the `symbols` parameter of the ``Canvas`` initializer
///   ``Canvas/init(opaque:colorMode:rendersAsynchronously:renderer:symbols:)``.
/// - Returns: The resolved symbol, or `nil` if SwiftUI can't find a child
///   view with the given `id`.
public func resolveSymbol<ID>(id: ID) -> GraphicsContext.ResolvedSymbol? where ID : Hashable
/// Draws a resolved symbol into the context, using the specified rectangle
/// as a layout frame.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the symbol.
///
/// - Parameters:
///   - symbol: The ``ResolvedSymbol`` to draw. Get a resolved symbol
///     by calling ``resolveSymbol(id:)`` with the identifier that you
///     use to tag the corresponding child view during ``Canvas``
///     initialization.
///   - rect: The rectangle in the current user space to draw the symbol in.
public func draw(_ symbol: GraphicsContext.ResolvedSymbol, in rect: CGRect)
/// Draws a resolved symbol into the context, aligning an anchor within the
/// symbol to a point in the context.
///
/// The current context state defines the full drawing operation. For
/// example, the current transformation and clip shapes affect how SwiftUI
/// draws the symbol.
///
/// - Parameters:
///   - symbol: The ``ResolvedSymbol`` view to draw. Get a resolved symbol
///     by calling ``resolveSymbol(id:)`` with the identifier that you
///     use to tag the corresponding child view during ``Canvas``
///     initialization.
///   - point: A point within the rectangle of the resolved symbol to anchor
///     to a point in the context.
///   - anchor: A ``UnitPoint`` within the context to align the symbol with.
///     The default is ``UnitPoint/center``.
public func draw(_ symbol: GraphicsContext.ResolvedSymbol, at point: CGPoint, anchor: UnitPoint = .center)
/// Provides a Core Graphics context that you can use as a proxy to draw
/// into this context.
///
/// Use this method to use existing drawing code that relies on
/// Core Graphics primitives.
///
/// - Parameter content: A closure that receives a
///   <doc://com.apple.documentation/documentation/CoreGraphics/CGContext>
///   that you use to perform drawing operations, just like you draw into a
///   ``GraphicsContext`` instance. Any filters, blend mode settings, clip
///   masks, and other state set before calling `withCGContext(content:)`
///   apply to drawing operations in the Core Graphics context as well. Any
///   state you set on the Core Graphics context is lost when the closure
///   returns. Accessing the Core Graphics context after the closure
///   returns produces undefined behavior.
public func withCGContext(content: (CGContext) throws -> Void) rethrows
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.BlendMode : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.ClipOptions : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.ShadowOptions : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.BlurOptions : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.FilterOptions : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension GraphicsContext.GradientOptions : Sendable {
}
/// A container view that arranges other views in a two dimensional layout.
///
/// Create a two dimensional layout by initializing a `Grid` with a collection
/// of ``GridRow`` structures. The first view in each grid row appears in
/// the grid's first column, the second view in the second column, and so
/// on. The following example creates a grid with two rows and two columns:
///
///     Grid {
///         GridRow {
///             Text("Hello")
///             Image(systemName: "globe")
///         }
///         GridRow {
///             Image(systemName: "hand.wave")
///             Text("World")
///         }
///     }
///
/// A grid and its rows behave something like a collection of ``HStack``
/// instances wrapped in a ``VStack``. However, the grid handles row and column
/// creation as a single operation, which applies alignment and spacing to
/// cells, rather than first to rows and then to a column of unrelated rows.
/// The grid produced by the example above demonstrates this:
///
/// ![A screenshot of items arranged in a grid. The upper-left
/// position in the grid contains the word hello. The upper-right contains
/// an image of a globe. The lower-left contains an image of a waving hand.
/// The lower-right contains the word world. The cells of the grid
/// have minimal vertical or horizontal spacing.](Grid-1-iOS)
///
/// > Note: If you need a grid that conforms to the ``Layout``
/// protocol, like when you want to create a conditional layout using
/// ``AnyLayout``, use ``GridLayout`` instead.
///
/// ### Multicolumn cells
///
/// If you provide a view rather than a ``GridRow`` as an element in the
/// grid's content, the grid uses the view to create a row that spans all of
/// the grid's columns. For example, you can add a ``Divider`` between the
/// rows of the previous example:
///
///     Grid {
///         GridRow {
///             Text("Hello")
///             Image(systemName: "globe")
///         }
///         Divider()
///         GridRow {
///             Image(systemName: "hand.wave")
///             Text("World")
///         }
///     }
///
/// Because a divider takes as much horizontal space as its parent offers, the
/// entire grid widens to fill the width offered by its parent view.
///
/// ![A screenshot of items arranged in a grid. The upper-left
/// cell in the grid contains the word hello. The upper right contains
/// an image of a globe. The lower-left contains an image of a waving hand.
/// The lower-right contains the word world. A dividing line that spans
/// the width of the grid separates the upper and lower elements. The grid's
/// rows have minimal vertical spacing, but it's columns have a lot of
/// horizontal spacing, with column content centered horizontally.](Grid-2-iOS)
///
/// To prevent a flexible view from taking more space on a given axis than the
/// other cells in a row or column require, add the
/// ``View/gridCellUnsizedAxes(_:)`` view modifier to the view:
///
///     Divider()
///         .gridCellUnsizedAxes(.horizontal)
///
/// This restores the grid to the width that the text and images require:
///
/// ![A screenshot of items arranged in a grid. The upper-left
/// position in the grid contains the word hello. The upper-right contains
/// an image of a globe. The lower-left contains an image of a waving hand.
/// The lower-right contains the word world. A dividing line that spans
/// the width of the grid separates the upper and lower elements. The grid's
/// rows and columns have minimal vertical or horizontal spacing.](Grid-3-iOS)
///
/// To make a cell span a specific number of columns rather than the whole
/// grid, use the ``View/gridCellColumns(_:)`` modifier on a view that's
/// contained inside a ``GridRow``.
///
/// ### Column count
///
/// The grid's column count grows to handle the row with the largest number of
/// columns. If you create rows with different numbers of columns, the grid
/// adds empty cells to the trailing edge of rows that have fewer columns.
/// The example below creates three rows with different column counts:
///
///     Grid {
///         GridRow {
///             Text("Row 1")
///             ForEach(0..<2) { _ in Color.red }
///         }
///         GridRow {
///             Text("Row 2")
///             ForEach(0..<5) { _ in Color.green }
///         }
///         GridRow {
///             Text("Row 3")
///             ForEach(0..<4) { _ in Color.blue }
///         }
///     }
///
/// The resulting grid has as many columns as the widest row, adding empty
/// cells to rows that don't specify enough views:
///
/// ![A screenshot of a grid with three rows and six columns. The first
/// column contains cells with the labels Row 1, Row 2, and Row 3, reading
/// from top to bottom. The text is centered in the cell in each case. The
/// other columns contain cells that are either filled with a rectangle, or
/// that are empty. Scanning from left to right, the first row contains two
/// red rectangle cells after its label cell, and then three empty cells.
/// The second row contains five green rectangle cells after its label cell.
/// The third row contains four blue rectangle cells after its label cell,
/// and then one empty cell. There's 20 points of space between each of
/// the cells.](Grid-4-iOS)
///
/// The grid sets the width of all the cells in a column to match the needs of
/// column's widest cell. In the example above, the width of the first column
/// depends on the width of the widest ``Text`` view that the column contains.
/// The other columns, which contain flexible ``Color`` views, share the
/// remaining horizontal space offered by the grid's parent view equally.
///
/// Similarly, the tallest cell in a row sets the height of the entire row.
/// The cells in the first column of the grid above need only the height
/// required for each string, but the ``Color`` cells expand to equally share
/// the total height available to the grid. As a result, the color cells
/// determine the row heights.
///
/// ### Cell spacing and alignment
///
/// You can control the spacing between cells in both the horizontal and
/// vertical dimensions and set a default alignment for the content in all
/// the grid cells when you initialize the grid using the
/// ``init(alignment:horizontalSpacing:verticalSpacing:content:)`` initializer.
/// Consider a modified version of the previous example:
///
///     Grid(alignment: .bottom, horizontalSpacing: 1, verticalSpacing: 1) {
///         // ...
///     }
///
/// This configuration causes all of the cells to use ``Alignment/bottom``
/// alignment --- which only affects the text cells because the colors fill
/// their cells completely --- and it reduces the spacing between cells:
///
/// ![A screenshot of a grid with three rows and six columns. The first
/// column contains cells with the labels Row 1, Row 2, and Row 3, reading
/// from top to bottom. The text is horizontally centered and bottom aligned
/// in the cell in each case. The other columns contain cells that are either
/// filled with a rectangle, or that are empty. Scanning from left to right,
/// the first row contains two red rectangle cells after its label cell, and
/// then three empty cells. The second row contains five green rectangle cells
/// after its label cell. The third row contains four blue rectangle cells
/// after its label cell, and then one empty cell. There's 1 point of space
/// between each of the cells.](Grid-5-iOS)
///
/// You can override the alignment of specific cells or groups of cells. For
/// example, you can change the horizontal alignment of the cells in a column
/// by adding the ``View/gridColumnAlignment(_:)`` modifier, or the vertical
/// alignment of the cells in a row by configuring the row's
/// ``GridRow/init(alignment:content:)`` initializer. You can also align
/// a single cell with the ``View/gridCellAnchor(_:)`` modifier.
///
/// ### Performance considerations
///
/// A grid can size its rows and columns correctly because
/// it renders all of its child views immediately. If your app exhibits
/// poor performance when it first displays a large grid that appears
/// inside a ``ScrollView``, consider switching to a ``LazyVGrid`` or
/// ``LazyHGrid`` instead.
///
/// Lazy grids render their cells when SwiftUI needs to display
/// them, rather than all at once. This reduces the initial cost of displaying
/// a large scrollable grid that's never fully visible, but also reduces the
/// grid's ability to optimally lay out cells. Switch to a lazy grid only if
/// profiling your code shows a worthwhile performance improvement.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct Grid<Content> where Content : View {
/// Creates a grid with the specified spacing, alignment, and child
/// views.
///
/// Use this initializer to create a ``Grid``. Provide a content closure
/// that defines the rows of the grid, and optionally customize the
/// spacing between cells and the alignment of content within each cell.
/// The following example customizes the spacing between cells:
///
///     Grid(horizontalSpacing: 30, verticalSpacing: 30) {
///         ForEach(0..<5) { row in
///             GridRow {
///                 ForEach(0..<5) { column in
///                     Text("(\(column), \(row))")
///                 }
///             }
///         }
///     }
///
/// You can list rows and the cells within rows directly, or you can
/// use a ``ForEach`` structure to generate either, as the example above
/// does:
///
/// ![A screenshot of a grid that contains five rows and five columns.
/// Each cell in the grid contains an pair of integers in parentheses.
/// The first integer indicates the column position, counting from zero
/// on the left up to four on the right. The second integer indicates the
/// row position, counting from zero on the top to four on the
/// bottom.](Grid-init-1-iOS)
///
/// By default, the grid's alignment value applies to all of the cells in
/// the grid. However, you can also change the alignment for particular
/// cells or groups of cells:
///
/// * Override the vertical alignment for the cells in a row
///   by specifying a ``VerticalAlignment`` parameter to the corresponding
///   row's ``GridRow/init(alignment:content:)`` initializer.
/// * Override the horizontal alignment for the cells in a column by adding
///   a ``View/gridColumnAlignment(_:)`` view modifier to exactly one of
///   the cells in the column, and specifying a ``HorizontalAlignment``
///   parameter.
/// * Specify a custom alignment anchor for a particular cell by using the
///   ``View/gridCellAnchor(_:)`` modifier on the cell's view.
///
/// - Parameters:
///   - alignment: The guide for aligning the child views within the
///     space allocated for a given cell. The default is
///     ``Alignment/center``.
///   - horizontalSpacing: The horizontal distance between each cell, given
///     in points. The value is `nil` by default, which results in a
///     default distance between cells that's appropriate for the platform.
///   - verticalSpacing: The vertical distance between each cell, given
///     in points. The value is `nil` by default, which results in a
///     default distance between cells that's appropriate for the platform.
///   - content: A closure that creates the grid's rows.
///
@inlinable public init(alignment: Alignment = .center, horizontalSpacing: CGFloat? = nil, verticalSpacing: CGFloat? = nil, @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Grid : View {
}
/// A description of a row or a column in a lazy grid.
///
/// Use an array of `GridItem` instances to configure the layout of items in
/// a lazy grid. Each grid item in the array specifies layout properties like
/// size and spacing for the rows of a ``LazyHGrid`` or the columns of
/// a ``LazyVGrid``. The following example defines four rows for a
/// horizontal grid, each with different characteristics:
///
///     struct GridItemDemo: View {
///         let rows = [
///             GridItem(.fixed(30), spacing: 1),
///             GridItem(.fixed(60), spacing: 10),
///             GridItem(.fixed(90), spacing: 20),
///             GridItem(.fixed(10), spacing: 50)
///         ]
///
///         var body: some View {
///             ScrollView(.horizontal) {
///                 LazyHGrid(rows: rows, spacing: 5) {
///                     ForEach(0...300, id: \.self) { _ in
///                         Color.red.frame(width: 30)
///                         Color.green.frame(width: 30)
///                         Color.blue.frame(width: 30)
///                         Color.yellow.frame(width: 30)
///                     }
///                 }
///             }
///         }
///     }
///
/// A lazy horizontal grid sets the width of each column based on the widest
/// cell in the column. It can do this because it has access to all of the views
/// in a given column at once. In the example above, the ``Color`` views always
/// have the same fixed width, resulting in a uniform column width across the
/// whole grid.
///
/// However, a lazy horizontal grid doesn't generally have access to all the
/// views in a row, because it generates new cells as people scroll through
/// information in your app. Instead, it relies on a grid item for information
/// about each row. The example above indicates a different fixed height for
/// each row, and sets a different amount of spacing to appear after each row:
///
/// ![A screenshot of a grid of rectangles arranged in four rows and a large
/// number of colums. All the rectangles are the same width, and have a uniform
/// horizontal spacing. The rectangles in a given row are the same height as
/// each other, but different than the rectangles in other rows. The vertical
/// spacing between rows also varies.](GridItem-1-iOS)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct GridItem : Sendable {
/// The size in the minor axis of one or more rows or columns in a grid
/// layout.
///
/// Use a `Size` instance when you create a ``GridItem``. The value tells a
/// ``LazyHGrid`` how to size its rows, or a ``LazyVGrid`` how to size
/// its columns.
public enum Size : Sendable {
/// A single item with the specified fixed size.
case fixed(CGFloat)
/// A single flexible item.
///
/// The size of this item is the size of the grid with spacing and
/// inflexible items removed, divided by the number of flexible items,
/// clamped to the provided bounds.
case flexible(minimum: CGFloat = 10, maximum: CGFloat = .infinity)
/// Multiple items in the space of a single flexible item.
///
/// This size case places one or more items into the space assigned to
/// a single `flexible` item, using the provided bounds and
/// spacing to decide exactly how many items fit. This approach prefers
/// to insert as many items of the `minimum` size as possible
/// but lets them increase to the `maximum` size.
case adaptive(minimum: CGFloat, maximum: CGFloat = .infinity)
}
/// The size of the item, which is the width of a column item or the
/// height of a row item.
public var size: GridItem.Size
/// The spacing to the next item.
///
/// If this value is `nil`, the item uses a reasonable default for the
/// current platform.
public var spacing: CGFloat?
/// The alignment to use when placing each view.
///
/// Use this property to anchor the view's relative position to the same
/// relative position in the view's assigned grid space.
public var alignment: Alignment?
/// Creates a grid item with the specified size, spacing, and alignment.
///
/// - Parameters:
///   - size: The size of the grid item.
///   - spacing: The spacing to use between this and the next item.
///   - alignment: The alignment to use for this grid item.
public init(_ size: GridItem.Size = .flexible(), spacing: CGFloat? = nil, alignment: Alignment? = nil)
}
/// A grid that you can use in conditional layouts.
///
/// This layout container behaves like a ``Grid``, but conforms to the
/// ``Layout`` protocol so you can use it in the conditional layouts that you
/// construct with ``AnyLayout``. If you don't need a conditional layout, use
/// ``Grid`` instead.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct GridLayout {
/// The alignment of subviews.
public var alignment: Alignment
/// The horizontal distance between adjacent subviews.
///
/// Set this value to `nil` to use default horizonal distances between
/// subviews.
public var horizontalSpacing: CGFloat?
/// The vertical distance between adjacent subviews.
///
/// Set this value to `nil` to use default vertical distances between
/// subviews.
public var verticalSpacing: CGFloat?
/// Creates a grid with the specified spacing and alignment.
///
/// - Parameters:
///   - alignment: The guide for aligning subviews within the
///     space allocated for a given cell. The default is
///     ``Alignment/center``.
///   - horizontalSpacing: The horizontal distance between each cell, given
///     in points. The value is `nil` by default, which results in a
///     default distance between cells that's appropriate for the platform.
///   - verticalSpacing: The vertical distance between each cell, given
///     in points. The value is `nil` by default, which results in a
///     default distance between cells that's appropriate for the platform.
@inlinable public init(alignment: Alignment = .center, horizontalSpacing: CGFloat? = nil, verticalSpacing: CGFloat? = nil)
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension GridLayout : Layout {
/// Creates and initializes a cache for a layout instance.
///
/// You can optionally use a cache to preserve calculated values across
/// calls to a layout container's methods. Many layout types don't need
/// a cache, because SwiftUI automatically reuses both the results of
/// calls into the layout and the values that the layout reads from its
/// subviews. Rely on the protocol's default implementation of this method
/// if you don't need a cache.
///
/// However you might find a cache useful when:
///
/// - The layout container repeats complex, intermediate calculations
/// across calls like ``sizeThatFits(proposal:subviews:cache:)``,
/// ``placeSubviews(in:proposal:subviews:cache:)``, and
/// ``explicitAlignment(of:in:proposal:subviews:cache:)-8ofeu``.
/// You might be able to improve performance by calculating values
/// once and storing them in a cache.
/// - The layout container reads many ``LayoutValueKey`` values from
/// subviews. It might be more efficient to do that once and store the
/// results in the cache, rather than rereading the subviews' values before
/// each layout call.
/// - You want to maintain working storage, like temporary Swift arrays,
/// across calls into the layout, to minimize the number of allocation
/// events.
///
/// Only implement a cache if profiling shows that it improves performance.
///
/// ### Initialize a cache
///
/// Implement the `makeCache(subviews:)` method to create a cache.
/// You can add computed values to the cache right away, using information
/// from the `subviews` input parameter, or you can do that later. The
/// methods of the ``Layout`` protocol that can access the cache
/// take the cache as an in-out parameter, which enables you to modify
/// the cache anywhere that you can read it.
///
/// You can use any storage type that makes sense for your layout
/// algorithm, but be sure that you only store data that you derive
/// from the layout and its subviews (lazily, if possible). For this to
/// work correctly, SwiftUI needs to be able to call this method to
/// recreate the cache without changing the layout result.
///
/// When you return a cache from this method, you implicitly define a type
/// for your cache. Be sure to either make the type of the `cache`
/// parameters on your other ``Layout`` protocol methods match, or use
/// a type alias to define the ``Cache`` associated type.
///
/// ### Update the cache
///
/// If the layout container or any of its subviews change, SwiftUI
/// calls the ``updateCache(_:subviews:)-9hkj9`` method so you can
/// modify or invalidate the contents of the
/// cache. The default implementation of that method calls the
/// `makeCache(subviews:)` method to recreate the cache, but you can
/// provide your own implementation of the update method to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
///
/// - Returns: Storage for calculated data that you share among
///   the methods of your custom layout container.
public func makeCache(subviews: GridLayout.Subviews) -> GridLayout.Cache
/// Updates the layout's cache when something changes.
///
/// If your custom layout container creates a cache by implementing the
/// ``makeCache(subviews:)-23agy`` method, SwiftUI calls the update method
/// when your layout or its subviews change, giving you an opportunity
/// to modify or invalidate the contents of the cache.
/// The method's default implementation recreates the
/// cache by calling the ``makeCache(subviews:)-23agy`` method,
/// but you can provide your own implementation to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - cache: Storage for calculated data that you share among
///     the methods of your custom layout container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
public func updateCache(_ cache: inout GridLayout.Cache, subviews: GridLayout.Subviews)
/// Returns the preferred spacing values of the composite view.
///
/// Implement this method to provide custom spacing preferences
/// for a layout container. The value you return affects
/// the spacing around the container, but it doesn't affect how the
/// container arranges subviews relative to one another inside the
/// container.
///
/// Create a custom ``ViewSpacing`` instance for your container by
/// initializing one with default values, and then merging that with
/// spacing instances of certain subviews. For example, if you define
/// a basic vertical stack that places subviews in a column, you could
/// use the spacing preferences of the subview edges that make
/// contact with the container's edges:
///
///     extension BasicVStack {
///         func spacing(subviews: Subviews, cache: inout ()) -> ViewSpacing {
///             var spacing = ViewSpacing()
///
///             for index in subviews.indices {
///                 var edges: Edge.Set = [.leading, .trailing]
///                 if index == 0 { edges.formUnion(.top) }
///                 if index == subviews.count - 1 { edges.formUnion(.bottom) }
///                 spacing.formUnion(subviews[index].spacing, edges: edges)
///             }
///
///             return spacing
///         }
///     }
///
/// In the above example, the first and last subviews contribute to the
/// spacing above and below the container, respectively, while all subviews
/// affect the spacing on the leading and trailing edges.
///
/// If you don't implement this method, the protocol provides a default
/// implementation, namely ``Layout/spacing(subviews:cache:)-1z0gt``,
/// that merges the spacing preferences across all subviews on all edges.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much spacing the container prefers around it.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A ``ViewSpacing`` instance that describes the preferred
///   spacing around the container view.
public func spacing(subviews: GridLayout.Subviews, cache: inout GridLayout.Cache) -> ViewSpacing
/// Returns the size of the composite view, given a proposed size
/// and the view's subviews.
///
/// Implement this method to tell your custom layout container's parent
/// view how much space the container needs for a set of subviews, given
/// a size proposal. The parent might call this method more than once
/// during a layout pass with different proposed sizes to test the
/// flexibility of the container, using proposals like:
///
/// * The ``ProposedViewSize/zero`` proposal; respond with the
///   layout's minimum size.
/// * The ``ProposedViewSize/infinity`` proposal; respond with the
///   layout's maximum size.
/// * The ``ProposedViewSize/unspecified`` proposal; respond with the
///   layout's ideal size.
///
/// The parent might also choose to test flexibility in one dimension at a
/// time. For example, a horizontal stack might propose a fixed height and
/// an infinite width, and then the same height with a zero width.
///
/// The following example calculates the size for a basic vertical stack
/// that places views in a column, with no spacing between the views:
///
///     private struct BasicVStack: Layout {
///         func sizeThatFits(
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGSize {
///             subviews.reduce(CGSize.zero) { result, subview in
///                 let size = subview.sizeThatFits(.unspecified)
///                 return CGSize(
///                     width: max(result.width, size.width),
///                     height: result.height + size.height)
///             }
///         }
///
///         // This layout also needs a placeSubviews() implementation.
///     }
///
/// The implementation asks each subview for its ideal size by calling the
/// ``LayoutSubview/sizeThatFits(_:)`` method with an
/// ``ProposedViewSize/unspecified`` proposed size.
/// It then reduces these values into a single size that represents
/// the maximum subview width and the sum of subview heights.
/// Because this example isn't flexible, it ignores its size proposal
/// input and always returns the same value for a given set of subviews.
///
/// SwiftUI views choose their own size, so the layout engine always
/// uses a value that you return from this method as the actual size of the
/// composite view. That size factors into the construction of the `bounds`
/// input to the ``placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// - Parameters:
///   - proposal: A size proposal for the container. The container's parent
///     view that calls this method might call the method more than once
///     with different proposals to learn more about the container's
///     flexibility before deciding which proposal to use for placement.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much space the container needs to display them.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A size that indicates how much space the container
///   needs to arrange its subviews.
public func sizeThatFits(proposal: ProposedViewSize, subviews: GridLayout.Subviews, cache: inout GridLayout.Cache) -> CGSize
/// Assigns positions to each of the layout's subviews.
///
/// SwiftUI calls your implementation of this method to tell your
/// custom layout container to place its subviews. From this method, call
/// the ``LayoutSubview/place(at:anchor:proposal:)`` method on each
/// element in `subviews` to tell the subviews where to appear in the
/// user interface.
///
/// For example, you can create a basic vertical stack that places views
/// in a column, with views horizontally aligned on their leading edge:
///
///     struct BasicVStack: Layout {
///         func placeSubviews(
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) {
///             var point = bounds.origin
///             for subview in subviews {
///                 subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///                 point.y += subview.dimensions(in: .unspecified).height
///             }
///         }
///
///         // This layout also needs a sizeThatFits() implementation.
///     }
///
/// The example creates a placement point that starts at the origin of the
/// specified `bounds` input and uses that to place the first subview. It
/// then moves the point in the y dimension by the subview's height,
/// which it reads using the ``LayoutSubview/dimensions(in:)`` method.
/// This prepares the point for the next iteration of the loop. All
/// subview operations use an ``ProposedViewSize/unspecified`` size
/// proposal to indicate that subviews should use and report their ideal
/// size.
///
/// A more complex layout container might add space between subviews
/// according to their ``LayoutSubview/spacing`` preferences, or a
/// fixed space based on input configuration. For example, you can extend
/// the basic vertical stack's placement method to calculate the
/// preferred distances between adjacent subviews and store the results in
/// an array:
///
///     let spacing: [CGFloat] = subviews.indices.dropLast().map { index in
///         subviews[index].spacing.distance(
///             to: subviews[index + 1].spacing,
///             along: .vertical)
///     }
///
/// The spacing's ``ViewSpacing/distance(to:along:)`` method considers the
/// preferences of adjacent views on the edge where they meet. It returns
/// the smallest distance that satisfies both views' preferences for the
/// given edge. For example, if one view prefers at least `2` points on its
/// bottom edge, and the next view prefers at least `8` points on its top
/// edge, the distance method returns `8`, because that's the smallest
/// value that satisfies both preferences.
///
/// Update the placement calculations to use the spacing values:
///
///     var point = bounds.origin
///     for (index, subview) in subviews.enumerated() {
///         if index > 0 { point.y += spacing[index - 1] } // Add spacing.
///         subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///         point.y += subview.dimensions(in: .unspecified).height
///     }
///
/// Be sure that you use computations during placement that are consistent
/// with those in your implementation of other protocol methods for a given
/// set of inputs. For example, if you add spacing during placement,
/// make sure your implementation of
/// ``sizeThatFits(proposal:subviews:cache:)`` accounts for the extra space.
/// Similarly, if the sizing method returns different values for different
/// size proposals, make sure the placement method responds to its
/// `proposal` input in the same way.
///
/// - Parameters:
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///     Place all the container's subviews within the region.
///     The size of this region matches a size that your container
///     previously returned from a call to the
///     ``sizeThatFits(proposal:subviews:cache:)`` method.
///   - proposal: The size proposal from which the container generated the
///     size that the parent used to create the `bounds` parameter.
///     The parent might propose more than one size before calling the
///     placement method, but it always uses one of the proposals and the
///     corresponding returned size when placing the container.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. Use the proxies in the collection
///     to get information about the subviews and to tell the subviews
///     where to appear.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
public func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: GridLayout.Subviews, cache: inout GridLayout.Cache)
/// Returns the position of the specified horizontal alignment guide along
/// the x axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can indent the container's leading edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: HorizontalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .leading {
///                 return bounds.minX + 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``HorizontalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
public func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: GridLayout.Subviews, cache: inout GridLayout.Cache) -> CGFloat?
/// Returns the position of the specified vertical alignment guide along
/// the y axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can raise the container's bottom edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: VerticalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .bottom {
///                 return bounds.minY - 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``VerticalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
public func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: GridLayout.Subviews, cache: inout GridLayout.Cache) -> CGFloat?
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
}
extension GridLayout {
/// A stateful grid layout algorithm.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct Cache {
}
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension GridLayout : Sendable {
}
/// A horizontal row in a two dimensional grid container.
///
/// Use one or more `GridRow` instances to define the rows of a ``Grid``
/// container. The child views inside the row define successive grid cells.
/// You can add rows to the grid explicitly, or use the ``ForEach`` structure
/// to generate multiple rows. Similarly, you can add cells to the row
/// explicitly or you can use ``ForEach`` to generate multiple cells inside
/// the row. The following example mixes these strategies:
///
///     Grid {
///         GridRow {
///             Color.clear
///                 .gridCellUnsizedAxes([.horizontal, .vertical])
///             ForEach(1..<4) { column in
///                 Text("C\(column)")
///             }
///         }
///         ForEach(1..<4) { row in
///             GridRow {
///                 Text("R\(row)")
///                 ForEach(1..<4) { _ in
///                     Circle().foregroundStyle(.mint)
///                 }
///             }
///         }
///     }
///
/// The grid in the example above has an explicit first row and three generated
/// rows. Similarly, each row has an explicit first cell and three generated
/// cells:
///
/// ![A screenshot of a grid that contains four rows and four columns. Scanning
/// from left to right, the first row contains an empty cell followed by cells
/// with the strings C1, C2, and C3. Scanning from top to bottom, the first
/// column contains an empty cell, followed by cells with the strings R1, R2,
/// and R3. All the other cells contain circles in a mint color.](GridRow-1-iOS)
///
/// To create an empty cell, use something invisible, like the
/// ``ShapeStyle/clear`` color that appears in the first column of the first
/// row in the example above. However, if you use a flexible view like a
/// ``Color`` or a ``Spacer``, you might also need to add the
/// ``View/gridCellUnsizedAxes(_:)`` modifier to prevent the view from
/// taking up more space than the other cells in the row or column need.
///
/// > Important: You can't use ``EmptyView`` to create a blank cell because
/// that resolves to the absence of a view and doesn't generate a cell.
///
/// By default, the cells in the row use the ``Alignment`` that you define
/// when you initialize the ``Grid``. However, you can override the vertical
/// alignment for the cells in a row by providing a ``VerticalAlignment``
/// value to the row's ``init(alignment:content:)`` initializer.
///
/// If you apply a view modifier to a row, the row applies the modifier to
/// all of the cells, similar to how a ``Group`` behaves. For example,  if
/// you apply the ``View/border(_:width:)`` modifier to a row, SwiftUI draws
/// a border on each cell in the row rather than around the row.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct GridRow<Content> where Content : View {
/// Creates a horizontal row of child views in a grid.
///
/// Use this initializer to create a ``GridRow`` inside of a ``Grid``.
/// Provide a content closure that defines the cells of the row, and
/// optionally customize the vertical alignment of content within each cell.
/// The following example customizes the vertical alignment of the cells
/// in the first and third rows:
///
///     Grid(alignment: .trailing) {
///         GridRow(alignment: .top) { // Use top vertical alignment.
///             Text("Top")
///             Color.red.frame(width: 1, height: 50)
///             Color.blue.frame(width: 50, height: 1)
///         }
///         GridRow { // Use the default (center) alignment.
///             Text("Center")
///             Color.red.frame(width: 1, height: 50)
///             Color.blue.frame(width: 50, height: 1)
///         }
///         GridRow(alignment: .bottom) { // Use bottom vertical alignment.
///             Text("Bottom")
///             Color.red.frame(width: 1, height: 50)
///             Color.blue.frame(width: 50, height: 1)
///         }
///     }
///
/// The example above specifies ``Alignment/trailing`` alignment for the
/// grid, which is composed of ``VerticalAlignment/center`` vertical
/// alignment and ``HorizontalAlignment/trailing`` horizontal alignment.
/// The middle row relies on the center vertical alignment, but the
/// other two rows specify custom vertical alignments:
///
/// ![A grid with three rows and three columns. Scanning from top to bottom,
/// the first column contains cells with the strings top, center, and
/// bottom. All strings are horizontally aligned on the right and vertically
/// aligned in a way that matches their content. The second column contains
/// cells with red vertical lines. The lines consume both the full height
/// and full width of the cells they occupy. The third column contains
/// cells with blue horizontal lines that consume the full width of the
/// cells they occupy, and that are vertically aligned in a way that matches
/// the text in column one of the corresponding row.](GridRow-init-1-iOS)
///
/// > Important: A grid row behaves like a ``Group`` if you create it
/// outside of a grid.
///
/// To override column alignment, use ``View/gridColumnAlignment(_:)``. To
/// override alignment for a single cell, use ``View/gridCellAnchor(_:)``.
///
/// - Parameters:
///   - alignment: An optional ``VerticalAlignment`` for the row. If you
///     don't specify a value, the row uses the vertical alignment component
///     of the ``Alignment`` parameter that you specify in the grid's
///     ``Grid/init(alignment:horizontalSpacing:verticalSpacing:content:)``
///     initializer, which is ``VerticalAlignment/center`` by default.
///   - content: The builder closure that contains the child views. Each
///     view in the closure implicitly maps to a cell in the grid.
///
@inlinable public init(alignment: VerticalAlignment? = nil, @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension GridRow : View {
}
/// A type that collects multiple instances of a content type --- like views,
/// scenes, or commands --- into a single unit.
///
/// Use a group to collect multiple views into a single instance, without
/// affecting the layout of those views, like an ``SwiftUI/HStack``,
/// ``SwiftUI/VStack``, or ``SwiftUI/Section`` would. After creating a group,
/// any modifier you apply to the group affects all of that group's members.
/// For example, the following code applies the ``SwiftUI/Font/headline``
/// font to three views in a group.
///
///     Group {
///         Text("SwiftUI")
///         Text("Combine")
///         Text("Swift System")
///     }
///     .font(.headline)
///
/// Because you create a group of views with a ``SwiftUI/ViewBuilder``, you can
/// use the group's initializer to produce different kinds of views from a
/// conditional, and then optionally apply modifiers to them. The following
/// example uses a `Group` to add a navigation bar title,
/// regardless of the type of view the conditional produces:
///
///     Group {
///         if isLoggedIn {
///             WelcomeView()
///         } else {
///             LoginView()
///         }
///     }
///     .navigationBarTitle("Start")
///
/// The modifier applies to all members of the group --- and not to the group
/// itself. For example, if you apply ``View/onAppear(perform:)`` to the above
/// group, it applies to all of the views produced by the `if isLoggedIn`
/// conditional, and it executes every time `isLoggedIn` changes.
///
/// Because a group of views itself is a view, you can compose a group within
/// other view builders, including nesting within other groups. This allows you
/// to add large numbers of views to different view builder containers. The
/// following example uses a `Group` to collect 10 ``SwiftUI/Text`` instances,
/// meaning that the vertical stack's view builder returns only two views ---
/// the group, plus an additional ``SwiftUI/Text``:
///
///     var body: some View {
///         VStack {
///             Group {
///                 Text("1")
///                 Text("2")
///                 Text("3")
///                 Text("4")
///                 Text("5")
///                 Text("6")
///                 Text("7")
///                 Text("8")
///                 Text("9")
///                 Text("10")
///             }
///             Text("11")
///         }
///     }
///
/// You can initialize groups with several types other than ``SwiftUI/View``,
/// such as ``SwiftUI/Scene`` and ``SwiftUI/ToolbarContent``. The closure you
/// provide to the group initializer uses the corresponding builder type
/// (``SwiftUI/SceneBuilder``, ``SwiftUI/ToolbarContentBuilder``, and so on),
/// and the capabilities of these builders vary between types. For example,
/// you can use groups to return large numbers of scenes or toolbar content
/// instances, but not to return different scenes or toolbar content based
/// on conditionals.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Group<Content> {
/// The type for the internal content of this `AccessibilityRotorContent`.
public typealias Body = Never
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Group : AccessibilityRotorContent where Content : AccessibilityRotorContent {
/// The internal content of this `AccessibilityRotorContent`.
public var body: Never { get }
/// Creates an instance that generates Rotor content by combining, in order,
/// all the Rotor content specified in the passed-in result builder.
///
/// - Parameter content: The result builder that generates Rotor content for
///   the group.
public init(@AccessibilityRotorContentBuilder content: () -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Group : View where Content : View {
/// Creates a group of views.
/// - Parameter content: A ``SwiftUI/ViewBuilder`` that produces the views
/// to group.
@inlinable public init(@ViewBuilder content: () -> Content)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Group : Scene where Content : Scene {
/// Creates a group of scenes.
///
/// - Parameter content: A ``SwiftUI/SceneBuilder`` that produces the scenes
/// to group.
@inlinable public init(@SceneBuilder content: () -> Content)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Group : ToolbarContent where Content : ToolbarContent {
/// Creates a group of toolbar content instances.
///
/// - Parameter content: A ``SwiftUI/ToolbarContentBuilder`` that produces
/// the toolbar content instances to group.
public init(@ToolbarContentBuilder content: () -> Content)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Group : CustomizableToolbarContent where Content : CustomizableToolbarContent {
/// Creates a group of customizable toolbar content instances.
///
/// - Parameter content: A ``SwiftUI/ToolbarContentBuilder`` that produces
/// the customizable toolbar content instances to group.
public init(@ToolbarContentBuilder content: () -> Content)
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Group : TableColumnContent where Content : TableColumnContent {
/// The type of value of rows presented by this column content.
public typealias TableRowValue = Content.TableRowValue
/// The type of sort comparator associated with this table column content.
public typealias TableColumnSortComparator = Content.TableColumnSortComparator
/// The type of content representing the body of this table column content.
public typealias TableColumnBody = Never
/// Creates a group of table columns.
///
/// - Parameter content: A ``SwiftUI/TableColumnBuilder`` that produces the
///   columns to group.
@inlinable public init<R, C>(@TableColumnBuilder<R, C> content: () -> Content) where R == Content.TableRowValue, C == Content.TableColumnSortComparator
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Group : Commands where Content : Commands {
/// Creates a group of commands.
///
/// - Parameter content: A ``SwiftUI/CommandsBuilder`` that produces the
/// commands to group.
@inlinable public init(@CommandsBuilder content: () -> Content)
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Group : TableRowContent where Content : TableRowContent {
/// The type of value represented by this table row content.
public typealias TableRowValue = Content.TableRowValue
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// Creates a group of table rows.
///
/// - Parameter content: A ``SwiftUI/TableRowBuilder`` that produces the
///   rows to group.
@inlinable public init<R>(@TableRowBuilder<R> content: () -> Content) where R == Content.TableRowValue
}
/// A stylized view, with an optional label, that visually collects a logical
/// grouping of content.
///
/// Use a group box when you want to visually distinguish a portion of your
/// user interface with an optional title for the boxed content.
///
/// The following example sets up a `GroupBox` with the label "End-User
/// Agreement", and a long `agreementText` string in a ``SwiftUI/Text`` view
/// wrapped by a ``SwiftUI/ScrollView``. The box also contains a
/// ``SwiftUI/Toggle`` for the user to interact with after reading the text.
///
///     var body: some View {
///         GroupBox(label:
///             Label("End-User Agreement", systemImage: "building.columns")
///         ) {
///             ScrollView(.vertical, showsIndicators: true) {
///                 Text(agreementText)
///                     .font(.footnote)
///             }
///             .frame(height: 100)
///             Toggle(isOn: $userAgreed) {
///                 Text("I agree to the above terms")
///             }
///         }
///     }
///
/// ![An iOS status bar above a gray rounded rectangle region marking the bounds
/// of the group box. At the top of the region, the title End-User Agreement
/// in a large bold font with an icon of a building with columns. Below this,
/// a scroll view with six lines of text visible. At the bottom of the gray
/// group box region, a toggle switch with the label I agree to the above
/// terms.](SwiftUI-GroupBox-EULA.png)
///
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct GroupBox<Label, Content> : View where Label : View, Content : View {
/// Creates a group box with the provided label and view content.
/// - Parameters:
///   - content: A ``SwiftUI/ViewBuilder`` that produces the content for the
///     group box.
///   - label: A ``SwiftUI/ViewBuilder`` that produces a label for the group
///     box.
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension GroupBox where Label == GroupBoxStyleConfiguration.Label, Content == GroupBoxStyleConfiguration.Content {
/// Creates a group box based on a style configuration.
///
/// Use this initializer within the ``GroupBoxStyle/makeBody(configuration:)``
/// method of a ``GroupBoxStyle`` instance to create a styled group box,
/// with customizations, while preserving its existing style.
///
/// The following example adds a pink border around the group box,
/// without overriding its current style:
///
///     struct PinkBorderGroupBoxStyle: GroupBoxStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             GroupBox(configuration)
///                 .border(Color.pink)
///         }
///     }
/// - Parameter configuration: The properties of the group box instance being created.
public init(_ configuration: GroupBoxStyleConfiguration)
}
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension GroupBox where Label == EmptyView {
/// Creates an unlabeled group box with the provided view content.
/// - Parameters:
///   - content: A ``SwiftUI/ViewBuilder`` that produces the content for
///    the group box.
public init(@ViewBuilder content: () -> Content)
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension GroupBox where Label == Text {
/// Creates a group box with the provided view content and title.
/// - Parameters:
///   - titleKey: The key for the group box's title, which describes the
///     content of the group box.
///   - content: A ``SwiftUI/ViewBuilder`` that produces the content for the
///     group box.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content)
/// Creates a group box with the provided view content.
/// - Parameters:
///   - title: A string that describes the content of the group box.
///   - content: A ``SwiftUI/ViewBuilder`` that produces the content for the
///     group box.
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol
}
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension GroupBox {
@available(iOS, deprecated: 100000.0, renamed: "GroupBox(content:label:)")
@available(macOS, deprecated: 100000.0, renamed: "GroupBox(content:label:)")
@available(visionOS, deprecated: 100000.0, renamed: "GroupBox(content:label:)")
public init(label: Label, @ViewBuilder content: () -> Content)
}
/// A type that specifies the appearance and interaction of all group boxes
/// within a view hierarchy.
///
/// To configure the current `GroupBoxStyle` for a view hierarchy, use the
/// ``View/groupBoxStyle(_:)`` modifier.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol GroupBoxStyle {
/// A view that represents the body of a group box.
associatedtype Body : View
/// Creates a view representing the body of a group box.
///
/// SwiftUI calls this method for each instance of ``SwiftUI/GroupBox``
/// created within a view hierarchy where this style is the current
/// group box style.
///
/// - Parameter configuration: The properties of the group box instance being
///   created.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a group box instance.
typealias Configuration = GroupBoxStyleConfiguration
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension GroupBoxStyle where Self == DefaultGroupBoxStyle {
/// The default style for group box views.
public static var automatic: DefaultGroupBoxStyle { get }
}
/// The properties of a group box instance.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct GroupBoxStyleConfiguration {
/// A type-erased label of a group box.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased content of a group box.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that provides the title of the group box.
public let label: GroupBoxStyleConfiguration.Label
/// A view that represents the content of the group box.
public let content: GroupBoxStyleConfiguration.Content
}
/// A form style with grouped rows.
///
/// Rows in this form style have leading aligned labels and trailing
/// aligned controls within visually grouped sections.
///
/// Use the ``FormStyle/grouped`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.grouped)
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct GroupedFormStyle : FormStyle {
/// Creates a form style with scrolling, grouped rows.
///
/// Don't call this initializer directly. Instead, use the
/// ``FormStyle/grouped`` static variable to create this style:
///
///     Form {
///        ...
///     }
///     .formStyle(.grouped)
///
public init()
/// Creates a view that represents the body of a form.
///
/// - Parameter configuration: The properties of the form.
/// - Returns: A view that has behavior and appearance that enables it
///   to function as a ``Form``.
public func makeBody(configuration: GroupedFormStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a form.
public typealias Body = some View
}
/// The list style that describes the behavior and appearance of a grouped list.
///
/// You can also use ``ListStyle/grouped`` to construct this style.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public struct GroupedListStyle : ListStyle {
/// Creates a grouped list style.
public init()
}
/// A view that arranges its subviews in a horizontal line.
///
/// Unlike ``LazyHStack``, which only renders the views when your app needs to
/// display them onscreen, an `HStack` renders the views all at once, regardless
/// of whether they are on- or offscreen. Use the regular `HStack` when you have
/// a small number of subviews or don't want the delayed rendering behavior
/// of the "lazy" version.
///
/// The following example shows a simple horizontal stack of five text views:
///
///     var body: some View {
///         HStack(
///             alignment: .top,
///             spacing: 10
///         ) {
///             ForEach(
///                 1...5,
///                 id: \.self
///             ) {
///                 Text("Item \($0)")
///             }
///         }
///     }
///
/// ![Five text views, named Item 1 through Item 5, arranged in a
/// horizontal row.](SwiftUI-HStack-simple.png)
///
/// > Note: If you need a horizontal stack that conforms to the ``Layout``
/// protocol, like when you want to create a conditional layout using
/// ``AnyLayout``, use ``HStackLayout`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct HStack<Content> : View where Content : View {
/// Creates a horizontal stack with the given spacing and vertical alignment.
///
/// - Parameters:
///   - alignment: The guide for aligning the subviews in this stack. This
///     guide has the same vertical screen coordinate for every subview.
///   - spacing: The distance between adjacent subviews, or `nil` if you
///     want the stack to choose a default distance for each pair of
///     subviews.
///   - content: A view builder that creates the content of this stack.
@inlinable public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A horizontal container that you can use in conditional layouts.
///
/// This layout container behaves like an ``HStack``, but conforms to the
/// ``Layout`` protocol so you can use it in the conditional layouts that you
/// construct with ``AnyLayout``. If you don't need a conditional layout, use
/// ``HStack`` instead.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct HStackLayout : Layout {
/// The vertical alignment of subviews.
public var alignment: VerticalAlignment
/// The distance between adjacent subviews.
///
/// Set this value to `nil` to use default distances between subviews.
public var spacing: CGFloat?
/// Creates a horizontal stack with the specified spacing and vertical
/// alignment.
///
/// - Parameters:
///     - alignment: The guide for aligning the subviews in this stack. It
///       has the same vertical screen coordinate for all subviews.
///     - spacing: The distance between adjacent subviews. Set this value
///       to `nil` to use default distances between subviews.
@inlinable public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil)
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// Cached values associated with the layout instance.
///
/// If you create a cache for your custom layout, you can use
/// a type alias to define this type as your data storage type.
/// Alternatively, you can refer to the data storage type directly in all
/// the places where you work with the cache.
///
/// See ``makeCache(subviews:)-23agy`` for more information.
public typealias Cache
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension HStackLayout : Sendable {
}
/// A shape style that maps to one of the numbered content styles.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public struct HierarchicalShapeStyle : ShapeStyle {
/// A shape style that maps to the first level of the current
/// content style.
public static let primary: HierarchicalShapeStyle
/// A shape style that maps to the second level of the current
/// content style.
public static let secondary: HierarchicalShapeStyle
/// A shape style that maps to the third level of the current
/// content style.
public static let tertiary: HierarchicalShapeStyle
/// A shape style that maps to the fourth level of the current
/// content style.
public static let quaternary: HierarchicalShapeStyle
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 16.0, macOS 12.0, macCatalyst 15.0, tvOS 17.0, watchOS 10.0, *)
extension HierarchicalShapeStyle {
/// A shape style that maps to the fifth level of the current
/// content style.
public static let quinary: HierarchicalShapeStyle
}
/// Styles that you can apply to hierarchical shapes.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct HierarchicalShapeStyleModifier<Base> : ShapeStyle where Base : ShapeStyle {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// An alignment position along the horizontal axis.
///
/// Use horizontal alignment guides to tell SwiftUI how to position views
/// relative to one another horizontally, like when you place views vertically
/// in an ``VStack``. The following example demonstrates common built-in
/// horizontal alignments:
///
/// ![Three columns of content. Each column contains a string
/// inside a box with a vertical line above and below the box. The
/// lines are aligned horizontally with the text in a different way for each
/// column. The lines for the left-most string, labeled Leading, align with
/// the left edge of the string. The lines for the middle string, labeled
/// Center, align with the center of the string. The lines for the right-most
/// string, labeled Trailing, align with the right edge of the
/// string.](HorizontalAlignment-1-iOS)
///
/// You can generate the example above by creating a series of columns
/// implemented as vertical stacks, where you configure each stack with a
/// different alignment guide:
///
///     private struct HorizontalAlignmentGallery: View {
///         var body: some View {
///             HStack(spacing: 30) {
///                 column(alignment: .leading, text: "Leading")
///                 column(alignment: .center, text: "Center")
///                 column(alignment: .trailing, text: "Trailing")
///             }
///             .frame(height: 150)
///         }
///
///         private func column(alignment: HorizontalAlignment, text: String) -> some View {
///             VStack(alignment: alignment, spacing: 0) {
///                 Color.red.frame(width: 1)
///                 Text(text).font(.title).border(.gray)
///                 Color.red.frame(width: 1)
///             }
///         }
///     }
///
/// During layout, SwiftUI aligns the views inside each stack by bringing
/// together the specified guides of the affected views. SwiftUI calculates
/// the position of a guide for a particular view based on the characteristics
/// of the view. For example, the ``HorizontalAlignment/center`` guide appears
/// at half the width of the view. You can override the guide calculation for a
/// particular view using the ``View/alignmentGuide(_:computeValue:)-9mdoh``
/// view modifier.
///
/// ### Layout direction
///
/// When a user configures their device to use a left-to-right language like
/// English, the system places the leading alignment on the left and the
/// trailing alignment on the right, as the example from the previous section
/// demonstrates. However, in a right-to-left language, the system reverses
/// these. You can see this by using the ``View/environment(_:_:)`` view
/// modifier to explicitly override the ``EnvironmentValues/layoutDirection``
/// environment value for the view defined above:
///
///     HorizontalAlignmentGallery()
///         .environment(\.layoutDirection, .rightToLeft)
///
/// ![Three columns of content. Each column contains a string
/// inside a box with a vertical line above and below the box. The
/// lines are aligned horizontally with the text in a different way for each
/// column. The lines for the left-most string, labeled Trailing, align with
/// the left edge of the string. The lines for the middle string, labeled
/// Center, align with the center of the string. The lines for the right-most
/// string, labeled Leading, align with the right edge of the
/// string.](HorizontalAlignment-2-iOS)
///
/// This automatic layout adjustment makes it easier to localize your app,
/// but it's still important to test your app for the different locales that
/// you ship into. For more information about the localization process, see
/// <doc://com.apple.documentation/documentation/Xcode/localization>.
///
/// ### Custom alignment guides
///
/// You can create a custom horizontal alignment by creating a type that
/// conforms to the ``AlignmentID`` protocol, and then using that type to
/// initalize a new static property on `HorizontalAlignment`:
///
///     private struct OneQuarterAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.width / 4
///         }
///     }
///
///     extension HorizontalAlignment {
///         static let oneQuarter = HorizontalAlignment(OneQuarterAlignment.self)
///     }
///
/// You implement the ``AlignmentID/defaultValue(in:)`` method to calculate
/// a default value for the custom alignment guide. The method receives a
/// ``ViewDimensions`` instance that you can use to calculate an appropriate
/// value based on characteristics of the view. The example above places
/// the guide at one quarter of the width of the view, as measured from the
/// view's origin.
///
/// You can then use the custom alignment guide like any built-in guide. For
/// example, you can use it as the `alignment` parameter to a ``VStack``,
/// or you can change it for a specific view using the
/// ``View/alignmentGuide(_:computeValue:)-9mdoh`` view modifier.
/// Custom alignment guides also automatically reverse in a right-to-left
/// environment, just like built-in guides.
///
/// ### Composite alignment
///
/// Combine a ``VerticalAlignment`` with a `HorizontalAlignment` to create a
/// composite ``Alignment`` that indicates both vertical and horizontal
/// positioning in one value. For example, you could combine your custom
/// `oneQuarter` horizontal alignment from the previous section with a built-in
/// ``VerticalAlignment/center`` vertical alignment to use in a ``ZStack``:
///
///     struct LayeredVerticalStripes: View {
///         var body: some View {
///             ZStack(alignment: Alignment(horizontal: .oneQuarter, vertical: .center)) {
///                 verticalStripes(color: .blue)
///                     .frame(width: 300, height: 150)
///                 verticalStripes(color: .green)
///                     .frame(width: 180, height: 80)
///             }
///         }
///
///         private func verticalStripes(color: Color) -> some View {
///             HStack(spacing: 1) {
///                 ForEach(0..<4) { _ in color }
///             }
///         }
///     }
///
/// The example above uses widths and heights that generate two mismatched sets
/// of four vertical stripes. The ``ZStack`` centers the two sets vertically and
/// aligns them horizontally one quarter of the way from the leading edge of
/// each set. In a left-to-right locale, this aligns the right edges of the
/// left-most stripes of each set:
///
/// ![Two sets of four rectangles. The first set is blue. The
/// second set is green, is smaller, and is layered on top of the first set.
/// The two sets are centered vertically, but align horizontally at the right
/// edge of each set's left-most rectangle.](HorizontalAlignment-3-iOS)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct HorizontalAlignment : Equatable {
/// Creates a custom horizontal alignment of the specified type.
///
/// Use this initializer to create a custom horizontal alignment. Define
/// an ``AlignmentID`` type, and then use that type to create a new
/// static property on ``HorizontalAlignment``:
///
///     private struct OneQuarterAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.width / 4
///         }
///     }
///
///     extension HorizontalAlignment {
///         static let oneQuarter = HorizontalAlignment(OneQuarterAlignment.self)
///     }
///
/// Every horizontal alignment instance that you create needs a unique
/// identifier. For more information, see ``AlignmentID``.
///
/// - Parameter id: The type of an identifier that uniquely identifies a
///   horizontal alignment.
public init(_ id: AlignmentID.Type)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: HorizontalAlignment, b: HorizontalAlignment) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension HorizontalAlignment {
/// Merges a sequence of explicit alignment values produced by
/// this instance.
///
/// For built-in horizontal alignment types, this method returns the mean
/// of all non-`nil` values.
public func combineExplicit<S>(_ values: S) -> CGFloat? where S : Sequence, S.Element == CGFloat?
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension HorizontalAlignment {
/// A guide that marks the leading edge of the view.
///
/// Use this guide to align the leading edges of views.
/// For a device that uses a left-to-right language, the leading edge
/// is on the left:
///
/// ![A box that contains the word, Leading. Vertical
/// lines appear above and below the box. The lines align horizontally
/// with the left edge of the box.](HorizontalAlignment-leading-1-iOS)
///
/// The following code generates the image above using a ``VStack``:
///
///     struct HorizontalAlignmentLeading: View {
///         var body: some View {
///             VStack(alignment: .leading, spacing: 0) {
///                 Color.red.frame(width: 1)
///                 Text("Leading").font(.title).border(.gray)
///                 Color.red.frame(width: 1)
///             }
///         }
///     }
///
public static let leading: HorizontalAlignment
/// A guide that marks the horizontal center of the view.
///
/// Use this guide to align the centers of views:
///
/// ![A box that contains the word, Center. Vertical
/// lines appear above and below the box. The lines align horizontally
/// with the center of the box.](HorizontalAlignment-center-1-iOS)
///
/// The following code generates the image above using a ``VStack``:
///
///     struct HorizontalAlignmentCenter: View {
///         var body: some View {
///             VStack(alignment: .center, spacing: 0) {
///                 Color.red.frame(width: 1)
///                 Text("Center").font(.title).border(.gray)
///                 Color.red.frame(width: 1)
///             }
///         }
///     }
///
public static let center: HorizontalAlignment
/// A guide that marks the trailing edge of the view.
///
/// Use this guide to align the trailing edges of views.
/// For a device that uses a left-to-right language, the trailing edge
/// is on the right:
///
/// ![A box that contains the word, Trailing. Vertical
/// lines appear above and below the box. The lines align horizontally
/// with the right edge of the box.](HorizontalAlignment-trailing-1-iOS)
///
/// The following code generates the image above using a ``VStack``:
///
///     struct HorizontalAlignmentTrailing: View {
///         var body: some View {
///             VStack(alignment: .trailing, spacing: 0) {
///                 Color.red.frame(width: 1)
///                 Text("Trailing").font(.title).border(.gray)
///                 Color.red.frame(width: 1)
///             }
///         }
///     }
///
public static let trailing: HorizontalAlignment
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension HorizontalAlignment {
/// A guide marking the leading edge of a `List` row separator.
///
/// Use this guide to align the leading end of the bottom `List` row
/// separator with any other horizontal guide of a view that is part of the
/// cell content.
///
/// The following example shows the row separator aligned with the leading
/// edge of the `Text` containing the name of food:
///
///     List {
///         ForEach(favoriteFoods) { food in
///             HStack {
///                 Text(food.emoji)
///                     .font(.system(size: 40))
///                 Text(food.name)
///                     .alignmentGuide(.listRowSeparatorLeading) {
///                         $0[.leading]
///                     }
///             }
///         }
///     }
///
/// To change the visibility or tint of the row separator use respectively
/// ``View/listRowSeparator(_:edges:)`` and
/// ``View/listRowSeparatorTint(_:edges:)``.
///
public static let listRowSeparatorLeading: HorizontalAlignment
/// A guide marking the trailing edge of a `List` row separator.
///
/// Use this guide to align the trailing end of the bottom `List` row
/// separator with any other horizontal guide of a view that is part of the
/// cell content.
///
/// To change the visibility or tint of the row separator use respectively
/// ``View/listRowSeparator(_:edges:)`` and
/// ``View/listRowSeparatorTint(_:edges:)``.
///
public static let listRowSeparatorTrailing: HorizontalAlignment
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension HorizontalAlignment : Sendable {
}
/// An edge on the horizontal axis.
///
/// Use a horizontal edge for tasks like setting a swipe action with the
/// ``View/swipeActions(edge:allowsFullSwipe:content:)``
/// view modifier. The positions of the leading and trailing edges
/// depend on the locale chosen by the user.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public enum HorizontalEdge : Int8, CaseIterable, Codable {
/// The leading edge.
case leading
/// The trailing edge.
case trailing
/// An efficient set of `HorizontalEdge`s.
@frozen public struct Set : OptionSet {
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = HorizontalEdge.Set
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int8
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int8)
/// A set containing only the leading horizontal edge.
public static let leading: HorizontalEdge.Set
/// A set containing only the trailing horizontal edge.
public static let trailing: HorizontalEdge.Set
/// A set containing the leading and trailing horizontal edges.
public static let all: HorizontalEdge.Set
/// Creates an instance containing just `e`.
public init(_ edge: HorizontalEdge)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = HorizontalEdge.Set.Element
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
}
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: Int8)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [HorizontalEdge]
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
/// A collection of all values of this type.
public static var allCases: [HorizontalEdge] { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int8 { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension HorizontalEdge : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension HorizontalEdge : Hashable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension HorizontalEdge : RawRepresentable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension HorizontalEdge : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension HorizontalEdge.Set : Sendable {
}
/// An effect applied when the pointer hovers over a view.
@available(iOS 13.4, tvOS 16.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public struct HoverEffect {
/// An effect  that attempts to determine the effect automatically.
/// This is the default effect.
public static let automatic: HoverEffect
/// An effect  that morphs the pointer into a platter behind the view
/// and shows a light source indicating position.
///
/// On tvOS, it applies a projection effect accompanied with a specular
/// highlight on the view when contained within a focused view. It also
/// incorporates motion effects to produce a parallax effect by adjusting
/// the projection matrix and specular offset.
@available(tvOS 17.0, *)
public static let highlight: HoverEffect
/// An effect that slides the pointer under the view and disappears as the
/// view scales up and gains a shadow.
public static let lift: HoverEffect
}
/// The current hovering state and value of the pointer.
///
/// When you use the ``View/onContinuousHover(coordinateSpace:perform:)-8gyrl``
/// modifier, you can handle the hovering state using the `action` closure.
/// SwiftUI calls the closure with a phase value to indicate the current
/// hovering state. The following example updates `hoverLocation` and
/// `isHovering` based on the phase provided to the closure:
///
///     @State private var hoverLocation: CGPoint = .zero
///     @State private var isHovering = false
///
///     var body: some View {
///         VStack {
///             Color.red
///                 .frame(width: 400, height: 400)
///                 .onContinuousHover { phase in
///                     switch phase {
///                     case .active(let location):
///                         hoverLocation = location
///                         isHovering = true
///                     case .ended:
///                         isHovering = false
///                     }
///                 }
///                 .overlay {
///                     Rectangle()
///                         .frame(width: 50, height: 50)
///                         .foregroundColor(isHovering ? .green : .blue)
///                         .offset(x: hoverLocation.x, y: hoverLocation.y)
///                 }
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(watchOS, unavailable)
@frozen public enum HoverPhase : Equatable {
/// The pointer's location moved to the specified point within the view.
case active(CGPoint)
/// The pointer exited the view.
case ended
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: HoverPhase, b: HoverPhase) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(watchOS, unavailable)
extension HoverPhase : Sendable {
}
/// A label style that only displays the icon of the label.
///
/// You can also use ``LabelStyle/iconOnly`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct IconOnlyLabelStyle : LabelStyle {
/// Creates an icon-only label style.
public init()
/// Creates a view that represents the body of a label.
///
/// The system calls this method for each ``Label`` instance in a view
/// hierarchy where this style is the current label style.
///
/// - Parameter configuration: The properties of the label.
public func makeBody(configuration: IconOnlyLabelStyle.Configuration) -> some View
/// A view that represents the body of a label.
public typealias Body = some View
}
/// A transition that returns the input view, unmodified, as the output
/// view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct IdentityTransition : Transition {
public init()
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: IdentityTransition.Content, phase: TransitionPhase) -> IdentityTransition.Content
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
public static let properties: TransitionProperties
/// The type of view representing the body.
public typealias Body = IdentityTransition.Content
}
/// A view that displays an image.
///
/// Use an `Image` instance when you want to add images to your SwiftUI app.
/// You can create images from many sources:
///
/// * Image files in your app's asset library or bundle. Supported types include
/// PNG, JPEG, HEIC, and more.
/// * Instances of platform-specific image types, like
/// <doc://com.apple.documentation/documentation/UIKit/UIImage> and
/// <doc://com.apple.documentation/documentation/AppKit/NSImage>.
/// * A bitmap stored in a Core Graphics
///  <doc://com.apple.documentation/documentation/coregraphics/cgimage>
///  instance.
/// * System graphics from the SF Symbols set.
///
/// The following example shows how to load an image from the app's asset
/// library or bundle and scale it to fit within its container:
///
///     Image("Landscape_4")
///         .resizable()
///         .aspectRatio(contentMode: .fit)
///     Text("Water wheel")
///
/// ![An image of a water wheel and its adjoining building, resized to fit the
/// width of an iPhone display. The words Water wheel appear under this
/// image.](Image-1.png)
///
/// You can use methods on the `Image` type as well as
/// standard view modifiers to adjust the size of the image to fit your app's
/// interface. Here, the `Image` type's
/// ``Image/resizable(capInsets:resizingMode:)`` method scales the image to fit
/// the current view. Then, the
/// ``View/aspectRatio(_:contentMode:)-771ow`` view modifier adjusts
/// this resizing behavior to maintain the image's original aspect ratio, rather
/// than scaling the x- and y-axes independently to fill all four sides of the
/// view. The article
/// <doc:Fitting-Images-into-Available-Space> shows how to apply scaling,
/// clipping, and tiling to `Image` instances of different sizes.
///
/// An `Image` is a late-binding token; the system resolves its actual value
/// only when it's about to use the image in an environment.
///
/// ### Making images accessible
///
/// To use an image as a control, use one of the initializers that takes a
/// `label` parameter. This allows the system's accessibility frameworks to use
/// the label as the name of the control for users who use features like
/// VoiceOver. For images that are only present for aesthetic reasons, use an
/// initializer with the `decorative` parameter; the accessibility systems
/// ignore these images.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Image : Equatable, Sendable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: Image, rhs: Image) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// The orientation of an image.
///
/// Many image formats such as JPEG include orientation metadata in the
/// image data. In other cases, you can specify image orientation
/// in code. Properly specifying orientation is often important both for
/// displaying the image and for certain kinds of image processing.
///
/// In SwiftUI, you provide an orientation value when initializing an
/// ``Image`` from an existing
/// <doc://com.apple.documentation/documentation/coregraphics/cgimage>.
@frozen public enum Orientation : UInt8, CaseIterable, Hashable {
/// A value that indicates the original pixel data matches the image's
/// intended display orientation.
case up
/// A value that indicates a horizontal flip of the image from the
/// orientation of its original pixel data.
case upMirrored
/// A value that indicates a 180° rotation of the image from the
/// orientation of its original pixel data.
case down
/// A value that indicates a vertical flip of the image from the
/// orientation of its original pixel data.
case downMirrored
/// A value that indicates a 90° counterclockwise rotation from the
/// orientation of its original pixel data.
case left
/// A value that indicates a 90° clockwise rotation and horizontal
/// flip of the image from the orientation of its original pixel
/// data.
case leftMirrored
/// A value that indicates a 90° clockwise rotation of the image from
/// the orientation of its original pixel data.
case right
/// A value that indicates a 90° counterclockwise rotation and
/// horizontal flip from the orientation of its original pixel data.
case rightMirrored
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: UInt8)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [Image.Orientation]
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt8
/// A collection of all values of this type.
public static var allCases: [Image.Orientation] { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: UInt8 { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// Creates a labeled image that you can use as content for controls.
///
/// - Parameters:
///   - name: The name of the image resource to lookup, as well as the
///     localization key with which to label the image.
///   - bundle: The bundle to search for the image resource and localization
///     content. If `nil`, SwiftUI uses the main `Bundle`. Defaults to `nil`.
public init(_ name: String, bundle: Bundle? = nil)
/// Creates a labeled image that you can use as content for controls, with
/// the specified label.
///
/// - Parameters:
///   - name: The name of the image resource to lookup
///   - bundle: The bundle to search for the image resource. If `nil`,
///     SwiftUI uses the main `Bundle`. Defaults to `nil`.
///   - label: The label associated with the image. SwiftUI uses the label
///     for accessibility.
public init(_ name: String, bundle: Bundle? = nil, label: Text)
/// Creates an unlabeled, decorative image.
///
/// SwiftUI ignores this image for accessibility purposes.
///
/// - Parameters:
///   - name: The name of the image resource to lookup
///   - bundle: The bundle to search for the image resource. If `nil`,
///     SwiftUI uses the main `Bundle`. Defaults to `nil`.
public init(decorative name: String, bundle: Bundle? = nil)
/// Creates a system symbol image.
///
/// This initializer creates an image using a system-provided symbol. Use
/// [SF Symbols](https://developer.apple.com/design/resources/#sf-symbols)
/// to find symbols and their corresponding names.
///
/// To create a custom symbol image from your app's asset catalog, use
/// ``Image/init(_:bundle:)`` instead.
///
/// - Parameters:
///   - systemName: The name of the system symbol image.
///     Use the SF Symbols app to look up the names of system symbol images.
@available(macOS 11.0, *)
public init(systemName: String)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Image {
/// Creates a system symbol image with a variable value.
///
/// This initializer creates an image using a system-provided symbol. The
/// rendered symbol may alter its appearance to represent the value
/// provided in `variableValue`. Use
/// [SF Symbols](https://developer.apple.com/design/resources/#sf-symbols)
/// (version 4.0 or later) to find system symbols that support variable
/// values and their corresponding names.
///
/// The following example shows the effect of creating the `"chart.bar.fill"`
/// symbol with different values.
///
///     HStack{
///         Image(systemName: "chart.bar.fill", variableValue: 0.3)
///         Image(systemName: "chart.bar.fill", variableValue: 0.6)
///         Image(systemName: "chart.bar.fill", variableValue: 1.0)
///     }
///     .font(.system(.largeTitle))
///
/// ![Three instances of the bar chart symbol, arranged horizontally.
/// The first fills one bar, the second fills two bars, and the last
/// symbol fills all three bars.](Image-3)
///
/// To create a custom symbol image from your app's asset
/// catalog, use ``Image/init(_:variableValue:bundle:)`` instead.
///
/// - Parameters:
///   - systemName: The name of the system symbol image.
///     Use the SF Symbols app to look up the names of system
///     symbol images.
///   - variableValue: An optional value between `0.0` and `1.0` that
///     the rendered image can use to customize its appearance, if
///     specified. If the symbol doesn't support variable values, this
///     parameter has no effect. Use the SF Symbols app to look up which
///     symbols support variable values.
public init(systemName: String, variableValue: Double?)
/// Creates a labeled image that you can use as content for controls,
/// with a variable value.
///
/// This initializer creates an image using a using a symbol in the
/// specified bundle. The rendered symbol may alter its appearance to
/// represent the value provided in `variableValue`.
///
/// > Note: See WWDC22 session [10158: Adopt variable color in SF
/// Symbols](https://developer.apple.com/wwdc22/10158/) for details
/// on how to create symbols that support variable values.
///
/// - Parameters:
///   - name: The name of the image resource to lookup, as well as
///     the localization key with which to label the image.
///   - variableValue: An optional value between `0.0` and `1.0` that
///     the rendered image can use to customize its appearance, if
///     specified. If the symbol doesn't support variable values, this
///     parameter has no effect.
///   - bundle: The bundle to search for the image resource and
///     localization content. If `nil`, SwiftUI uses the main
///     `Bundle`. Defaults to `nil`.
///
public init(_ name: String, variableValue: Double?, bundle: Bundle? = nil)
/// Creates a labeled image that you can use as content for controls, with
/// the specified label and variable value.
///
/// This initializer creates an image using a using a symbol in the
/// specified bundle. The rendered symbol may alter its appearance to
/// represent the value provided in `variableValue`.
///
/// > Note: See WWDC22 session [10158: Adopt variable color in SF
/// Symbols](https://developer.apple.com/wwdc22/10158/) for details on
/// how to create symbols that support variable values.
///
/// - Parameters:
///   - name: The name of the image resource to lookup.
///   - variableValue: An optional value between `0.0` and `1.0` that
///     the rendered image can use to customize its appearance, if
///     specified. If the symbol doesn't support variable values, this
///     parameter has no effect.
///   - bundle: The bundle to search for the image resource. If
///     `nil`, SwiftUI uses the main `Bundle`. Defaults to `nil`.
///   - label: The label associated with the image. SwiftUI uses
///     the label for accessibility.
///
public init(_ name: String, variableValue: Double?, bundle: Bundle? = nil, label: Text)
/// Creates an unlabeled, decorative image, with a variable value.
///
/// This initializer creates an image using a using a symbol in the
/// specified bundle. The rendered symbol may alter its appearance to
/// represent the value provided in `variableValue`.
///
/// > Note: See WWDC22 session [10158: Adopt variable color in SF
/// Symbols](https://developer.apple.com/wwdc22/10158/) for details on
/// how to create symbols that support variable values.
///
/// SwiftUI ignores this image for accessibility purposes.
///
/// - Parameters:
///   - name: The name of the image resource to lookup.
///   - variableValue: An optional value between `0.0` and `1.0` that
///     the rendered image can use to customize its appearance, if
///     specified. If the symbol doesn't support variable values, this
///     parameter has no effect.
///   - bundle: The bundle to search for the image resource. If
///     `nil`, SwiftUI uses the main `Bundle`. Defaults to `nil`.
///
public init(decorative name: String, variableValue: Double?, bundle: Bundle? = nil)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Image {
/// Initialize an `Image` with an image resource.
public init(_ resource: ImageResource)
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension Image {
/// Creates a SwiftUI image from a UIKit image instance.
/// - Parameter uiImage: The UIKit image to wrap with a SwiftUI ``Image``
/// instance.
public init(uiImage: UIImage)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Image {
public struct DynamicRange : Hashable, Sendable {
/// Restrict the image content dynamic range to the standard range.
public static let standard: Image.DynamicRange
/// Allow image content to use some extended range. This is
/// appropriate for placing HDR content next to SDR content.
public static let constrainedHigh: Image.DynamicRange
/// Allow image content to use an unrestricted extended range.
public static let high: Image.DynamicRange
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Image.DynamicRange, b: Image.DynamicRange) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Returns a new image configured with the specified allowed
/// dynamic range.
///
/// The following example enables HDR rendering for a specific
/// image view, assuming that the image has an HDR (ITU-R 2100)
/// color space and the output device supports it:
///
///     Image("hdr-asset").allowedDynamicRange(.high)
///
/// - Parameter range: the requested dynamic range, or nil to
///   restore the default allowed range.
///
/// - Returns: a new image.
public func allowedDynamicRange(_ range: Image.DynamicRange?) -> Image
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// The modes that SwiftUI uses to resize an image to fit within
/// its containing view.
public enum ResizingMode : Sendable {
/// A mode to repeat the image at its original size, as many
/// times as necessary to fill the available space.
case tile
/// A mode to enlarge or reduce the size of an image so that it
/// fills the available space.
case stretch
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Image.ResizingMode, b: Image.ResizingMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Sets the mode by which SwiftUI resizes an image to fit its space.
/// - Parameters:
///   - capInsets: Inset values that indicate a portion of the image that
///   SwiftUI doesn't resize.
///   - resizingMode: The mode by which SwiftUI resizes the image.
/// - Returns: An image, with the new resizing behavior set.
public func resizable(capInsets: EdgeInsets = EdgeInsets(), resizingMode: Image.ResizingMode = .stretch) -> Image
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// A type that indicates how SwiftUI renders images.
public enum TemplateRenderingMode : Sendable {
/// A mode that renders all non-transparent pixels as the foreground
/// color.
case template
/// A mode that renders pixels of bitmap images as-is.
///
/// For system images created from the SF Symbol set, multicolor symbols
/// respect the current foreground and accent colors.
case original
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Image.TemplateRenderingMode, b: Image.TemplateRenderingMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A scale to apply to vector images relative to text.
///
/// Use this type with the ``View/imageScale(_:)`` modifier, or the
/// ``EnvironmentValues/imageScale`` environment key, to set the image scale.
///
/// The following example shows the three `Scale` values as applied to
/// a system symbol image, each set against a text view:
///
///     HStack { Image(systemName: "swift").imageScale(.small); Text("Small") }
///     HStack { Image(systemName: "swift").imageScale(.medium); Text("Medium") }
///     HStack { Image(systemName: "swift").imageScale(.large); Text("Large") }
///
/// ![Vertically arranged text views that read Small, Medium, and
/// Large. On the left of each view is a system image that uses the Swift symbol.
/// The image next to the Small text is slightly smaller than the text.
/// The image next to the Medium text matches the size of the text. The
/// image next to the Large text is larger than the
/// text.](SwiftUI-EnvironmentAdditions-Image-scale.png)
///
@available(macOS 11.0, *)
public enum Scale : Sendable {
/// A scale that produces small images.
case small
/// A scale that produces medium-sized images.
case medium
/// A scale that produces large images.
case large
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Image.Scale, b: Image.Scale) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// Indicates whether SwiftUI renders an image as-is, or
/// by using a different mode.
///
/// The ``TemplateRenderingMode`` enumeration has two cases:
/// ``TemplateRenderingMode/original`` and ``TemplateRenderingMode/template``.
/// The original mode renders pixels as they appear in the original source
/// image. Template mode renders all nontransparent pixels as the
/// foreground color, which you can use for purposes like creating image
/// masks.
///
/// The following example shows both rendering modes, as applied to an icon
/// image of a green circle with darker green border:
///
///     Image("dot_green")
///         .renderingMode(.original)
///     Image("dot_green")
///         .renderingMode(.template)
///
/// ![Two identically-sized circle images. The circle on top is green
/// with a darker green border. The circle at the bottom is a solid color,
/// either white on a black background, or black on a white background,
/// depending on the system's current dark mode
/// setting.](SwiftUI-Image-TemplateRenderingMode-dots.png)
///
/// You also use `renderingMode` to produce multicolored system graphics
/// from the SF Symbols set. Use the ``TemplateRenderingMode/original``
/// mode to apply a foreground color to all parts of the symbol except
/// those that have a distinct color in the graphic. The following
/// example shows three uses of the `person.crop.circle.badge.plus` symbol
/// to achieve different effects:
///
/// * A default appearance with no foreground color or template rendering
/// mode specified. The symbol appears all black in light mode, and all
/// white in Dark Mode.
/// * The multicolor behavior achieved by using `original` template
/// rendering mode, along with a blue foreground color. This mode causes the
/// graphic to override the foreground color for distinctive parts of the
/// image, in this case the plus icon.
/// * A single-color template behavior achieved by using `template`
/// rendering mode with a blue foreground color. This mode applies the
/// foreground color to the entire image, regardless of the user's Appearance preferences.
///
///```swift
///HStack {
///    Image(systemName: "person.crop.circle.badge.plus")
///    Image(systemName: "person.crop.circle.badge.plus")
///        .renderingMode(.original)
///        .foregroundColor(.blue)
///    Image(systemName: "person.crop.circle.badge.plus")
///        .renderingMode(.template)
///        .foregroundColor(.blue)
///}
///.font(.largeTitle)
///```
///
/// ![A horizontal layout of three versions of the same symbol: a person
/// icon in a circle with a plus icon overlaid at the bottom left. Each
/// applies a diffent set of colors based on its rendering mode, as
/// described in the preceding
/// list.](SwiftUI-Image-TemplateRenderingMode-sfsymbols.png)
///
/// Use the SF Symbols app to find system images that offer the multicolor
/// feature. Keep in mind that some multicolor symbols use both the
/// foreground and accent colors.
///
/// - Parameter renderingMode: The mode SwiftUI uses to render images.
/// - Returns: A modified ``Image``.
public func renderingMode(_ renderingMode: Image.TemplateRenderingMode?) -> Image
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// The level of quality for rendering an image that requires interpolation,
/// such as a scaled image.
///
/// The ``Image/interpolation(_:)`` modifier specifies the interpolation
/// behavior when using the ``Image/resizable(capInsets:resizingMode:)``
/// modifier on an ``Image``. Use this behavior to prioritize rendering
/// performance or image quality.
public enum Interpolation : Sendable {
/// A value that indicates SwiftUI doesn't interpolate image data.
case none
/// A value that indicates a low level of interpolation quality, which may
/// speed up image rendering.
case low
/// A value that indicates a medium level of interpolation quality,
/// between the low- and high-quality values.
case medium
/// A value that indicates a high level of interpolation quality, which
/// may slow down image rendering.
case high
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Image.Interpolation, b: Image.Interpolation) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// Specifies the current level of quality for rendering an
/// image that requires interpolation.
///
/// See the article <doc:Fitting-Images-into-Available-Space> for examples
/// of using `interpolation(_:)` when scaling an ``Image``.
/// - Parameter interpolation: The quality level, expressed as a value of
/// the `Interpolation` type, that SwiftUI applies when interpolating
/// an image.
/// - Returns: An image with the given interpolation value set.
public func interpolation(_ interpolation: Image.Interpolation) -> Image
/// Specifies whether SwiftUI applies antialiasing when rendering
/// the image.
/// - Parameter isAntialiased: A Boolean value that specifies whether to
/// allow antialiasing. Pass `true` to allow antialising, `false` otherwise.
/// - Returns: An image with the antialiasing behavior set.
public func antialiased(_ isAntialiased: Bool) -> Image
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Image : Transferable {
/// The representation used to import and export the item.
///
/// A ``transferRepresentation`` can contain multiple representations
/// for different content types.
public static var transferRepresentation: some TransferRepresentation { get }
/// The type of the representation used to import and export the item.
///
/// Swift infers this type from the return value of the
/// ``transferRepresentation`` property.
public typealias Representation = some TransferRepresentation
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image {
/// Creates a labeled image based on a Core Graphics image instance, usable
/// as content for controls.
///
/// - Parameters:
///   - cgImage: The base graphical image.
///   - scale: The scale factor for the image,
///     with a value like `1.0`, `2.0`, or `3.0`.
///   - orientation: The orientation of the image. The default is
///     ``Image/Orientation/up``.
///   - label: The label associated with the image. SwiftUI uses the label
///     for accessibility.
public init(_ cgImage: CGImage, scale: CGFloat, orientation: Image.Orientation = .up, label: Text)
/// Creates an unlabeled, decorative image based on a Core Graphics image
/// instance.
///
/// SwiftUI ignores this image for accessibility purposes.
///
/// - Parameters:
///   - cgImage: The base graphical image.
///   - scale: The scale factor for the image,
///     with a value like `1.0`, `2.0`, or `3.0`.
///   - orientation: The orientation of the image. The default is
///     ``Image/Orientation/up``.
public init(decorative cgImage: CGImage, scale: CGFloat, orientation: Image.Orientation = .up)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Image {
/// Initializes an image of the given size, with contents provided by a
/// custom rendering closure.
///
/// Use this initializer to create an image by calling drawing commands on a
/// ``GraphicsContext`` provided to the `renderer` closure.
///
/// The following example shows a custom image created by passing a
/// `GraphicContext` to draw an ellipse and fill it with a gradient:
///
///     let mySize = CGSize(width: 300, height: 200)
///     let image = Image(size: mySize) { context in
///         context.fill(
///             Path(
///                 ellipseIn: CGRect(origin: .zero, size: mySize)),
///                 with: .linearGradient(
///                     Gradient(colors: [.yellow, .orange]),
///                     startPoint: .zero,
///                     endPoint: CGPoint(x: mySize.width, y:mySize.height))
///         )
///     }
///
/// ![An ellipse with a gradient that blends from yellow at the upper-
/// left to orange at the bottom-right.](Image-2)
///
/// - Parameters:
///   - size: The size of the newly-created image.
///   - label: The label associated with the image. SwiftUI uses the label
///     for accessibility.
///   - opaque: A Boolean value that indicates whether the image is fully
///     opaque. This may improve performance when `true`. Don't render
///     non-opaque pixels to an image declared as opaque. Defaults to `false`.
///   - colorMode: The working color space and storage format of the image.
///     Defaults to ``ColorRenderingMode/nonLinear``.
///   - renderer: A closure to draw the contents of the image. The closure
///     receives a ``GraphicsContext`` as its parameter.
public init(size: CGSize, label: Text? = nil, opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear, renderer: @escaping (inout GraphicsContext) -> Void)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Image {
/// Sets the rendering mode for symbol images within this view.
///
/// - Parameter mode: The symbol rendering mode to use.
///
/// - Returns: A view that uses the rendering mode you supply.
public func symbolRenderingMode(_ mode: SymbolRenderingMode?) -> Image
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.Orientation : RawRepresentable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.Orientation : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.ResizingMode : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.ResizingMode : Hashable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.TemplateRenderingMode : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.TemplateRenderingMode : Hashable {
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 11.0, *)
extension Image.Scale : Equatable {
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 11.0, *)
extension Image.Scale : Hashable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.Interpolation : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Image.Interpolation : Hashable {
}
/// A shape style that fills a shape by repeating a region of an image.
///
/// You can also use ``ShapeStyle/image(_:sourceRect:scale:)`` to construct this
/// style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ImagePaint : ShapeStyle {
/// The image to be drawn.
public var image: Image
/// A unit-space rectangle defining how much of the source image to draw.
///
/// The results are undefined if this rectangle selects areas outside the
/// `[0, 1]` range in either axis.
public var sourceRect: CGRect
/// A scale factor applied to the image while being drawn.
public var scale: CGFloat
/// Creates a shape-filling shape style.
///
/// - Parameters:
///   - image: The image to be drawn.
///   - sourceRect: A unit-space rectangle defining how much of the source
///     image to draw. The results are undefined if `sourceRect` selects
///     areas outside the `[0, 1]` range in either axis.
///   - scale: A scale factor applied to the image during rendering.
public init(image: Image, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1)
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// An object that creates images from SwiftUI views.
///
/// Use `ImageRenderer` to export bitmap image data from a SwiftUI view. You
/// initialize the renderer with a view, then render images on demand,
/// either by calling the ``render(rasterizationScale:renderer:)`` method, or
/// by using the renderer's properties to create a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGImage>,
/// <doc://com.apple.documentation/documentation/AppKit/NSImage>, or
/// <doc://com.apple.documentation/documentation/UIKit/UIImage>.
///
/// By drawing to a ``Canvas`` and exporting with an `ImageRenderer`,
/// you can generate images from any progammatically-rendered content, like
/// paths, shapes, gradients, and more. You can also render standard SwiftUI
/// views like ``Text`` views, or containers of multiple view types.
///
/// The following example uses a private `createAwardView(forUser:date:)` method
/// to create a game app's view of a trophy symbol with a user name and date.
/// This view combines a ``Canvas`` that applies a shadow filter with
/// two ``Text`` views into a ``VStack``. A ``Button`` allows the person to
/// save this view. The button's action uses an `ImageRenderer` to rasterize a
/// `CGImage` and then calls a private `uploadAchievementImage(_:)` method to
/// encode and upload the image.
///
///     var body: some View {
///         let trophyAndDate = createAwardView(forUser: playerName,
///                                              date: achievementDate)
///         VStack {
///             trophyAndDate
///             Button("Save Achievement") {
///                 let renderer = ImageRenderer(content: trophyAndDate)
///                 if let image = renderer.cgImage {
///                     uploadAchievementImage(image)
///                 }
///             }
///         }
///     }
///
///     private func createAwardView(forUser: String, date: Date) -> some View {
///         VStack {
///             Image(systemName: "trophy")
///                 .resizable()
///                 .frame(width: 200, height: 200)
///                 .frame(maxWidth: .infinity, maxHeight: .infinity)
///                 .shadow(color: .mint, radius: 5)
///             Text(playerName)
///                 .font(.largeTitle)
///             Text(achievementDate.formatted())
///         }
///         .multilineTextAlignment(.center)
///         .frame(width: 200, height: 290)
///     }
///
/// ![A large trophy symbol, drawn with a mint-colored shadow. Below this, a
/// user name and the date and time. At the bottom, a button with the title
/// Save Achievement allows people to save and upload an image of this
/// view.](ImageRenderer-1)
///
/// Because `ImageRenderer` conforms to
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>, you
/// can use it to produce a stream of images as its properties change. Subscribe
/// to the renderer's ``ImageRenderer/objectWillChange`` publisher, then use the
/// renderer to rasterize a new image each time the subscriber receives an
/// update.
///
/// - Important: `ImageRenderer` output only includes views that SwiftUI renders,
/// such as text, images, shapes, and composite views of these types. It
/// does not render views provided by native platform frameworks (AppKit and
/// UIKit) such as web views, media players, and some controls. For these views,
/// `ImageRenderer` displays a placeholder image, similar to the behavior of
/// ``View/drawingGroup(opaque:colorMode:)``.
///
/// ### Rendering to a PDF context
///
/// The ``render(rasterizationScale:renderer:)`` method renders the specified
/// view to any
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGContext>. That
/// means you aren't limited to creating a rasterized `CGImage`. For
/// example, you can generate PDF data by rendering to a PDF context. The
/// resulting PDF maintains resolution-independence for supported members of the
/// view hierarchy, such as text, symbol images, lines, shapes, and fills.
///
/// The following example uses the `createAwardView(forUser:date:)` method from
/// the previous example, and exports its contents as an 800-by-600 point PDF to
/// the file URL `renderURL`. It uses the `size` parameter sent to the
/// rendering closure to center the `trophyAndDate` view vertically and
/// horizontally on the page.
///
///     var body: some View {
///         let trophyAndDate = createAwardView(forUser: playerName,
///                                             date: achievementDate)
///         VStack {
///             trophyAndDate
///             Button("Save Achievement") {
///                 let renderer = ImageRenderer(content: trophyAndDate)
///                 renderer.render { size, renderer in
///                     var mediaBox = CGRect(origin: .zero,
///                                           size: CGSize(width: 800, height: 600))
///                     guard let consumer = CGDataConsumer(url: renderURL as CFURL),
///                           let pdfContext =  CGContext(consumer: consumer,
///                                                       mediaBox: &mediaBox, nil)
///                     else {
///                         return
///                     }
///                     pdfContext.beginPDFPage(nil)
///                     pdfContext.translateBy(x: mediaBox.size.width / 2 - size.width / 2,
///                                            y: mediaBox.size.height / 2 - size.height / 2)
///                     renderer(pdfContext)
///                     pdfContext.endPDFPage()
///                     pdfContext.closePDF()
///                 }
///             }
///         }
///     }
///
/// ### Creating an image from drawing instructions
///
/// `ImageRenderer` makes it possible to create a custom image by drawing into a
/// ``Canvas``, rendering a `CGImage` from it, and using that to initialize an
/// ``Image``. To simplify this process, use the `Image`
/// initializer ``Image/init(size:label:opaque:colorMode:renderer:)``, which
/// takes a closure whose argument is a ``GraphicsContext`` that you can
/// directly draw into.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
final public class ImageRenderer<Content> : ObservableObject where Content : View {
/// A publisher that informs subscribers of changes to the image.
///
/// The renderer's
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject/ObjectWillChangePublisher>
/// publishes `Void` elements.
/// Subscribers should interpret any event as indicating that the contents
/// of the image may have changed.
final public let objectWillChange: PassthroughSubject<Void, Never>
/// The root view rendered by this image renderer.
@MainActor final public var content: Content
/// The size proposed to the root view.
///
/// The default value of this property, ``ProposedViewSize/unspecified``,
/// produces an image that matches the original view size. You can provide
/// a custom ``ProposedViewSize`` to override the view's size in one or
/// both dimensions.
@MainActor final public var proposedSize: ProposedViewSize
/// The scale at which to render the image.
///
/// This value is a ratio of view points to image pixels. This relationship
/// means that values greater than `1.0` create an image larger than the
/// original content view, and less than `1.0` creates a smaller image. The
/// following example shows a 100 x 50 rectangle view and an image rendered
/// from it with a `scale` of `2.0`, resulting in an image size of
/// 200 x 100.
///
///     let rectangle = Rectangle()
///         .frame(width: 100, height: 50)
///     let renderer = ImageRenderer(content: rectangle)
///     renderer.scale = 2.0
///     if let rendered = renderer.cgImage {
///         print("Scaled image: \(rendered.width) x \(rendered.height)")
///     }
///     // Prints "Scaled image: 200 x 100"
///
/// The default value of this property is `1.0`.
@MainActor final public var scale: CGFloat
/// A Boolean value that indicates whether the alpha channel of the image is
/// fully opaque.
///
/// Setting this value to `true`, meaning the alpha channel is opaque, may
/// improve performance. Don't render non-opaque pixels to a renderer
/// declared as opaque. This property defaults to `false`.
@MainActor final public var isOpaque: Bool
/// The working color space and storage format of the image.
@MainActor final public var colorMode: ColorRenderingMode
/// Creates a renderer object with a source content view.
///
/// - Parameter view: A ``View`` to render.
@MainActor public init(content view: Content)
/// The current contents of the view, rasterized as a Core Graphics image.
///
/// The renderer notifies its `objectWillChange` publisher when
/// the contents of the image may have changed.
@MainActor final public var cgImage: CGImage? { get }
/// The current contents of the view, rasterized as a UIKit image.
///
/// The renderer notifies its `objectWillChange` publisher when
/// the contents of the image may have changed.
@MainActor final public var uiImage: UIImage? { get }
/// Draws the renderer's current contents to an arbitrary Core Graphics
/// context.
///
/// Use this method to rasterize the renderer's content to a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGContext>
/// you provide. The `renderer` closure receives two parameters: the current
/// size of the view, and a function that renders the view to your
/// `CGContext`. Implement the closure to provide a suitable `CGContext`,
/// then invoke the function to render the content to that context.
///
/// - Parameters:
///   - rasterizationScale: The scale factor for converting user
///     interface points to pixels when rasterizing parts of the
///     view that can't be represented as native Core Graphics drawing
///     commands.
///   - renderer: The closure that sets up the Core Graphics context and
///     renders the view. This closure receives two parameters: the size of
///     the view and a function that you invoke in the closure to render the
///     view at the reported size. This function takes a
///     <doc://com.apple.documentation/documentation/CoreGraphics/CGContext>
///     parameter, and assumes a bottom-left coordinate space origin.
@MainActor final public func render(rasterizationScale: CGFloat = 1, renderer: (CGSize, (CGContext) -> Void) -> Void)
/// The type of publisher that emits before the object has changed.
public typealias ObjectWillChangePublisher = PassthroughSubject<Void, Never>
}
/// Defines the implementation of all `IndexView` instances within a view
/// hierarchy.
///
/// To configure the current `IndexViewStyle` for a view hierarchy, use the
/// `.indexViewStyle()` modifier.
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *)
@available(macOS, unavailable)
public protocol IndexViewStyle {
}
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *)
@available(macOS, unavailable)
extension IndexViewStyle where Self == PageIndexViewStyle {
/// An index view style that places a page index view over its content.
public static var page: PageIndexViewStyle { get }
/// An index view style that places a page index view over its content.
///
/// - Parameter backgroundDisplayMode: The display mode of the background of
///   any page index views receiving this style
public static func page(backgroundDisplayMode: PageIndexViewStyle.BackgroundDisplayMode) -> PageIndexViewStyle
}
/// A collection wrapper that iterates over the indices and identifiers of a
/// collection together.
///
/// You don't use this type directly. Instead SwiftUI creates this type on
/// your behalf.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct IndexedIdentifierCollection<Base, ID> : Collection where Base : Collection, ID : Hashable {
/// A type representing the sequence's elements.
public struct Element {
}
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public typealias Index = Base.Index
/// The position of the first element in a nonempty collection.
///
/// If the collection is empty, `startIndex` is equal to `endIndex`.
public var startIndex: IndexedIdentifierCollection<Base, ID>.Index { get }
/// The collection's "past the end" position---that is, the position one
/// greater than the last valid subscript argument.
///
/// When you need a range that includes the last element of a collection, use
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator
/// creates a range that doesn't include the upper bound, so it's always
/// safe to use with `endIndex`. For example:
///
///     let numbers = [10, 20, 30, 40, 50]
///     if let index = numbers.firstIndex(of: 30) {
///         print(numbers[index ..< numbers.endIndex])
///     }
///     // Prints "[30, 40, 50]"
///
/// If the collection is empty, `endIndex` is equal to `startIndex`.
public var endIndex: IndexedIdentifierCollection<Base, ID>.Index { get }
/// Accesses the element at the specified position.
///
/// The following example accesses an element of an array through its
/// subscript to print its value:
///
///     var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"]
///     print(streets[1])
///     // Prints "Bryant"
///
/// You can subscript a collection with any valid index other than the
/// collection's end index. The end index refers to the position one past
/// the last element of a collection, so it doesn't correspond with an
/// element.
///
/// - Parameter position: The position of the element to access. `position`
///   must be a valid index of the collection that is not equal to the
///   `endIndex` property.
///
/// - Complexity: O(1)
public subscript(position: IndexedIdentifierCollection<Base, ID>.Index) -> IndexedIdentifierCollection<Base, ID>.Element { get }
/// Returns the position immediately after the given index.
///
/// The successor of an index must be well defined. For an index `i` into a
/// collection `c`, calling `c.index(after: i)` returns the same index every
/// time.
///
/// - Parameter i: A valid index of the collection. `i` must be less than
///   `endIndex`.
/// - Returns: The index value immediately after `i`.
public func index(after i: IndexedIdentifierCollection<Base, ID>.Index) -> IndexedIdentifierCollection<Base, ID>.Index
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = DefaultIndices<IndexedIdentifierCollection<Base, ID>>
/// A type that provides the collection's iteration interface and
/// encapsulates its iteration state.
///
/// By default, a collection conforms to the `Sequence` protocol by
/// supplying `IndexingIterator` as its associated `Iterator`
/// type.
public typealias Iterator = IndexingIterator<IndexedIdentifierCollection<Base, ID>>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<IndexedIdentifierCollection<Base, ID>>
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension IndexedIdentifierCollection : BidirectionalCollection where Base : BidirectionalCollection {
/// Returns the position immediately before the given index.
///
/// - Parameter i: A valid index of the collection. `i` must be greater than
///   `startIndex`.
/// - Returns: The index value immediately before `i`.
public func index(before i: IndexedIdentifierCollection<Base, ID>.Index) -> IndexedIdentifierCollection<Base, ID>.Index
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension IndexedIdentifierCollection : RandomAccessCollection where Base : RandomAccessCollection {
}
/// A `PickerStyle` where each option is displayed inline with other views in
/// the current container.
///
/// You can also use ``PickerStyle/inline`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct InlinePickerStyle : PickerStyle {
/// Creates an inline picker style.
public init()
}
/// The list style that describes the behavior and appearance of an inset
/// grouped list.
///
/// You can also use ``ListStyle/insetGrouped`` to construct this style.
@available(iOS 14.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct InsetGroupedListStyle : ListStyle {
/// Creates an inset grouped list style.
public init()
}
/// The list style that describes the behavior and appearance of an inset list.
///
/// You can also use ``ListStyle/inset`` to construct this style.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct InsetListStyle : ListStyle {
/// Creates an inset list style.
public init()
}
/// The table style that describes the behavior and appearance of a table with
/// its content and selection inset from the table edges.
///
/// You can also use ``TableStyle/inset`` to construct this style.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct InsetTableStyle : TableStyle {
/// Creates a default inset table style, with alternating row backgrounds.
public init()
/// Creates a view that represents the body of a table.
///
/// The system calls this method for each ``Table`` instance in a view
/// hierarchy where this style is the current table style.
///
/// - Parameter configuration: The properties of the table.
public func makeBody(configuration: InsetTableStyle.Configuration) -> some View
/// A view that represents the body of a table.
public typealias Body = some View
}
/// A shape type that is able to inset itself to produce another shape.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol InsettableShape : Shape {
/// The type of the inset shape.
associatedtype InsetShape : InsettableShape
/// Returns `self` inset by `amount`.
func inset(by amount: CGFloat) -> Self.InsetShape
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension InsettableShape {
/// Returns a view that is the result of insetting `self` by
/// `style.lineWidth / 2`, stroking the resulting shape with
/// `style`, and then filling with `content`.
public func strokeBorder<S>(_ content: S = .foreground, style: StrokeStyle, antialiased: Bool = true) -> StrokeBorderShapeView<Self, S, EmptyView> where S : ShapeStyle
/// Returns a view that is the result of filling the `lineWidth`-sized
/// border (aka inner stroke) of `self` with `content`. This is
/// equivalent to insetting `self` by `lineWidth / 2` and stroking the
/// resulting shape with `lineWidth` as the line-width.
public func strokeBorder<S>(_ content: S = .foreground, lineWidth: CGFloat = 1, antialiased: Bool = true) -> StrokeBorderShapeView<Self, S, EmptyView> where S : ShapeStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension InsettableShape {
/// Returns a view that is the result of insetting `self` by
/// `style.lineWidth / 2`, stroking the resulting shape with
/// `style`, and then filling with `content`.
@inlinable public func strokeBorder<S>(_ content: S, style: StrokeStyle, antialiased: Bool = true) -> some View where S : ShapeStyle
/// Returns a view that is the result of insetting `self` by
/// `style.lineWidth / 2`, stroking the resulting shape with
/// `style`, and then filling with the foreground color.
@inlinable public func strokeBorder(style: StrokeStyle, antialiased: Bool = true) -> some View
/// Returns a view that is the result of filling the `lineWidth`-sized
/// border (aka inner stroke) of `self` with `content`. This is
/// equivalent to insetting `self` by `lineWidth / 2` and stroking the
/// resulting shape with `lineWidth` as the line-width.
@inlinable public func strokeBorder<S>(_ content: S, lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View where S : ShapeStyle
/// Returns a view that is the result of filling the `lineWidth`-sized
/// border (aka inner stroke) of `self` with the foreground color.
/// This is equivalent to insetting `self` by `lineWidth / 2` and
/// stroking the resulting shape with `lineWidth` as the line-width.
@inlinable public func strokeBorder(lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View
}
/// A built-in set of commands for manipulating inspectors.
///
/// `InspectorCommands` include a command for toggling the presented state of
/// the inspector with a keyboard shortcut of ⌘⌃I.
///
/// These commands are optional and can be explicitly requested by passing a
/// value of this type to the ``Scene/commands(content:)`` modifier:
///
///     @State var presented = true
///     WindowGroup {
///         MainView()
///             .inspector(isPresented: $presented) {
///                 InspectorView()
///             }
///     }
///     .commands {
///         InspectorCommands()
///     }
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct InspectorCommands : Commands {
/// A new value describing the built-in inspector-related commands.
public init()
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// The orientation of the interface from the user's perspective.
///
/// By default, device previews appear right side up, using orientation
/// ``InterfaceOrientation/portrait``. You can change the orientation
/// with a call to the ``View/previewInterfaceOrientation(_:)`` modifier:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewInterfaceOrientation(.landscapeRight)
///         }
///     }
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct InterfaceOrientation : CaseIterable, Identifiable, Equatable, Sendable {
/// A collection of all values of this type.
public static var allCases: [InterfaceOrientation] { get }
/// The stable identity of the entity associated with this instance.
public var id: String { get }
/// The device is in portrait mode, with the top of the device on top.
public static let portrait: InterfaceOrientation
/// The device is in portrait mode, but is upside down.
public static let portraitUpsideDown: InterfaceOrientation
/// The device is in landscape mode, with the top of the device on the left.
public static let landscapeLeft: InterfaceOrientation
/// The device is in landscape mode, with the top of the device on the right.
public static let landscapeRight: InterfaceOrientation
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: InterfaceOrientation, b: InterfaceOrientation) -> Bool
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [InterfaceOrientation]
/// A type representing the stable identity of the entity associated with
/// an instance.
public typealias ID = String
}
/// A table row modifier that associates an item provider with some base
/// row content.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct ItemProviderTableRowModifier {
public var body: some _TableRowContentModifier { get }
public typealias Body = some _TableRowContentModifier
}
/// Key equivalents consist of a letter, punctuation, or function key that can
/// be combined with an optional set of modifier keys to specify a keyboard
/// shortcut.
///
/// Key equivalents are used to establish keyboard shortcuts to app
/// functionality. Any key can be used as a key equivalent as long as pressing
/// it produces a single character value. Key equivalents are typically
/// initialized using a single-character string literal, with constants for
/// unprintable or hard-to-type values.
///
/// The modifier keys necessary to type a key equivalent are factored in to the
/// resulting keyboard shortcut. That is, a key equivalent whose raw value is
/// the capitalized string "A" corresponds with the keyboard shortcut
/// Command-Shift-A. The exact mapping may depend on the keyboard layout—for
/// example, a key equivalent with the character value "}" produces a shortcut
/// equivalent to Command-Shift-] on ANSI keyboards, but would produce a
/// different shortcut for keyboard layouts where punctuation characters are in
/// different locations.
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct KeyEquivalent : Sendable {
/// Up Arrow (U+F700)
public static let upArrow: KeyEquivalent
/// Down Arrow (U+F701)
public static let downArrow: KeyEquivalent
/// Left Arrow (U+F702)
public static let leftArrow: KeyEquivalent
/// Right Arrow (U+F703)
public static let rightArrow: KeyEquivalent
/// Escape (U+001B)
public static let escape: KeyEquivalent
/// Delete (U+0008)
public static let delete: KeyEquivalent
/// Delete Forward (U+F728)
public static let deleteForward: KeyEquivalent
/// Home (U+F729)
public static let home: KeyEquivalent
/// End (U+F72B)
public static let end: KeyEquivalent
/// Page Up (U+F72C)
public static let pageUp: KeyEquivalent
/// Page Down (U+F72D)
public static let pageDown: KeyEquivalent
/// Clear (U+F739)
public static let clear: KeyEquivalent
/// Tab (U+0009)
public static let tab: KeyEquivalent
/// Space (U+0020)
public static let space: KeyEquivalent
/// Return (U+000D)
public static let `return`: KeyEquivalent
/// The character value that the key equivalent represents.
public var character: Character
/// Creates a new key equivalent from the given character value.
public init(_ character: Character)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension KeyEquivalent : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: KeyEquivalent, b: KeyEquivalent) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension KeyEquivalent : ExpressibleByExtendedGraphemeClusterLiteral {
/// Creates an instance initialized to the given value.
///
/// - Parameter value: The value of the new instance.
public init(extendedGraphemeClusterLiteral: Character)
/// A type that represents an extended grapheme cluster literal.
///
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`,
/// `String`, and `StaticString`.
public typealias ExtendedGraphemeClusterLiteralType = Character
/// A type that represents a Unicode scalar literal.
///
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`,
/// `Character`, `String`, and `StaticString`.
public typealias UnicodeScalarLiteralType = Character
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct KeyPress : Sendable {
/// The phase of the key-press event (`.down`, `.repeat`, or `.up`).
public let phase: KeyPress.Phases
/// The key equivalent value for the pressed key.
public let key: KeyEquivalent
/// The characters generated by the pressed key as if no modifier
/// key applies.
public let characters: String
/// The set of modifier keys the user held in addition to the
/// pressed key.
public let modifiers: EventModifiers
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension KeyPress : CustomDebugStringConvertible {
/// Options for matching different phases of a key-press event.
public struct Phases : OptionSet, Sendable, CustomDebugStringConvertible {
/// The user pressed down on a key.
public static let down: KeyPress.Phases
/// The user held a key down to issue a sequence of repeating events.
public static let `repeat`: KeyPress.Phases
/// The user released a key.
public static let up: KeyPress.Phases
/// A value that matches all key press phases.
public static let all: KeyPress.Phases
/// A textual representation of this instance, suitable for debugging.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(reflecting:)`
/// initializer. This initializer works with any type, and uses the custom
/// `debugDescription` property for types that conform to
/// `CustomDebugStringConvertible`:
///
///     struct Point: CustomDebugStringConvertible {
///         let x: Int, y: Int
///
///         var debugDescription: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(reflecting: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `debugDescription` property.
public var debugDescription: String { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = KeyPress.Phases
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = KeyPress.Phases
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
/// A result value returned from a key-press action that indicates whether
/// the action consumed the event.
public enum Result : Sendable {
/// The action consumed the event, preventing dispatch from continuing.
case handled
/// The action ignored the event, allowing dispatch to continue.
case ignored
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: KeyPress.Result, b: KeyPress.Result) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A textual representation of this instance, suitable for debugging.
///
/// Calling this property directly is discouraged. Instead, convert an
/// instance of any type to a string by using the `String(reflecting:)`
/// initializer. This initializer works with any type, and uses the custom
/// `debugDescription` property for types that conform to
/// `CustomDebugStringConvertible`:
///
///     struct Point: CustomDebugStringConvertible {
///         let x: Int, y: Int
///
///         var debugDescription: String {
///             return "(\(x), \(y))"
///         }
///     }
///
///     let p = Point(x: 21, y: 30)
///     let s = String(reflecting: p)
///     print(s)
///     // Prints "(21, 30)"
///
/// The conversion of `p` to a string in the assignment to `s` uses the
/// `Point` type's `debugDescription` property.
public var debugDescription: String { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension KeyPress.Result : Equatable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension KeyPress.Result : Hashable {
}
/// Keyboard shortcuts describe combinations of keys on a keyboard that the user
/// can press in order to activate a button or toggle.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct KeyboardShortcut : Sendable {
/// Options for how a keyboard shortcut participates in automatic localization.
///
/// A shortcut's `key` that is defined on an US-English keyboard
/// layout might not be reachable on international layouts.
/// For example the shortcut `⌘[` works well for the US layout but is
/// hard to reach for German users.
/// On the German keyboard layout, pressing `⌥5` will produce
/// `[`, which causes the shortcut to become `⌥⌘5`.
/// If configured, which is the default behavior, automatic shortcut
/// remapping will convert it to `⌘Ö`.
///
/// In addition to that, some keyboard shortcuts carry information
/// about directionality.
/// Right-aligning a block of text or seeking forward in context of music
/// playback are such examples. These kinds of shortcuts benefit from the option
/// ``KeyboardShortcut/Localization-swift.struct/withoutMirroring``
/// to tell the system that they won't be flipped when running in a
/// right-to-left context.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct Localization : Sendable {
/// Remap shortcuts to their international counterparts, mirrored for
/// right-to-left usage if appropriate.
///
/// This is the default configuration.
public static let automatic: KeyboardShortcut.Localization
/// Don't mirror shortcuts.
///
/// Use this for shortcuts that always have a specific directionality, like
/// aligning something on the right.
///
/// Don't use this option for navigational shortcuts like "Go Back" because navigation
/// is flipped in right-to-left contexts.
public static let withoutMirroring: KeyboardShortcut.Localization
/// Don't use automatic shortcut remapping.
///
/// When you use this mode, you have to take care of international use-cases separately.
public static let custom: KeyboardShortcut.Localization
}
/// The standard keyboard shortcut for the default button, consisting of
/// the Return (↩) key and no modifiers.
///
/// On macOS, the default button is designated with special coloration. If
/// more than one control is assigned this shortcut, only the first one is
/// emphasized.
public static let defaultAction: KeyboardShortcut
/// The standard keyboard shortcut for cancelling the in-progress action
/// or dismissing a prompt, consisting of the Escape (⎋) key and no
/// modifiers.
public static let cancelAction: KeyboardShortcut
/// The key equivalent that the user presses in conjunction with any
/// specified modifier keys to activate the shortcut.
public var key: KeyEquivalent
/// The modifier keys that the user presses in conjunction with a key
/// equivalent to activate the shortcut.
public var modifiers: EventModifiers
/// The localization strategy to apply to this shortcut.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public var localization: KeyboardShortcut.Localization
/// Creates a new keyboard shortcut with the given key equivalent and set of
/// modifier keys.
///
/// The localization configuration defaults to ``KeyboardShortcut/Localization-swift.struct/automatic``.
public init(_ key: KeyEquivalent, modifiers: EventModifiers = .command)
/// Creates a new keyboard shortcut with the given key equivalent and set of
/// modifier keys.
///
/// Use the `localization` parameter to specify a localization strategy
/// for this shortcut.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public init(_ key: KeyEquivalent, modifiers: EventModifiers = .command, localization: KeyboardShortcut.Localization)
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension KeyboardShortcut : Hashable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: KeyboardShortcut, rhs: KeyboardShortcut) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A container that animates its content with keyframes.
///
/// The `content` closure updates every frame while
/// animating, so avoid performing any expensive operations directly within
/// `content`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct KeyframeAnimator<Value, KeyframePath, Content> : View where Value == KeyframePath.Value, KeyframePath : Keyframes, Content : View {
/// Plays the given keyframes when the given trigger value changes, updating
/// the view using the modifiers you apply in `body`.
///
/// Note that the `content` closure will be updated on every frame while
/// animating, so avoid performing any expensive operations directly within
/// `content`.
///
/// If the trigger value changes while animating, the `keyframes` closure
/// will be called with the current interpolated value, and the keyframes
/// that you return define a new animation that replaces the old one. The
/// previous velocity will be preserved, so cubic or spring keyframes will
/// maintain continuity from the previous animation if they do not specify
/// a custom initial velocity.
///
/// When a keyframe animation finishes, the animator will remain at the
/// end value, which becomes the initial value for the next animation.
///
/// - Parameters:
///   - initialValue: The initial value that the keyframes will animate
///     from.
///   - trigger: A value to observe for changes.
///   - content: A view builder closure that takes the interpolated value
///     generated by the keyframes as its single argument.
///   - keyframes: Keyframes defining how the value changes over time. The
///     current value of the animator is the single argument, which is
///     equal to `initialValue` when the view first appears, then is equal
///     to the end value of the previous keyframe animation on subsequent
///     calls.
public init(initialValue: Value, trigger: some Equatable, @ViewBuilder content: @escaping (Value) -> Content, @KeyframesBuilder<Value> keyframes: @escaping (Value) -> KeyframePath)
/// Loops the given keyframes continuously, updating
/// the view using the modifiers you apply in `body`.
///
/// Note that the `content` closure will be updated on every frame while
/// animating, so avoid performing any expensive operations directly within
/// `content`.
///
/// - Parameters:
///   - initialValue: The initial value that the keyframes will animate
///     from.
///   - repeating: Whether the keyframes are currently repeating. If false,
///     the value at the beginning of the keyframe timeline will be
///     provided to the content closure.
///   - content: A view builder closure that takes the interpolated value
///     generated by the keyframes as its single argument.
///   - keyframes: Keyframes defining how the value changes over time. The
///     current value of the animator is the single argument, which is
///     equal to `initialValue` when the view first appears, then is equal
///     to the end value of the previous keyframe animation on subsequent
///     calls.
public init(initialValue: Value, repeating: Bool = true, @ViewBuilder content: @escaping (Value) -> Content, @KeyframesBuilder<Value> keyframes: @escaping (Value) -> KeyframePath)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A description of how a value changes over time, modeled using keyframes.
///
/// Unlike other animations in SwiftUI (using ``Animation``), keyframes
/// don't interpolate between from and to values that SwiftUI provides as
/// state changes. Instead, keyframes fully define the path that a value
/// takes over time using the tracks that make up their body.
///
/// `Keyframes` values are roughly analogous to video clips;
/// they have a set duration, and you can scrub and evaluate them for any
/// time within the duration.
///
/// The `Keyframes` structure also allows you to compute an interpolated
/// value at a specific time, which you can use when integrating keyframes
/// into custom use cases.
///
/// For example, you can use a `Keyframes` instance to define animations for a
/// type conforming to `Animatable:`
///
///     let keyframes = KeyframeTimeline(initialValue: CGPoint.zero) {
///         CubcKeyframe(.init(x: 0, y: 100), duration: 0.3)
///         CubicKeyframe(.init(x: 0, y: 0), duration: 0.7)
///     }
///
///     let value = keyframes.value(time: 0.45
///
/// For animations that involve multiple coordinated changes, you can include
/// multiple nested tracks:
///
///     struct Values {
///         var rotation = Angle.zero
///         var scale = 1.0
///     }
///
///     let keyframes = KeyframeTimeline(initialValue: Values()) {
///         KeyframeTrack(\.rotation) {
///             CubicKeyframe(.zero, duration: 0.2)
///             CubicKeyframe(.degrees(45), duration: 0.3)
///         }
///         KeyframeTrack(\.scale) {
///             CubicKeyframe(value: 1.2, duration: 0.5)
///             CubicKeyframe(value: 0.9, duration: 0.2)
///             CubicKeyframe(value: 1.0, duration: 0.3)
///         }
///     }
///
/// Multiple nested tracks update the initial value in the order that they are
/// declared. This means that if multiple nested plans change the same property
/// of the root value, the value from the last competing track will be used.
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct KeyframeTimeline<Value> {
/// Creates a new instance using the initial value and content that you
/// provide.
public init(initialValue: Value, @KeyframesBuilder<Value> content: () -> some Keyframes<Value>)
/// The duration of the content in seconds.
public var duration: TimeInterval { get }
/// Returns the interpolated value at the given time.
public func value(time: Double) -> Value
/// Returns the interpolated value at the given progress in the range zero to one.
public func value(progress: Double) -> Value
}
/// A sequence of keyframes animating a single property of a root type.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct KeyframeTrack<Root, Value, Content> : Keyframes where Value == Content.Value, Content : KeyframeTrackContent {
/// Creates an instance that animates the entire value from the root of the key path.
///
/// - Parameter keyframes: A keyframe collection builder closure containing
///   the keyframes that control the interpolation curve.
public init(@KeyframeTrackContentBuilder<Root> content: () -> Content) where Root == Value
/// Creates an instance that animates the property of the root value
/// at the given key path.
///
/// - Parameter keyPath: The property to animate.
/// - Parameter keyframes: A keyframe collection builder closure containing
///   the keyframes that control the interpolation curve.
public init(_ keyPath: WritableKeyPath<Root, Value>, @KeyframeTrackContentBuilder<Value> content: () -> Content)
/// The type of keyframes representing the body of this type.
///
/// When you create a custom keyframes type, Swift infers this type from your
/// implementation of the required
/// ``Keyframes/body-swift.property`` property.
public typealias Body = Never
}
/// A group of keyframes that define an interpolation curve of an animatable
/// value.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol KeyframeTrackContent<Value> {
associatedtype Value : Animatable = Self.Body.Value
associatedtype Body : KeyframeTrackContent
/// The composition of content that comprise the keyframe track.
@KeyframeTrackContentBuilder<Self.Value> var body: Self.Body { get }
}
/// The builder that creates keyframe track content from the keyframes
/// that you define within a closure.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@resultBuilder public struct KeyframeTrackContentBuilder<Value> where Value : Animatable {
public static func buildExpression<K>(_ expression: K) -> K where Value == K.Value, K : KeyframeTrackContent
public static func buildArray(_ components: [some KeyframeTrackContent<Value>]) -> some KeyframeTrackContent<Value>
public static func buildEither<First, Second>(first component: First) -> KeyframeTrackContentBuilder<Value>.Conditional<Value, First, Second> where Value == First.Value, First : KeyframeTrackContent, Second : KeyframeTrackContent, First.Value == Second.Value
public static func buildEither<First, Second>(second component: Second) -> KeyframeTrackContentBuilder<Value>.Conditional<Value, First, Second> where Value == First.Value, First : KeyframeTrackContent, Second : KeyframeTrackContent, First.Value == Second.Value
public static func buildPartialBlock<K>(first: K) -> K where Value == K.Value, K : KeyframeTrackContent
public static func buildPartialBlock(accumulated: some KeyframeTrackContent<Value>, next: some KeyframeTrackContent<Value>) -> some KeyframeTrackContent<Value>
public static func buildBlock() -> some KeyframeTrackContent<Value>
}
extension KeyframeTrackContentBuilder {
/// A conditional result from the result builder.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct Conditional<ConditionalValue, First, Second> : KeyframeTrackContent where ConditionalValue == First.Value, First : KeyframeTrackContent, Second : KeyframeTrackContent, First.Value == Second.Value {
public typealias Body = KeyframeTrackContentBuilder<KeyframeTrackContentBuilder<Value>.Conditional<ConditionalValue, First, Second>.Value>.Conditional<ConditionalValue, First, Second>
public typealias Value = ConditionalValue
}
}
/// A type that defines changes to a value over time.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol Keyframes<Value> {
/// The type of value animated by this keyframes type
associatedtype Value = Self.Body.Value
/// The type of keyframes representing the body of this type.
///
/// When you create a custom keyframes type, Swift infers this type from your
/// implementation of the required
/// ``Keyframes/body-swift.property`` property.
associatedtype Body : Keyframes
/// The composition of content that comprise the keyframes.
@KeyframesBuilder<Self.Value> var body: Self.Body { get }
}
/// A builder that combines keyframe content values into a single value.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@resultBuilder public struct KeyframesBuilder<Value> {
public static func buildExpression<K>(_ expression: K) -> K where Value == K.Value, K : KeyframeTrackContent
public static func buildArray(_ components: [some KeyframeTrackContent<Value>]) -> some KeyframeTrackContent<Value>
public static func buildEither<First, Second>(first component: First) -> KeyframeTrackContentBuilder<Value>.Conditional<Value, First, Second> where Value == First.Value, First : KeyframeTrackContent, Second : KeyframeTrackContent, First.Value == Second.Value
public static func buildEither<First, Second>(second component: Second) -> KeyframeTrackContentBuilder<Value>.Conditional<Value, First, Second> where Value == First.Value, First : KeyframeTrackContent, Second : KeyframeTrackContent, First.Value == Second.Value
public static func buildPartialBlock<K>(first: K) -> K where Value == K.Value, K : KeyframeTrackContent
public static func buildPartialBlock(accumulated: some KeyframeTrackContent<Value>, next: some KeyframeTrackContent<Value>) -> some KeyframeTrackContent<Value>
public static func buildBlock() -> some KeyframeTrackContent<Value> where Value : Animatable
public static func buildFinalResult<Content>(_ component: Content) -> KeyframeTrack<Value, Value, Content> where Value == Content.Value, Content : KeyframeTrackContent
/// Keyframes
public static func buildExpression<Content>(_ expression: Content) -> Content where Value == Content.Value, Content : Keyframes
public static func buildPartialBlock<Content>(first: Content) -> Content where Value == Content.Value, Content : Keyframes
public static func buildPartialBlock(accumulated: some Keyframes<Value>, next: some Keyframes<Value>) -> some Keyframes<Value>
public static func buildBlock() -> some Keyframes<Value>
public static func buildFinalResult<Content>(_ component: Content) -> Content where Value == Content.Value, Content : Keyframes
}
/// A standard label for user interface items, consisting of an icon with a
/// title.
///
/// One of the most common and recognizable user interface components is the
/// combination of an icon and a label. This idiom appears across many kinds of
/// apps and shows up in collections, lists, menus of action items, and
/// disclosable lists, just to name a few.
///
/// You create a label, in its simplest form, by providing a title and the name
/// of an image, such as an icon from the
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/)
/// collection:
///
///     Label("Lightning", systemImage: "bolt.fill")
///
/// You can also apply styles to labels in several ways. In the case of dynamic
/// changes to the view after device rotation or change to a window size you
/// might want to show only the text portion of the label using the
/// ``LabelStyle/titleOnly`` label style:
///
///     Label("Lightning", systemImage: "bolt.fill")
///         .labelStyle(.titleOnly)
///
/// Conversely, there's also an icon-only label style:
///
///     Label("Lightning", systemImage: "bolt.fill")
///         .labelStyle(.iconOnly)
///
/// Some containers might apply a different default label style, such as only
/// showing icons within toolbars on macOS and iOS. To opt in to showing both
/// the title and the icon, you can apply the ``LabelStyle/titleAndIcon`` label
/// style:
///
///     Label("Lightning", systemImage: "bolt.fill")
///         .labelStyle(.titleAndIcon)
///
/// You can also create a customized label style by modifying an existing
/// style; this example adds a red border to the default label style:
///
///     struct RedBorderedLabelStyle: LabelStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Label(configuration)
///                 .border(Color.red)
///         }
///     }
///
/// For more extensive customization or to create a completely new label style,
/// you'll need to adopt the ``LabelStyle`` protocol and implement a
/// ``LabelStyleConfiguration`` for the new style.
///
/// To apply a common label style to a group of labels, apply the style
/// to the view hierarchy that contains the labels:
///
///     VStack {
///         Label("Rain", systemImage: "cloud.rain")
///         Label("Snow", systemImage: "snow")
///         Label("Sun", systemImage: "sun.max")
///     }
///     .labelStyle(.iconOnly)
///
/// It's also possible to make labels using views to compose the label's icon
/// programmatically, rather than using a pre-made image. In this example, the
/// icon portion of the label uses a filled ``Circle`` overlaid
/// with the user's initials:
///
///     Label {
///         Text(person.fullName)
///             .font(.body)
///             .foregroundColor(.primary)
///         Text(person.title)
///             .font(.subheadline)
///             .foregroundColor(.secondary)
///     } icon: {
///         Circle()
///             .fill(person.profileColor)
///             .frame(width: 44, height: 44, alignment: .center)
///             .overlay(Text(person.initials))
///     }
///
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct Label<Title, Icon> : View where Title : View, Icon : View {
/// Creates a label with a custom title and icon.
public init(@ViewBuilder title: () -> Title, @ViewBuilder icon: () -> Icon)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Label where Title == Text, Icon == Image {
/// Creates a label with an icon image and a title generated from a
/// localized string.
///
/// - Parameters:
///    - titleKey: A title generated from a localized string.
///    - image: The name of the image resource to lookup.
public init(_ titleKey: LocalizedStringKey, image name: String)
/// Creates a label with a system icon image and a title generated from a
/// localized string.
///
/// - Parameters:
///    - titleKey: A title generated from a localized string.
///    - systemImage: The name of the image resource to lookup.
public init(_ titleKey: LocalizedStringKey, systemImage name: String)
/// Creates a label with an icon image and a title generated from a string.
///
/// - Parameters:
///    - title: A string used as the label's title.
///    - image: The name of the image resource to lookup.
public init<S>(_ title: S, image name: String) where S : StringProtocol
/// Creates a label with a system icon image and a title generated from a
/// string.
///
/// - Parameters:
///    - title: A string used as the label's title.
///    - systemImage: The name of the image resource to lookup.
public init<S>(_ title: S, systemImage name: String) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Label where Title == Text, Icon == Image {
/// Creates a label with an icon image and a title generated from a
/// localized string.
///
/// - Parameters:
///    - titleKey: A title generated from a localized string.
///    - image: The image resource to lookup.
public init(_ titleKey: LocalizedStringKey, image resource: ImageResource)
/// Creates a label with an icon image and a title generated from a string.
///
/// - Parameters:
///    - title: A string used as the label's title.
///    - image: The image resource to lookup.
public init<S>(_ title: S, image resource: ImageResource) where S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Label where Title == LabelStyleConfiguration.Title, Icon == LabelStyleConfiguration.Icon {
/// Creates a label representing the configuration of a style.
///
/// You can use this initializer within the ``LabelStyle/makeBody(configuration:)``
/// method of a ``LabelStyle`` instance to create an instance of the label
/// that's being styled. This is useful for custom label styles that only
/// wish to modify the current style, as opposed to implementing a brand new
/// style.
///
/// For example, the following style adds a red border around the label,
/// but otherwise preserves the current style:
///
///     struct RedBorderedLabelStyle: LabelStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Label(configuration)
///                 .border(Color.red)
///         }
///     }
///
/// - Parameter configuration: The label style to use.
public init(_ configuration: LabelStyleConfiguration)
}
/// A type that applies a custom appearance to all labels within a view.
///
/// To configure the current label style for a view hierarchy, use the
/// ``View/labelStyle(_:)`` modifier.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol LabelStyle {
/// A view that represents the body of a label.
associatedtype Body : View
/// Creates a view that represents the body of a label.
///
/// The system calls this method for each ``Label`` instance in a view
/// hierarchy where this style is the current label style.
///
/// - Parameter configuration: The properties of the label.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a label.
typealias Configuration = LabelStyleConfiguration
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LabelStyle where Self == DefaultLabelStyle {
/// A label style that resolves its appearance automatically based on the
/// current context.
public static var automatic: DefaultLabelStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LabelStyle where Self == IconOnlyLabelStyle {
/// A label style that only displays the icon of the label.
///
/// The title of the label is still used for non-visual descriptions, such as
/// VoiceOver.
public static var iconOnly: IconOnlyLabelStyle { get }
}
@available(iOS 14.5, macOS 11.3, tvOS 14.5, watchOS 7.4, *)
extension LabelStyle where Self == TitleAndIconLabelStyle {
/// A label style that shows both the title and icon of the label using a
/// system-standard layout.
///
/// In most cases, labels show both their title and icon by default. However,
/// some containers might apply a different default label style to their
/// content, such as only showing icons within toolbars on macOS and iOS. To
/// opt in to showing both the title and the icon, you can apply the title
/// and icon label style:
///
///     Label("Lightning", systemImage: "bolt.fill")
///         .labelStyle(.titleAndIcon)
///
/// To apply the title and icon style to a group of labels, apply the style
/// to the view hierarchy that contains the labels:
///
///     VStack {
///         Label("Rain", systemImage: "cloud.rain")
///         Label("Snow", systemImage: "snow")
///         Label("Sun", systemImage: "sun.max")
///     }
///     .labelStyle(.titleAndIcon)
///
/// The relative layout of the title and icon is dependent on the context it
/// is displayed in. In most cases, however, the label is arranged
/// horizontally with the icon leading.
public static var titleAndIcon: TitleAndIconLabelStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LabelStyle where Self == TitleOnlyLabelStyle {
/// A label style that only displays the title of the label.
public static var titleOnly: TitleOnlyLabelStyle { get }
}
/// The properties of a label.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LabelStyleConfiguration {
/// A type-erased title view of a label.
public struct Title {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased icon view of a label.
public struct Icon {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A description of the labeled item.
public var title: LabelStyleConfiguration.Title { get }
/// A symbolic representation of the labeled item.
public var icon: LabelStyleConfiguration.Icon { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LabelStyleConfiguration.Title : View {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LabelStyleConfiguration.Icon : View {
}
/// A container for attaching a label to a value-bearing view.
///
/// The instance's content represents a read-only or read-write value, and its
/// label identifies or describes the purpose of that value.
/// The resulting element has a layout that's consistent with other framework
/// controls and automatically adapts to its container, like a form or toolbar.
/// Some styles of labeled content also apply styling or behaviors to the value
/// content, like making ``Text`` views selectable.
///
/// The following example associates a label with a custom view and has
/// a layout that matches the label of the ``Picker``:
///
///     Form {
///         LabeledContent("Custom Value") {
///             MyCustomView(value: $value)
///         }
///         Picker("Selected Value", selection: $selection) {
///             Text("Option 1").tag(1)
///             Text("Option 2").tag(2)
///         }
///     }
///
/// ### Custom view labels
///
/// You can assemble labeled content with an explicit view for its label
/// using the ``init(content:label:)`` initializer. For example, you can
/// rewrite the previous labeled content example using a ``Text`` view:
///
///     LabeledContent {
///         MyCustomView(value: $value)
///     } label: {
///         Text("Custom Value")
///     }
///
/// The `label` view builder accepts any kind of view, like a ``Label``:
///
///     LabeledContent {
///         MyCustomView(value: $value)
///     } label: {
///         Label("Custom Value", systemImage: "hammer")
///     }
///
/// ### Textual labeled content
///
/// You can construct labeled content with string values or formatted values
/// to create read-only displays of textual values:
///
///     Form {
///         Section("Information") {
///             LabeledContent("Name", value: person.name)
///             LabeledContent("Age", value: person.age, format: .number)
///             LabeledContent("Height", value: person.height,
///                 format: .measurement(width: .abbreviated))
///         }
///         if !person.pets.isEmpty {
///             Section("Pets") {
///                 ForEach(pet) { pet in
///                     LabeledContent(pet.species, value: pet.name)
///                 }
///             }
///         }
///     }
///
/// Wherever possible, SwiftUI makes this text selectable.
///
/// ### Compositional elements
///
/// You can use labeled content as the label for other elements. For example,
/// a ``NavigationLink`` can present a summary value for the destination it
/// links to:
///
///     Form {
///         NavigationLink(value: Settings.wifiDetail) {
///             LabeledContent("Wi-Fi", value: ssidName)
///         }
///     }
///
/// In some cases, the styling of views used as the value content is
/// specialized as well. For example, while a ``Toggle`` in an inset group
/// form on macOS is styled as a switch by default, it's styled as a checkbox
/// when used as a value element within a surrounding `LabeledContent`
/// instance:
///
///     Form {
///         LabeledContent("Source Control") {
///             Toggle("Refresh local status automatically",
///                 isOn: $refreshLocalStatus)
///             Toggle("Fetch and refresh server status automatically",
///                 isOn: $refreshServerStatus)
///             Toggle("Add and remove files automatically",
///                 isOn: $addAndRemoveFiles)
///             Toggle("Select files to commit automatically",
///                 isOn: $selectFiles)
///         }
///     }
///
/// ### Controlling label visibility
///
/// A label communicates the identity or purpose of the value, which is
/// important for accessibility. However, you might want to hide the label
/// in the display, and some controls or contexts may visually hide their label
/// by default. The ``View/labelsHidden()`` modifier allows controlling that
/// visibility. The following example hides both labels, producing only a
/// group of the two value views:
///
///     Group {
///         LabeledContent("Custom Value") {
///             MyCustomView(value: $value)
///         }
///         Picker("Selected Value", selection: $selection) {
///             Text("Option 1").tag(1)
///             Text("Option 2").tag(2)
///         }
///     }
///     .labelsHidden()
///
/// ### Styling labeled content
///
/// You can set label styles using the ``View/labeledContentStyle(_:)``
/// modifier. You can also build custom styles using ``LabeledContentStyle``.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LabeledContent<Label, Content> {
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LabeledContent : View where Label : View, Content : View {
/// Creates a standard labeled element, with a view that conveys
/// the value of the element and a label.
///
/// - Parameters:
///   - content: The view that conveys the value of the resulting labeled
///     element.
///   - label: The label that describes the purpose of the result.
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LabeledContent where Label == Text, Content : View {
/// Creates a labeled view that generates its label from a localized string
/// key.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the view's localized title, that describes
///     the purpose of the view.
///   - content: The value content being labeled.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content)
/// Creates a labeled view that generates its label from a string.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// - Parameters:
///   - title: A string that describes the purpose of the view.
///   - content: The value content being labeled.
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LabeledContent where Label == Text, Content == Text {
/// Creates a labeled informational view.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
///     Form {
///         LabeledContent("Name", value: person.name)
///     }
///
/// In some contexts, this text will be selectable by default.
///
/// - Parameters:
///   - titleKey: The key for the view's localized title, that describes
///     the purpose of the view.
///   - value: The value being labeled.
public init<S>(_ titleKey: LocalizedStringKey, value: S) where S : StringProtocol
/// Creates a labeled informational view.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
///     Form {
///         ForEach(person.pet) { pet in
///             LabeledContent(pet.species, value: pet.name)
///         }
///     }
///
/// - Parameters:
///   - title: A string that describes the purpose of the view.
///   - value: The value being labeled.
public init<S1, S2>(_ title: S1, value: S2) where S1 : StringProtocol, S2 : StringProtocol
/// Creates a labeled informational view from a formatted value.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
///     Form {
///         LabeledContent("Age", value: person.age, format: .number)
///         LabeledContent("Height", value: person.height,
///             format: .measurement(width: .abbreviated))
///     }
///
/// - Parameters:
///   - titleKey: The key for the view's localized title, that describes
///     the purpose of the view.
///   - value: The value being labeled.
///   - format: A format style of type `F` to convert the underlying value
///     of type `F.FormatInput` to a string representation.
public init<F>(_ titleKey: LocalizedStringKey, value: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String
/// Creates a labeled informational view from a formatted value.
///
/// This initializer creates a ``Text`` label on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
///     Form {
///         Section("Downloads") {
///             ForEach(download) { file in
///                 LabeledContent(file.name, value: file.downloadSize,
///                     format: .byteCount(style: .file))
///            }
///         }
///     }
///
/// - Parameters:
///   - title: A string that describes the purpose of the view.
///   - value: The value being labeled.
///   - format: A format style of type `F` to convert the underlying value
///     of type `F.FormatInput` to a string representation.
public init<S, F>(_ title: S, value: F.FormatInput, format: F) where S : StringProtocol, F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LabeledContent where Label == LabeledContentStyleConfiguration.Label, Content == LabeledContentStyleConfiguration.Content {
/// Creates labeled content based on a labeled content style configuration.
///
/// You can use this initializer within the
/// ``LabeledContentStyle/makeBody(configuration:)`` method of a
/// ``LabeledContentStyle`` to create a labeled content instance.
/// This is useful for custom styles that only modify the current style,
/// as opposed to implementing a brand new style.
///
/// For example, the following style adds a red border around the labeled
/// content, but otherwise preserves the current style:
///
///     struct RedBorderLabeledContentStyle: LabeledContentStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             LabeledContent(configuration)
///                 .border(.red)
///         }
///     }
///
/// - Parameter configuration: The properties of the labeled content
public init(_ configuration: LabeledContentStyleConfiguration)
}
/// The appearance and behavior of a labeled content instance..
///
/// Use ``View/labeledContentStyle(_:)`` to set a style on a view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol LabeledContentStyle {
/// A view that represents the appearance and behavior of labeled content.
associatedtype Body : View
/// Creates a view that represents the body of labeled content.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a labeled content instance.
typealias Configuration = LabeledContentStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LabeledContentStyle where Self == AutomaticLabeledContentStyle {
/// A labeled content style that resolves its appearance automatically based
/// on the current context.
public static var automatic: AutomaticLabeledContentStyle { get }
}
/// The properties of a labeled content instance.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LabeledContentStyleConfiguration {
/// A type-erased label of a labeled content instance.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased content of a labeled content instance.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The label of the labeled content instance.
public let label: LabeledContentStyleConfiguration.Label
/// The content of the labeled content instance.
public let content: LabeledContentStyleConfiguration.Content
}
/// A view that represents the body of a control group with a specified
/// label.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a ``ControlGroup``.
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct LabeledControlGroupContent<Content, Label> : View where Content : View, Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A view that represents the view of a toolbar item group with a specified
/// label.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a ``ToolbarItemGroup``.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LabeledToolbarItemGroupContent<Content, Label> : View where Content : View, Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A type that defines the geometry of a collection of views.
///
/// You traditionally arrange views in your app's user interface using built-in
/// layout containers like ``HStack`` and ``Grid``. If you need more complex
/// layout behavior, you can define a custom layout container by creating a type
/// that conforms to the `Layout` protocol and implementing its required
/// methods:
///
/// * ``Layout/sizeThatFits(proposal:subviews:cache:)``
///   reports the size of the composite layout view.
/// * ``Layout/placeSubviews(in:proposal:subviews:cache:)``
///   assigns positions to the container's subviews.
///
/// You can define a basic layout type with only these two methods:
///
///     struct BasicVStack: Layout {
///         func sizeThatFits(
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGSize {
///             // Calculate and return the size of the layout container.
///         }
///
///         func placeSubviews(
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) {
///             // Tell each subview where to appear.
///         }
///     }
///
/// Use your layout the same way you use a built-in layout
/// container, by providing a ``ViewBuilder`` with the list of subviews
/// to arrange:
///
///     BasicVStack {
///         Text("A Subview")
///         Text("Another Subview")
///     }
///
/// ### Support additional behaviors
///
/// You can optionally implement other protocol methods and properties to
/// provide more layout container features:
///
/// * Define explicit horizontal and vertical layout guides for the container by
///   implementing ``explicitAlignment(of:in:proposal:subviews:cache:)-8ofeu``
///   and ``explicitAlignment(of:in:proposal:subviews:cache:)-3iqmu``,
///   respectively.
/// * Establish the preferred spacing around the container by implementing
///   ``spacing(subviews:cache:)-86z2e``.
/// * Indicate the axis of orientation for a container that has characteristics
///   of a stack by implementing the ``layoutProperties-5rb5b`` static property.
/// * Create and manage a cache to store computed values across different
///   layout protocol calls by implementing ``makeCache(subviews:)-23agy``.
///
/// The protocol provides default implementations for these symbols
/// if you don't implement them. See each method or property for details.
///
/// ### Add input parameters
///
/// You can define parameters as inputs to the layout, like you might
/// for a ``View``:
///
///     struct BasicVStack: Layout {
///         var alignment: HorizontalAlignment
///
///         // ...
///     }
///
/// Set the parameters at the point where you instantiate the layout:
///
///     BasicVStack(alignment: .leading) {
///         // ...
///     }
///
/// If the layout provides default values for its parameters, you can omit the
/// parameters at the call site, but you might need to keep the parentheses
/// after the name of the layout, depending on how you specify the defaults.
/// For example, suppose you set a default alignment for the basic stack in
/// the parameter declaration:
///
///     struct BasicVStack: Layout {
///         var alignment: HorizontalAlignment = .center
///
///         // ...
///     }
///
/// To instantiate this layout using the default center alignment, you don't
/// have to specify the alignment value, but you do need to add empty
/// parentheses:
///
///     BasicVStack() {
///         // ...
///     }
///
/// The Swift compiler requires the parentheses in this case because of how the
/// layout protocol implements this call site syntax. Specifically, the layout's
/// ``callAsFunction(_:)`` method looks for an initializer with exactly zero
/// input arguments when you omit the parentheses from the call site.
/// You can enable the simpler call site for a layout that doesn't have an
/// implicit initializer of this type by explicitly defining one:
///
///     init() {
///         self.alignment = .center
///     }
///
/// For information about Swift initializers, see
/// [Initialization](https://docs.swift.org/swift-book/LanguageGuide/Initialization.html)
/// in *The Swift Programming Language*.
///
/// ### Interact with subviews through their proxies
///
/// To perform layout, you need information about all of its subviews, which
/// are the views that your container arranges. While your layout can't
/// interact directly with its subviews, it can access a set of subview proxies
/// through the ``Subviews`` collection that each protocol method receives as
/// an input parameter. That type is an alias for the ``LayoutSubviews``
/// collection type, which in turn contains ``LayoutSubview`` instances
/// that are the subview proxies.
///
/// You can get information about each subview from its proxy, like its
/// dimensions and spacing preferences. This enables
/// you to measure subviews before you commit to placing them. You also
/// assign a position to each subview by calling its proxy's
/// ``LayoutSubview/place(at:anchor:proposal:)`` method.
/// Call the method on each subview from within your implementation of the
/// layout's ``placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// ### Access layout values
///
/// Views have layout values that you set with view modifiers.
/// Layout containers can choose to condition their behavior accordingly.
/// For example, a built-in ``HStack`` allocates space to its subviews based
/// in part on the priorities that you set with the ``View/layoutPriority(_:)``
/// view modifier. Your layout container accesses this value for a subview by
/// reading the proxy's ``LayoutSubview/priority`` property.
///
/// You can also create custom layout values by creating a layout key.
/// Set a value on a view with the ``View/layoutValue(key:value:)`` view
/// modifier. Read the corresponding value from the subview's proxy using the
/// key as an index on the subview. For more information about creating,
/// setting, and accessing custom layout values, see ``LayoutValueKey``.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol Layout : Animatable {
/// Properties of a layout container.
///
/// Implement this property in a type that conforms to the ``Layout``
/// protocol to characterize your custom layout container. For example,
/// you can indicate that your layout has a vertical
/// ``LayoutProperties/stackOrientation``:
///
///     extension BasicVStack {
///         static var layoutProperties: LayoutProperties {
///             var properties = LayoutProperties()
///             properties.stackOrientation = .vertical
///             return properties
///         }
///     }
///
/// If you don't implement this property in your custom layout, the protocol
/// provides a default implementation, namely ``layoutProperties-6h7w0``,
/// that returns a ``LayoutProperties`` instance with default values.
static var layoutProperties: LayoutProperties { get }
/// Cached values associated with the layout instance.
///
/// If you create a cache for your custom layout, you can use
/// a type alias to define this type as your data storage type.
/// Alternatively, you can refer to the data storage type directly in all
/// the places where you work with the cache.
///
/// See ``makeCache(subviews:)-23agy`` for more information.
associatedtype Cache = Void
/// A collection of proxies for the subviews of a layout view.
///
/// This collection doesn't store views. Instead it stores instances of
/// ``LayoutSubview``, each of which acts as a proxy for one of the
/// views arranged by the layout. Use the proxies to
/// get information about the views, and to tell the views where to
/// appear.
///
/// For more information about the behavior of the underlying
/// collection type, see ``LayoutSubviews``.
typealias Subviews = LayoutSubviews
/// Creates and initializes a cache for a layout instance.
///
/// You can optionally use a cache to preserve calculated values across
/// calls to a layout container's methods. Many layout types don't need
/// a cache, because SwiftUI automatically reuses both the results of
/// calls into the layout and the values that the layout reads from its
/// subviews. Rely on the protocol's default implementation of this method
/// if you don't need a cache.
///
/// However you might find a cache useful when:
///
/// - The layout container repeats complex, intermediate calculations
/// across calls like ``sizeThatFits(proposal:subviews:cache:)``,
/// ``placeSubviews(in:proposal:subviews:cache:)``, and
/// ``explicitAlignment(of:in:proposal:subviews:cache:)-8ofeu``.
/// You might be able to improve performance by calculating values
/// once and storing them in a cache.
/// - The layout container reads many ``LayoutValueKey`` values from
/// subviews. It might be more efficient to do that once and store the
/// results in the cache, rather than rereading the subviews' values before
/// each layout call.
/// - You want to maintain working storage, like temporary Swift arrays,
/// across calls into the layout, to minimize the number of allocation
/// events.
///
/// Only implement a cache if profiling shows that it improves performance.
///
/// ### Initialize a cache
///
/// Implement the `makeCache(subviews:)` method to create a cache.
/// You can add computed values to the cache right away, using information
/// from the `subviews` input parameter, or you can do that later. The
/// methods of the ``Layout`` protocol that can access the cache
/// take the cache as an in-out parameter, which enables you to modify
/// the cache anywhere that you can read it.
///
/// You can use any storage type that makes sense for your layout
/// algorithm, but be sure that you only store data that you derive
/// from the layout and its subviews (lazily, if possible). For this to
/// work correctly, SwiftUI needs to be able to call this method to
/// recreate the cache without changing the layout result.
///
/// When you return a cache from this method, you implicitly define a type
/// for your cache. Be sure to either make the type of the `cache`
/// parameters on your other ``Layout`` protocol methods match, or use
/// a type alias to define the ``Cache`` associated type.
///
/// ### Update the cache
///
/// If the layout container or any of its subviews change, SwiftUI
/// calls the ``updateCache(_:subviews:)-9hkj9`` method so you can
/// modify or invalidate the contents of the
/// cache. The default implementation of that method calls the
/// `makeCache(subviews:)` method to recreate the cache, but you can
/// provide your own implementation of the update method to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
///
/// - Returns: Storage for calculated data that you share among
///   the methods of your custom layout container.
func makeCache(subviews: Self.Subviews) -> Self.Cache
/// Updates the layout's cache when something changes.
///
/// If your custom layout container creates a cache by implementing the
/// ``makeCache(subviews:)-23agy`` method, SwiftUI calls the update method
/// when your layout or its subviews change, giving you an opportunity
/// to modify or invalidate the contents of the cache.
/// The method's default implementation recreates the
/// cache by calling the ``makeCache(subviews:)-23agy`` method,
/// but you can provide your own implementation to take an
/// incremental approach, if appropriate.
///
/// - Parameters:
///   - cache: Storage for calculated data that you share among
///     the methods of your custom layout container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you
///     calculate values to store in the cache.
func updateCache(_ cache: inout Self.Cache, subviews: Self.Subviews)
/// Returns the preferred spacing values of the composite view.
///
/// Implement this method to provide custom spacing preferences
/// for a layout container. The value you return affects
/// the spacing around the container, but it doesn't affect how the
/// container arranges subviews relative to one another inside the
/// container.
///
/// Create a custom ``ViewSpacing`` instance for your container by
/// initializing one with default values, and then merging that with
/// spacing instances of certain subviews. For example, if you define
/// a basic vertical stack that places subviews in a column, you could
/// use the spacing preferences of the subview edges that make
/// contact with the container's edges:
///
///     extension BasicVStack {
///         func spacing(subviews: Subviews, cache: inout ()) -> ViewSpacing {
///             var spacing = ViewSpacing()
///
///             for index in subviews.indices {
///                 var edges: Edge.Set = [.leading, .trailing]
///                 if index == 0 { edges.formUnion(.top) }
///                 if index == subviews.count - 1 { edges.formUnion(.bottom) }
///                 spacing.formUnion(subviews[index].spacing, edges: edges)
///             }
///
///             return spacing
///         }
///     }
///
/// In the above example, the first and last subviews contribute to the
/// spacing above and below the container, respectively, while all subviews
/// affect the spacing on the leading and trailing edges.
///
/// If you don't implement this method, the protocol provides a default
/// implementation, namely ``Layout/spacing(subviews:cache:)-1z0gt``,
/// that merges the spacing preferences across all subviews on all edges.
///
/// - Parameters:
///   - subviews: A collection of proxy instances that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much spacing the container prefers around it.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A ``ViewSpacing`` instance that describes the preferred
///   spacing around the container view.
func spacing(subviews: Self.Subviews, cache: inout Self.Cache) -> ViewSpacing
/// Returns the size of the composite view, given a proposed size
/// and the view's subviews.
///
/// Implement this method to tell your custom layout container's parent
/// view how much space the container needs for a set of subviews, given
/// a size proposal. The parent might call this method more than once
/// during a layout pass with different proposed sizes to test the
/// flexibility of the container, using proposals like:
///
/// * The ``ProposedViewSize/zero`` proposal; respond with the
///   layout's minimum size.
/// * The ``ProposedViewSize/infinity`` proposal; respond with the
///   layout's maximum size.
/// * The ``ProposedViewSize/unspecified`` proposal; respond with the
///   layout's ideal size.
///
/// The parent might also choose to test flexibility in one dimension at a
/// time. For example, a horizontal stack might propose a fixed height and
/// an infinite width, and then the same height with a zero width.
///
/// The following example calculates the size for a basic vertical stack
/// that places views in a column, with no spacing between the views:
///
///     private struct BasicVStack: Layout {
///         func sizeThatFits(
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGSize {
///             subviews.reduce(CGSize.zero) { result, subview in
///                 let size = subview.sizeThatFits(.unspecified)
///                 return CGSize(
///                     width: max(result.width, size.width),
///                     height: result.height + size.height)
///             }
///         }
///
///         // This layout also needs a placeSubviews() implementation.
///     }
///
/// The implementation asks each subview for its ideal size by calling the
/// ``LayoutSubview/sizeThatFits(_:)`` method with an
/// ``ProposedViewSize/unspecified`` proposed size.
/// It then reduces these values into a single size that represents
/// the maximum subview width and the sum of subview heights.
/// Because this example isn't flexible, it ignores its size proposal
/// input and always returns the same value for a given set of subviews.
///
/// SwiftUI views choose their own size, so the layout engine always
/// uses a value that you return from this method as the actual size of the
/// composite view. That size factors into the construction of the `bounds`
/// input to the ``placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// - Parameters:
///   - proposal: A size proposal for the container. The container's parent
///     view that calls this method might call the method more than once
///     with different proposals to learn more about the container's
///     flexibility before deciding which proposal to use for placement.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     how much space the container needs to display them.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: A size that indicates how much space the container
///   needs to arrange its subviews.
func sizeThatFits(proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache) -> CGSize
/// Assigns positions to each of the layout's subviews.
///
/// SwiftUI calls your implementation of this method to tell your
/// custom layout container to place its subviews. From this method, call
/// the ``LayoutSubview/place(at:anchor:proposal:)`` method on each
/// element in `subviews` to tell the subviews where to appear in the
/// user interface.
///
/// For example, you can create a basic vertical stack that places views
/// in a column, with views horizontally aligned on their leading edge:
///
///     struct BasicVStack: Layout {
///         func placeSubviews(
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) {
///             var point = bounds.origin
///             for subview in subviews {
///                 subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///                 point.y += subview.dimensions(in: .unspecified).height
///             }
///         }
///
///         // This layout also needs a sizeThatFits() implementation.
///     }
///
/// The example creates a placement point that starts at the origin of the
/// specified `bounds` input and uses that to place the first subview. It
/// then moves the point in the y dimension by the subview's height,
/// which it reads using the ``LayoutSubview/dimensions(in:)`` method.
/// This prepares the point for the next iteration of the loop. All
/// subview operations use an ``ProposedViewSize/unspecified`` size
/// proposal to indicate that subviews should use and report their ideal
/// size.
///
/// A more complex layout container might add space between subviews
/// according to their ``LayoutSubview/spacing`` preferences, or a
/// fixed space based on input configuration. For example, you can extend
/// the basic vertical stack's placement method to calculate the
/// preferred distances between adjacent subviews and store the results in
/// an array:
///
///     let spacing: [CGFloat] = subviews.indices.dropLast().map { index in
///         subviews[index].spacing.distance(
///             to: subviews[index + 1].spacing,
///             along: .vertical)
///     }
///
/// The spacing's ``ViewSpacing/distance(to:along:)`` method considers the
/// preferences of adjacent views on the edge where they meet. It returns
/// the smallest distance that satisfies both views' preferences for the
/// given edge. For example, if one view prefers at least `2` points on its
/// bottom edge, and the next view prefers at least `8` points on its top
/// edge, the distance method returns `8`, because that's the smallest
/// value that satisfies both preferences.
///
/// Update the placement calculations to use the spacing values:
///
///     var point = bounds.origin
///     for (index, subview) in subviews.enumerated() {
///         if index > 0 { point.y += spacing[index - 1] } // Add spacing.
///         subview.place(at: point, anchor: .topLeading, proposal: .unspecified)
///         point.y += subview.dimensions(in: .unspecified).height
///     }
///
/// Be sure that you use computations during placement that are consistent
/// with those in your implementation of other protocol methods for a given
/// set of inputs. For example, if you add spacing during placement,
/// make sure your implementation of
/// ``sizeThatFits(proposal:subviews:cache:)`` accounts for the extra space.
/// Similarly, if the sizing method returns different values for different
/// size proposals, make sure the placement method responds to its
/// `proposal` input in the same way.
///
/// - Parameters:
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///     Place all the container's subviews within the region.
///     The size of this region matches a size that your container
///     previously returned from a call to the
///     ``sizeThatFits(proposal:subviews:cache:)`` method.
///   - proposal: The size proposal from which the container generated the
///     size that the parent used to create the `bounds` parameter.
///     The parent might propose more than one size before calling the
///     placement method, but it always uses one of the proposals and the
///     corresponding returned size when placing the container.
///   - subviews: A collection of proxies that represent the
///     views that the container arranges. Use the proxies in the collection
///     to get information about the subviews and to tell the subviews
///     where to appear.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache)
/// Returns the position of the specified horizontal alignment guide along
/// the x axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can indent the container's leading edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: HorizontalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .leading {
///                 return bounds.minX + 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``HorizontalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache) -> CGFloat?
/// Returns the position of the specified vertical alignment guide along
/// the y axis.
///
/// Implement this method to return a value for the specified alignment
/// guide of a custom layout container. The value you return affects
/// the placement of the container as a whole, but it doesn't affect how the
/// container arranges subviews relative to one another.
///
/// You can use this method to put an alignment guide in a nonstandard
/// position. For example, you can raise the container's bottom edge
/// alignment guide by 10 points:
///
///     extension BasicVStack {
///         func explicitAlignment(
///             of guide: VerticalAlignment,
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) -> CGFloat? {
///             if guide == .bottom {
///                 return bounds.minY - 10
///             }
///             return nil
///         }
///     }
///
/// The above example returns `nil` for other guides to indicate that they
/// don't have an explicit value. A guide without an explicit value behaves
/// as it would for any other view. If you don't implement the
/// method, the protocol's default implementation merges the
/// subviews' guides.
///
/// - Parameters:
///   - guide: The ``VerticalAlignment`` guide that the method calculates
///     the position of.
///   - bounds: The region that the container view's parent allocates to the
///     container view, specified in the parent's coordinate space.
///   - proposal: A proposed size for the container.
///   - subviews: A collection of proxy instances that represent the
///     views arranged by the container. You can use the proxies in the
///     collection to get information about the subviews as you determine
///     where to place the guide.
///   - cache: Optional storage for calculated data that you can share among
///     the methods of your custom layout container. See
///     ``makeCache(subviews:)-23agy`` for details.
///
/// - Returns: The guide's position relative to the `bounds`.
///   Return `nil` to indicate that the guide doesn't have an explicit
///   value.
func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache) -> CGFloat?
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Layout {
/// The default property values for a layout.
///
/// If you don't implement the ``layoutProperties-5rb5b`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which returns a ``LayoutProperties`` instance with
/// default values. The properties instance contains information about the
/// layout container, like a ``LayoutProperties/stackOrientation``
/// property that indicates the container's major axis.
public static var layoutProperties: LayoutProperties { get }
/// Reinitializes a cache to a new value.
///
/// If you don't implement the ``updateCache(_:subviews:)-9hkj9`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which calls ``makeCache(subviews:)-23agy``.
public func updateCache(_ cache: inout Self.Cache, subviews: Self.Subviews)
/// Returns the result of merging the horizontal alignment guides of all
/// subviews.
///
/// If you don't implement the
/// ``explicitAlignment(of:in:proposal:subviews:cache:)-8ofeu`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which merges the guides of all the subviews.
public func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache) -> CGFloat?
/// Returns the result of merging the vertical alignment guides of all
/// subviews.
///
/// If you don't implement the
/// ``explicitAlignment(of:in:proposal:subviews:cache:)-3iqmu`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which merges the guides of all the subviews.
public func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Self.Subviews, cache: inout Self.Cache) -> CGFloat?
/// Returns the union of all subview spacing.
///
/// If you don't implement the ``spacing(subviews:cache:)-86z2e`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which returns the union of the spacing preferences of all
/// the layout's subviews.
public func spacing(subviews: Self.Subviews, cache: inout Self.Cache) -> ViewSpacing
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Layout where Self.Cache == () {
/// Returns the empty value when your layout doesn't require a cache.
///
/// If you don't implement the ``makeCache(subviews:)-23agy`` method in
/// your custom layout, the protocol uses this default implementation
/// instead, which returns an empty value.
public func makeCache(subviews: Self.Subviews) -> Self.Cache
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Layout {
/// Combines the specified views into a single composite view using
/// the layout algorithms of the custom layout container.
///
/// Don't call this method directly. SwiftUI calls it when you
/// instantiate a custom layout that conforms to the ``Layout``
/// protocol:
///
///     BasicVStack { // Implicitly calls callAsFunction.
///         Text("A View")
///         Text("Another View")
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameter content: A ``ViewBuilder`` that contains the views to
///   lay out.
///
/// - Returns: A composite view that combines all the input views.
public func callAsFunction<V>(@ViewBuilder _ content: () -> V) -> some View where V : View
}
/// A direction in which SwiftUI can lay out content.
///
/// SwiftUI supports both left-to-right and right-to-left directions
/// for laying out content to support different languages and locales.
/// The system sets the value based on the user's locale, but
/// you can also use the ``View/environment(_:_:)`` modifier
/// to override the direction for a view and its child views:
///
///     MyView()
///         .environment(\.layoutDirection, .rightToLeft)
///
/// You can also read the ``EnvironmentValues/layoutDirection`` environment
/// value to find out which direction applies to a particular environment.
/// However, in many cases, you don't need to take any action based on this
/// value. SwiftUI horizontally flips the x position of each view within its
/// parent, so layout calculations automatically produce the desired effect
/// for both modes without any changes.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum LayoutDirection : Hashable, CaseIterable, Sendable {
/// A left-to-right layout direction.
case leftToRight
/// A right-to-left layout direction.
case rightToLeft
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: LayoutDirection, b: LayoutDirection) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [LayoutDirection]
/// A collection of all values of this type.
public static var allCases: [LayoutDirection] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
extension LayoutDirection {
/// Create a direction from its UITraitEnvironmentLayoutDirection equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiLayoutDirection: UITraitEnvironmentLayoutDirection)
}
/// A description of what should happen when the layout direction changes.
///
/// A `LayoutDirectionBehavior` can be used with the `layoutDirectionBehavior`
/// view modifier or the `layoutDirectionBehavior` property of `Shape`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public enum LayoutDirectionBehavior : Hashable, Sendable {
/// A behavior that doesn't mirror when the layout direction changes.
case fixed
/// A behavior that mirrors when the layout direction has the specified
/// value.
///
/// If you develop your view or shape in an LTR context, you can use
/// `.mirrors(in: .rightToLeft)` (which is equivalent to `.mirrors`) to
/// mirror your content when the layout direction is RTL (and keep the
/// original version in LTR). If you developer in an RTL context, you can
/// use `.mirrors(in: .leftToRight)` to mirror your content when the layout
/// direction is LTR (and keep the original version in RTL).
case mirrors(in: LayoutDirection)
/// A behavior that mirrors when the layout direction is right-to-left.
public static var mirrors: LayoutDirectionBehavior { get }
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: LayoutDirectionBehavior, b: LayoutDirectionBehavior) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Layout-specific properties of a layout container.
///
/// This structure contains configuration information that's
/// applicable to a layout container. For example, the ``stackOrientation``
/// value indicates the layout's primary axis, if any.
///
/// You can use an instance of this type to characterize a custom layout
/// container, which is a type that conforms to the ``Layout`` protocol.
/// Implement the protocol's ``Layout/layoutProperties-5rb5b`` property
/// to return an instance. For example, you can indicate that your layout
/// has a vertical stack orientation:
///
///     extension BasicVStack {
///         static var layoutProperties: LayoutProperties {
///             var properties = LayoutProperties()
///             properties.stackOrientation = .vertical
///             return properties
///         }
///     }
///
/// If you don't implement the property in your custom layout, the protocol
/// provides a default implementation that returns a `LayoutProperties`
/// instance with default values.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LayoutProperties : Sendable {
/// Creates a default set of properties.
///
/// Use a layout properties instance to provide information about
/// a type that conforms to the ``Layout`` protocol. For example, you
/// can create a layout properties instance in your layout's implementation
/// of the ``Layout/layoutProperties-5rb5b`` method, and use it to
/// indicate that the layout has a ``Axis/vertical`` orientation:
///
///     extension BasicVStack {
///         static var layoutProperties: LayoutProperties {
///             var properties = LayoutProperties()
///             properties.stackOrientation = .vertical
///             return properties
///         }
///     }
///
public init()
/// The orientation of the containing stack-like container.
///
/// Certain views alter their behavior based on the stack orientation
/// of the container that they appear in. For example, ``Spacer`` and
/// ``Divider`` align their major axis to match that of their container.
///
/// Set the orientation for your custom layout container by returning a
/// configured ``LayoutProperties`` instance from your ``Layout``
/// type's implementation of the ``Layout/layoutProperties-5rb5b``
/// method. For example, you can indicate that your layout has a
/// ``Axis/vertical`` major axis:
///
///     extension BasicVStack {
///         static var layoutProperties: LayoutProperties {
///             var properties = LayoutProperties()
///             properties.stackOrientation = .vertical
///             return properties
///         }
///     }
///
/// A value of `nil`, which is the default when you don't specify a
/// value, indicates an unknown orientation, or that a layout isn't
/// one-dimensional.
public var stackOrientation: Axis?
}
/// A proxy that represents one subview of a layout.
///
/// This type acts as a proxy for a view that your custom layout container
/// places in the user interface. ``Layout`` protocol methods
/// receive a ``LayoutSubviews`` collection that contains exactly one
/// proxy for each of the subviews arranged by your container.
///
/// Use a proxy to get information about the associated subview, like its
/// dimensions, layout priority, or custom layout values. You also use the
/// proxy to tell its corresponding subview where to appear by calling the
/// proxy's ``LayoutSubview/place(at:anchor:proposal:)`` method.
/// Do this once for each subview from your implementation of the layout's
/// ``Layout/placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// You can read custom layout values associated with a subview
/// by using the property's key as an index on the subview. For more
/// information about defining, setting, and reading custom values,
/// see ``LayoutValueKey``.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LayoutSubview : Equatable {
/// Gets the value for the subview that's associated with the specified key.
///
/// If you define a custom layout value using ``LayoutValueKey``,
/// you can read the key's associated value for a given subview in
/// a layout container by indexing the container's subviews with
/// the key type. For example, if you define a `Flexibility` key
/// type, you can put the associated values of all the layout's
/// subviews into an array:
///
///     let flexibilities = subviews.map { subview in
///         subview[Flexibility.self]
///     }
///
/// For more information about creating a custom layout, see ``Layout``.
public subscript<K>(key: K.Type) -> K.Value where K : LayoutValueKey { get }
/// The layout priority of the subview.
///
/// If you define a custom layout type using the ``Layout``
/// protocol, you can read this value from subviews and use the value
/// when deciding how to assign space to subviews. For example, you
/// can read all of the subview priorities into an array before
/// placing the subviews in a custom layout type called `BasicVStack`:
///
///     extension BasicVStack {
///         func placeSubviews(
///             in bounds: CGRect,
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout ()
///         ) {
///             let priorities = subviews.map { subview in
///                 subview.priority
///             }
///
///             // Place views, based on priorities.
///         }
///     }
///
/// Set the layout priority for a view that appears in your layout by
/// applying the ``View/layoutPriority(_:)`` view modifier. For example,
/// you can assign two different priorities to views that you arrange
/// with `BasicVStack`:
///
///     BasicVStack {
///         Text("High priority")
///             .layoutPriority(10)
///         Text("Low priority")
///             .layoutPriority(1)
///     }
///
public var priority: Double { get }
/// Asks the subview for its size.
///
/// Use this method as a convenience to get the ``ViewDimensions/width``
/// and ``ViewDimensions/height`` properties of the ``ViewDimensions``
/// instance returned by the ``dimensions(in:)`` method, reported as a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGSize>
/// instance.
///
/// - Parameter proposal: A proposed size for the subview. In SwiftUI,
///   views choose their own size, but can take a size proposal from
///   their parent view into account when doing so.
///
/// - Returns: The size that the subview chooses for itself, given the
///   proposal from its container view.
public func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
/// Asks the subview for its dimensions and alignment guides.
///
/// Call this method to ask a subview of a custom ``Layout`` type
/// about its size and alignment properties. You can call it from
/// your implementation of any of that protocol's methods, like
/// ``Layout/placeSubviews(in:proposal:subviews:cache:)`` or
/// ``Layout/sizeThatFits(proposal:subviews:cache:)``, to get
/// information for your layout calculations.
///
/// When you call this method, you propose a size using the `proposal`
/// parameter. The subview can choose its own size, but might take the
/// proposal into account. You can call this method more than
/// once with different proposals to find out if the view is flexible.
/// For example, you can propose:
///
/// * ``ProposedViewSize/zero`` to get the subview's minimum size.
/// * ``ProposedViewSize/infinity`` to get the subview's maximum size.
/// * ``ProposedViewSize/unspecified`` to get the subview's ideal size.
///
/// If you need only the view's height and width, you can use the
/// ``sizeThatFits(_:)`` method instead.
///
/// - Parameter proposal: A proposed size for the subview. In SwiftUI,
///   views choose their own size, but can take a size proposal from
///   their parent view into account when doing so.
///
/// - Returns: A ``ViewDimensions`` instance that includes a height
///   and width, as well as a set of alignment guides.
public func dimensions(in proposal: ProposedViewSize) -> ViewDimensions
/// The subviews's preferred spacing values.
///
/// This ``ViewSpacing`` instance indicates how much space a subview
/// in a custom layout prefers to have between it and the next view.
/// It contains preferences for all edges, and might take into account
/// the type of both this and the adjacent view. If your ``Layout`` type
/// places subviews based on spacing preferences, use this instance
/// to compute a distance between this subview and the next. See
/// ``Layout/placeSubviews(in:proposal:subviews:cache:)`` for an
/// example.
///
/// You can also merge this instance with instances from other subviews
/// to construct a new instance that's suitable for the subviews' container.
/// See ``Layout/spacing(subviews:cache:)-86z2e``.
public var spacing: ViewSpacing { get }
/// Assigns a position and proposed size to the subview.
///
/// Call this method from your implementation of the ``Layout``
/// protocol's ``Layout/placeSubviews(in:proposal:subviews:cache:)``
/// method for each subview arranged by the layout.
/// Provide a position within the container's bounds where the subview
/// should appear, and an anchor that indicates which part of the subview
/// appears at that point.
///
/// Include a proposed size that the subview can take into account when
/// sizing itself. To learn the subview's size for a given proposal before
/// calling this method, you can call the ``dimensions(in:)`` or
/// ``sizeThatFits(_:)`` method on the subview with the same proposal.
/// That enables you to know subview sizes before committing to subview
/// positions.
///
/// > Important: Call this method only from within your
///   ``Layout`` type's implementation of the
/// ``Layout/placeSubviews(in:proposal:subviews:cache:)`` method.
///
/// If you call this method more than once for a subview, the last call
/// takes precedence. If you don't call this method for a subview, the
/// subview appears at the center of its layout container and uses the
/// layout container's size proposal.
///
/// - Parameters:
///   - position: The place where the anchor of the subview should
///     appear in its container view, relative to container's bounds.
///   - anchor: The unit point on the subview that appears at `position`.
///     You can use a built-in point, like ``UnitPoint/center``, or
///     you can create a custom ``UnitPoint``.
///   - proposal: A proposed size for the subview. In SwiftUI,
///     views choose their own size, but can take a size proposal from
///     their parent view into account when doing so.
public func place(at position: CGPoint, anchor: UnitPoint = .topLeading, proposal: ProposedViewSize)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: LayoutSubview, b: LayoutSubview) -> Bool
}
/// A collection of proxy values that represent the subviews of a layout view.
///
/// You receive a `LayoutSubviews` input to your implementations of
/// ``Layout`` protocol methods, like
/// ``Layout/placeSubviews(in:proposal:subviews:cache:)`` and
/// ``Layout/sizeThatFits(proposal:subviews:cache:)``. The `subviews`
/// parameter (which the protocol aliases to the ``Layout/Subviews`` type)
/// is a collection that contains proxies for the layout's subviews (of type
/// ``LayoutSubview``). The proxies appear in the collection in the same
/// order that they appear in the ``ViewBuilder`` input to the layout
/// container. Use the proxies to perform layout operations.
///
/// Access the proxies in the collection as you would the contents of any
/// Swift random-access collection. For example, you can enumerate all of the
/// subviews and their indices to inspect or operate on them:
///
///     for (index, subview) in subviews.enumerated() {
///         // ...
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct LayoutSubviews : Equatable, RandomAccessCollection, Sendable {
/// A type that contains a subsequence of proxy values.
public typealias SubSequence = LayoutSubviews
/// A type that contains a proxy value.
public typealias Element = LayoutSubview
/// A type that you can use to index proxy values.
public typealias Index = Int
/// The layout direction inherited by the container view.
///
/// SwiftUI supports both left-to-right and right-to-left directions.
/// Read this property within a custom layout container
/// to find out which environment the container is in.
///
/// In most cases, you don't need to take any action based on this
/// value. SwiftUI horizontally flips the x position of each view within its
/// parent when the mode switches, so layout calculations automatically
/// produce the desired effect for both directions.
public var layoutDirection: LayoutDirection
/// The index of the first subview.
public var startIndex: Int { get }
/// An index that's one higher than the last subview.
public var endIndex: Int { get }
/// Gets the subview proxy at a specified index.
public subscript(index: Int) -> LayoutSubviews.Element { get }
/// Gets the subview proxies in the specified range.
public subscript(bounds: Range<Int>) -> LayoutSubviews { get }
/// Gets the subview proxies with the specified indicies.
public subscript<S>(indices: S) -> LayoutSubviews where S : Sequence, S.Element == Int { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: LayoutSubviews, rhs: LayoutSubviews) -> Bool
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = Range<LayoutSubviews.Index>
/// A type that provides the collection's iteration interface and
/// encapsulates its iteration state.
///
/// By default, a collection conforms to the `Sequence` protocol by
/// supplying `IndexingIterator` as its associated `Iterator`
/// type.
public typealias Iterator = IndexingIterator<LayoutSubviews>
}
/// A key for accessing a layout value of a layout container's subviews.
///
/// If you create a custom layout by defining a type that conforms to the
/// ``Layout`` protocol, you can also create custom layout values
/// that you set on individual views, and that your container view can access
/// to guide its layout behavior. Your custom values resemble
/// the built-in layout values that you set with view modifiers
/// like ``View/layoutPriority(_:)`` and ``View/zIndex(_:)``, but have a
/// purpose that you define.
///
/// To create a custom layout value, define a type that conforms to the
/// `LayoutValueKey` protocol and implement the one required property that
/// returns the default value of the property. For example, you can create
/// a property that defines an amount of flexibility for a view, defined as
/// an optional floating point number with a default value of `nil`:
///
///     private struct Flexibility: LayoutValueKey {
///         static let defaultValue: CGFloat? = nil
///     }
///
/// The Swift compiler infers this particular key's associated type as an
/// optional <doc://com.apple.documentation/documentation/CoreFoundation/CGFloat>
/// from this definition.
///
/// ### Set a value on a view
///
/// Set the value on a view by adding the ``View/layoutValue(key:value:)``
/// view modifier to the view. To make your custom value easier to work
/// with, you can do this in a convenience modifier in an extension of the
/// ``View`` protocol:
///
///     extension View {
///         func layoutFlexibility(_ value: CGFloat?) -> some View {
///             layoutValue(key: Flexibility.self, value: value)
///         }
///     }
///
/// Use your modifier to set the value on any views that need a nondefault
/// value:
///
///     BasicVStack {
///         Text("One View")
///         Text("Another View")
///             .layoutFlexibility(3)
///     }
///
/// Any view that you don't explicitly set a value for uses the default
/// value, as with the first ``Text`` view, above.
///
/// ### Retrieve a value during layout
///
/// Access a custom layout value using the key as an index
/// on subview's proxy (an instance of ``LayoutSubview``)
/// and use the value to make decisions about sizing, placement, or other
/// layout operations. For example, you might read the flexibility value
/// in your layout view's ``LayoutSubview/sizeThatFits(_:)`` method, and
/// adjust your size calculations accordingly:
///
///     extension BasicVStack {
///         func sizeThatFits(
///             proposal: ProposedViewSize,
///             subviews: Subviews,
///             cache: inout Void
///         ) -> CGSize {
///
///             // Map the flexibility property of each subview into an array.
///             let flexibilities = subviews.map { subview in
///                 subview[Flexibility.self]
///             }
///
///             // Calculate and return the size of the layout container.
///             // ...
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol LayoutValueKey {
/// The type of the key's value.
///
/// Swift typically infers this type from your implementation of the
/// ``defaultValue`` property, so you don't have to define it explicitly.
associatedtype Value
/// The default value of the key.
///
/// Implement the `defaultValue` property for a type that conforms to the
/// ``LayoutValueKey`` protocol. For example, you can create a `Flexibility`
/// layout value that defaults to `nil`:
///
///     private struct Flexibility: LayoutValueKey {
///         static let defaultValue: CGFloat? = nil
///     }
///
/// The type that you declare for the `defaultValue` sets the layout
/// key's ``Value`` associated type. The Swift compiler infers the key's
/// associated type in the above example as an optional
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGFloat>.
///
/// Any view that you don't explicitly set a value for uses the default
/// value. Override the default value for a view using the
/// ``View/layoutValue(key:value:)`` modifier.
static var defaultValue: Self.Value { get }
}
/// A container view that arranges its child views in a grid that
/// grows horizontally, creating items only as needed.
///
/// Use a lazy horizontal grid when you want to display a large, horizontally
/// scrollable collection of views arranged in a two dimensional layout. The
/// first view that you provide to the grid's `content` closure appears in the
/// top row of the column that's on the grid's leading edge. Additional views
/// occupy successive cells in the grid, filling the first column from top to
/// bottom, then the second column, and so on. The number of columns can grow
/// unbounded, but you specify the number of rows by providing a
/// corresponding number of ``GridItem`` instances to the grid's initializer.
///
/// The grid in the following example defines two rows and uses a ``ForEach``
/// structure to repeatedly generate a pair of ``Text`` views for the rows
/// in each column:
///
///     struct HorizontalSmileys: View {
///         let rows = [GridItem(.fixed(30)), GridItem(.fixed(30))]
///
///         var body: some View {
///             ScrollView(.horizontal) {
///                 LazyHGrid(rows: rows) {
///                     ForEach(0x1f600...0x1f679, id: \.self) { value in
///                         Text(String(format: "%x", value))
///                         Text(emoji(value))
///                             .font(.largeTitle)
///                     }
///                 }
///             }
///         }
///
///         private func emoji(_ value: Int) -> String {
///             guard let scalar = UnicodeScalar(value) else { return "?" }
///             return String(Character(scalar))
///         }
///     }
///
/// For each column in the grid, the top row shows a Unicode code point from
/// the "Smileys" group, and the bottom shows its corresponding emoji:
///
/// ![A screenshot of a row of hexadecimal numbers above a row of emoji,
/// with each number and a corresponding emoji making up a column.
/// Half of each of the first and last column are cut off on either end
/// of the image, with eight columns fully visible.](LazyHGrid-1-iOS)
///
/// You can achieve a similar layout using a ``Grid`` container. Unlike a lazy
/// grid, which creates child views only when SwiftUI needs to display
/// them, a regular grid creates all of its child views right away. This
/// enables the grid to provide better support for cell spacing and alignment.
/// Only use a lazy grid if profiling your app shows that a ``Grid`` view
/// performs poorly because it tries to load too many views at once.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LazyHGrid<Content> : View where Content : View {
/// Creates a grid that grows horizontally.
///
/// - Parameters:
///   - rows: An array of grid items that size and position each column of
///    the grid.
///   - alignment: The alignment of the grid within its parent view.
///   - spacing: The spacing between the grid and the next item in its
///   parent view.
///   - pinnedViews: Views to pin to the bounds of a parent scroll view.
///   - content: The content of the grid.
public init(rows: [GridItem], alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that arranges its children in a line that grows horizontally,
/// creating items only as needed.
///
/// The stack is "lazy," in that the stack view doesn't create items until
/// it needs to render them onscreen.
///
/// In the following example, a ``ScrollView`` contains a `LazyHStack` that
/// consists of a horizontal row of text views. The stack aligns to the top
/// of the scroll view and uses 10-point spacing between each text view.
///
///     ScrollView(.horizontal) {
///         LazyHStack(alignment: .top, spacing: 10) {
///             ForEach(1...100, id: \.self) {
///                 Text("Column \($0)")
///             }
///         }
///     }
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LazyHStack<Content> : View where Content : View {
/// Creates a lazy horizontal stack view with the given spacing,
/// vertical alignment, pinning behavior, and content.
///
/// - Parameters:
///     - alignment: The guide for aligning the subviews in this stack. All
///       child views have the same vertical screen coordinate.
///     - spacing: The distance between adjacent subviews, or `nil` if you
///       want the stack to choose a default distance for each pair of
///       subviews.
///     - pinnedViews: The kinds of child views that will be pinned.
///     - content: A view builder that creates the content of this stack.
public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A container view that arranges its child views in a grid that
/// grows vertically, creating items only as needed.
///
/// Use a lazy vertical grid when you want to display a large, vertically
/// scrollable collection of views arranged in a two dimensional layout. The
/// first view that you provide to the grid's `content` closure appears in the
/// top row of the column that's on the grid's leading edge. Additional views
/// occupy successive cells in the grid, filling the first row from leading to
/// trailing edges, then the second row, and so on. The number of rows can grow
/// unbounded, but you specify the number of columns by providing a
/// corresponding number of ``GridItem`` instances to the grid's initializer.
///
/// The grid in the following example defines two columns and uses a
/// ``ForEach`` structure to repeatedly generate a pair of ``Text`` views for
/// the columns in each row:
///
///     struct VerticalSmileys: View {
///         let columns = [GridItem(.flexible()), GridItem(.flexible())]
///
///         var body: some View {
///              ScrollView {
///                  LazyVGrid(columns: columns) {
///                      ForEach(0x1f600...0x1f679, id: \.self) { value in
///                          Text(String(format: "%x", value))
///                          Text(emoji(value))
///                              .font(.largeTitle)
///                      }
///                  }
///              }
///         }
///
///         private func emoji(_ value: Int) -> String {
///             guard let scalar = UnicodeScalar(value) else { return "?" }
///             return String(Character(scalar))
///         }
///     }
///
/// For each row in the grid, the first column shows a Unicode code point from
/// the "Smileys" group, and the second shows its corresponding emoji:
///
/// ![A screenshot of a colunb of hexadecimal numbers to the left of a column
/// of emoji, with each number and a corresponding emoji making up a row.
/// Half of the last row is cut off, with seventeen rows fully
/// visible.](LazyVGrid-1-iOS)
///
/// You can achieve a similar layout using a ``Grid`` container. Unlike a lazy
/// grid, which creates child views only when SwiftUI needs to display
/// them, a regular grid creates all of its child views right away. This
/// enables the grid to provide better support for cell spacing and alignment.
/// Only use a lazy grid if profiling your app shows that a ``Grid`` view
/// performs poorly because it tries to load too many views at once.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LazyVGrid<Content> : View where Content : View {
/// Creates a grid that grows vertically.
///
/// - Parameters:
///   - columns: An array of grid items to size and position each row of
///    the grid.
///   - alignment: The alignment of the grid within its parent view.
///   - spacing: The spacing between the grid and the next item in its
///   parent view.
///   - pinnedViews: Views to pin to the bounds of a parent scroll view.
///   - content: The content of the grid.
public init(columns: [GridItem], alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that arranges its children in a line that grows vertically,
/// creating items only as needed.
///
/// The stack is "lazy," in that the stack view doesn't create items until
/// it needs to render them onscreen.
///
/// In the following example, a ``ScrollView`` contains a `LazyVStack` that
/// consists of a vertical row of text views. The stack aligns to the
/// leading edge of the scroll view, and uses default spacing between the
/// text views.
///
///     ScrollView {
///         LazyVStack(alignment: .leading) {
///             ForEach(1...100, id: \.self) {
///                 Text("Row \($0)")
///             }
///         }
///     }
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LazyVStack<Content> : View where Content : View {
/// Creates a lazy vertical stack view with the given spacing,
/// vertical alignment, pinning behavior, and content.
///
/// - Parameters:
///     - alignment: The guide for aligning the subviews in this stack. All
///     child views have the same horizontal screen coordinate.
///     - spacing: The distance between adjacent subviews, or `nil` if you
///       want the stack to choose a default distance for each pair of
///       subviews.
///     - pinnedViews: The kinds of child views that will be pinned.
///     - content: A view builder that creates the content of this stack.
public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The Accessibility Bold Text user setting options.
///
/// The app can't override the user's choice before iOS 16, tvOS 16 or
/// watchOS 9.0.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum LegibilityWeight : Hashable, Sendable {
/// Use regular font weight (no Accessibility Bold).
case regular
/// Use heavier font weight (force Accessibility Bold).
case bold
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: LegibilityWeight, b: LegibilityWeight) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
extension LegibilityWeight {
/// Creates a legibility weight from its UILegibilityWeight equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiLegibilityWeight: UILegibilityWeight)
}
/// A type-erased widget configuration.
///
/// You don't use this type directly. Instead SwiftUI creates this type on
/// your behalf.
@available(iOS 16.1, macOS 13.0, watchOS 9.1, *)
@available(tvOS, unavailable)
@frozen public struct LimitedAvailabilityConfiguration : WidgetConfiguration {
/// The type of widget configuration representing the body of
/// this configuration.
///
/// When you create a custom widget, Swift infers this type from your
/// implementation of the required `body` property.
public typealias Body = Never
}
/// A gauge style that displays bar that fills from leading to trailing
/// edges as the gauge's current value increases.
///
/// Use ``GaugeStyle/linearCapacity`` to construct this style.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct LinearCapacityGaugeStyle : GaugeStyle {
/// Creates a linear capacity gauge style.
public init()
/// Creates a view representing the body of a gauge.
///
/// The system calls this modifier on each instance of gauge within a view
/// hierarchy where this style is the current gauge style.
///
/// - Parameter configuration: The properties to apply to the gauge instance.
public func makeBody(configuration: LinearCapacityGaugeStyle.Configuration) -> some View
/// A view representing the body of a gauge.
public typealias Body = some View
}
/// A linear gradient.
///
/// The gradient applies the color function along an axis, as defined by its
/// start and end points. The gradient maps the unit space points into the
/// bounding rectangle of each shape filled with the gradient.
///
/// When using a linear gradient as a shape style, you can also use
/// ``ShapeStyle/linearGradient(_:startPoint:endPoint:)-753nc``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct LinearGradient : ShapeStyle, View, Sendable {
/// Creates a linear gradient from a base gradient.
public init(gradient: Gradient, startPoint: UnitPoint, endPoint: UnitPoint)
/// Creates a linear gradient from a collection of colors.
public init(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint)
/// Creates a linear gradient from a collection of color stops.
public init(stops: [Gradient.Stop], startPoint: UnitPoint, endPoint: UnitPoint)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A keyframe that uses simple linear interpolation.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct LinearKeyframe<Value> : KeyframeTrackContent where Value : Animatable {
/// Creates a new keyframe using the given value and timestamp.
///
/// - Parameters:
///   - to: The value of the keyframe.
///   - duration: The duration of the segment defined by this keyframe.
///   - timingCurve: A unit curve that controls the speed of interpolation.
public init(_ to: Value, duration: TimeInterval, timingCurve: UnitCurve = .linear)
public typealias Body = LinearKeyframe<Value>
}
/// A progress view that visually indicates its progress using a horizontal bar.
///
/// Use ``ProgressViewStyle/linear`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct LinearProgressViewStyle : ProgressViewStyle {
/// Creates a linear progress view style.
public init()
/// Creates a linear progress view style with a tint color.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
public init(tint: Color)
/// Creates a view representing the body of a progress view.
///
/// - Parameter configuration: The properties of the progress view being
///   created.
///
/// The view hierarchy calls this method for each progress view where this
/// style is the current progress view style.
///
/// - Parameter configuration: The properties of the progress view, such as
///  its preferred progress type.
public func makeBody(configuration: LinearProgressViewStyle.Configuration) -> some View
/// A view representing the body of a progress view.
public typealias Body = some View
}
/// A control for navigating to a URL.
///
/// Create a link by providing a destination URL and a title. The title
/// tells the user the purpose of the link, and can be a string, a title
/// key that produces a localized string, or a view that acts as a label.
/// The example below creates a link to `example.com` and displays the
/// title string as a link-styled view:
///
///     Link("View Our Terms of Service",
///           destination: URL(string: "https://www.example.com/TOS.html")!)
///
/// When a user taps or clicks a `Link`, the default behavior depends on the
/// contents of the URL. For example, SwiftUI opens a Universal Link in the
/// associated app if possible, or in the user's default web browser if not.
/// Alternatively, you can override the default behavior by setting the
/// ``EnvironmentValues/openURL`` environment value with a custom
/// ``OpenURLAction``:
///
///     Link("Visit Our Site", destination: URL(string: "https://www.example.com")!)
///         .environment(\.openURL, OpenURLAction { url in
///             print("Open \(url)")
///             return .handled
///         })
///
/// As with other views, you can style links using standard view modifiers
/// depending on the view type of the link's label. For example, a ``Text``
/// label could be modified with a custom ``View/font(_:)`` or
/// ``View/foregroundColor(_:)`` to customize the appearance of the link in
/// your app's UI.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct Link<Label> : View where Label : View {
/// Creates a control, consisting of a URL and a label, used to navigate
/// to the given URL.
///
/// - Parameters:
///     - destination: The URL for the link.
///     - label: A view that describes the destination of URL.
public init(destination: URL, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Link where Label == Text {
/// Creates a control, consisting of a URL and a title key, used to
/// navigate to a URL.
///
/// Use ``Link`` to create a control that your app uses to navigate to a
/// URL that you provide. The example below creates a link to
/// `example.com` and uses `Visit Example Co` as the title key to
/// generate a link-styled view in your app:
///
///     Link("Visit Example Co",
///           destination: URL(string: "https://www.example.com/")!)
///
/// - Parameters:
///     - titleKey: The key for the localized title that describes the
///       purpose of this link.
///     - destination: The URL for the link.
public init(_ titleKey: LocalizedStringKey, destination: URL)
/// Creates a control, consisting of a URL and a title string, used to
/// navigate to a URL.
///
/// Use ``Link`` to create a control that your app uses to navigate to a
/// URL that you provide. The example below creates a link to
/// `example.com` and displays the title string you provide as a
/// link-styled view in your app:
///
///     func marketingLink(_ callToAction: String) -> Link {
///         Link(callToAction,
///             destination: URL(string: "https://www.example.com/")!)
///     }
///
/// - Parameters:
///     - title: A text string used as the title for describing the
///       underlying `destination` URL.
///     - destination: The URL for the link.
public init<S>(_ title: S, destination: URL) where S : StringProtocol
}
/// A style appropriate for links.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct LinkShapeStyle : ShapeStyle {
/// Creates a new link shape style instance.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A container that presents rows of data arranged in a single column,
/// optionally providing the ability to select one or more members.
///
/// In its simplest form, a `List` creates its contents statically, as shown in
/// the following example:
///
///     var body: some View {
///         List {
///             Text("A List Item")
///             Text("A Second List Item")
///             Text("A Third List Item")
///         }
///     }
///
/// ![A vertical list with three text views.](List-1-iOS)
///
/// More commonly, you create lists dynamically from an underlying collection
/// of data. The following example shows how to create a simple list from an
/// array of an `Ocean` type which conforms to
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>:
///
///     struct Ocean: Identifiable {
///         let name: String
///         let id = UUID()
///     }
///
///     private var oceans = [
///         Ocean(name: "Pacific"),
///         Ocean(name: "Atlantic"),
///         Ocean(name: "Indian"),
///         Ocean(name: "Southern"),
///         Ocean(name: "Arctic")
///     ]
///
///     var body: some View {
///         List(oceans) {
///             Text($0.name)
///         }
///     }
///
/// ![A vertical list with five text views, each with the name of an
/// ocean.](List-2-iOS)
///
/// ### Supporting selection in lists
///
/// To make members of a list selectable, provide a binding to a selection
/// variable. Binding to a single instance of the list data's `Identifiable.ID`
/// type creates a single-selection list. Binding to a
/// <doc://com.apple.documentation/documentation/Swift/Set> creates a list that
/// supports multiple selections. The following example shows how to add
/// multiselect to the previous example:
///
///     struct Ocean: Identifiable, Hashable {
///         let name: String
///         let id = UUID()
///     }
///
///     private var oceans = [
///         Ocean(name: "Pacific"),
///         Ocean(name: "Atlantic"),
///         Ocean(name: "Indian"),
///         Ocean(name: "Southern"),
///         Ocean(name: "Arctic")
///     ]
///
///     @State private var multiSelection = Set<UUID>()
///
///     var body: some View {
///         NavigationView {
///             List(oceans, selection: $multiSelection) {
///                 Text($0.name)
///             }
///             .navigationTitle("Oceans")
///             .toolbar { EditButton() }
///         }
///         Text("\(multiSelection.count) selections")
///     }
///
/// When people make a single selection by tapping or clicking, the selected
/// cell changes its appearance to indicate the selection. To enable multiple
/// selections with tap gestures, put the list into edit mode by either
/// modifying the ``EnvironmentValues/editMode`` value, or adding an
/// ``EditButton`` to your app's interface. When you put the list into edit
/// mode, the list shows a circle next to each list item. The circle contains
/// a checkmark when the user selects the associated item. The example above
/// uses an Edit button, which changes its title to Done while in edit mode:
///
/// ![A navigation view with the title Oceans and a vertical list that contains
/// five text views, each with the name of an ocean. The second and third items
/// are highlighted to indicate that they are selected. At the bottom, a text
/// view reads 2 selections.](List-3-iOS)
///
/// People can make multiple selections without needing to enter edit mode on
/// devices that have a keyboard and mouse or trackpad, like Mac and iPad.
///
/// ### Refreshing the list content
///
/// To make the content of the list refreshable using the standard refresh
/// control, use the ``View/refreshable(action:)`` modifier.
///
/// The following example shows how to add a standard refresh control to a list.
/// When the user drags the top of the list downward, SwiftUI reveals the refresh
/// control and executes the specified action. Use an `await` expression
/// inside the `action` closure to refresh your data. The refresh indicator remains
/// visible for the duration of the awaited operation.
///
///     struct Ocean: Identifiable, Hashable {
///          let name: String
///          let id = UUID()
///          let stats: [String: String]
///      }
///
///      class OceanStore: ObservableObject {
///          @Published var oceans = [Ocean]()
///          func loadStats() async {}
///      }
///
///      @EnvironmentObject var store: OceanStore
///
///      var body: some View {
///          NavigationView {
///              List(store.oceans) { ocean in
///                  HStack {
///                      Text(ocean.name)
///                      StatsSummary(stats: ocean.stats) // A custom view for showing statistics.
///                  }
///              }
///              .refreshable {
///                  await store.loadStats()
///              }
///              .navigationTitle("Oceans")
///          }
///      }
///
/// ### Supporting multidimensional lists
///
/// To create two-dimensional lists, group items inside ``Section`` instances.
/// The following example creates sections named after the world's oceans,
/// each of which has ``Text`` views named for major seas attached to those
/// oceans. The example also allows for selection of a single list item,
/// identified by the `id` of the example's `Sea` type.
///
///     struct ContentView: View {
///         struct Sea: Hashable, Identifiable {
///             let name: String
///             let id = UUID()
///         }
///
///         struct OceanRegion: Identifiable {
///             let name: String
///             let seas: [Sea]
///             let id = UUID()
///         }
///
///         private let oceanRegions: [OceanRegion] = [
///             OceanRegion(name: "Pacific",
///                         seas: [Sea(name: "Australasian Mediterranean"),
///                                Sea(name: "Philippine"),
///                                Sea(name: "Coral"),
///                                Sea(name: "South China")]),
///             OceanRegion(name: "Atlantic",
///                         seas: [Sea(name: "American Mediterranean"),
///                                Sea(name: "Sargasso"),
///                                Sea(name: "Caribbean")]),
///             OceanRegion(name: "Indian",
///                         seas: [Sea(name: "Bay of Bengal")]),
///             OceanRegion(name: "Southern",
///                         seas: [Sea(name: "Weddell")]),
///             OceanRegion(name: "Arctic",
///                         seas: [Sea(name: "Greenland")])
///         ]
///
///         @State private var singleSelection: UUID?
///
///         var body: some View {
///             NavigationView {
///                 List(selection: $singleSelection) {
///                     ForEach(oceanRegions) { region in
///                         Section(header: Text("Major \(region.name) Ocean Seas")) {
///                             ForEach(region.seas) { sea in
///                                 Text(sea.name)
///                             }
///                         }
///                     }
///                 }
///                 .navigationTitle("Oceans and Seas")
///             }
///         }
///     }
///
/// Because this example uses single selection, people can make selections
/// outside of edit mode on all platforms.
///
/// ![A vertical list split into sections titled Major Pacific Ocean Seas,
/// Major Atlantic Ocean Seas, and so on. Each section has a different number of
/// rows, with the names of various seas. Within the Major Atlantic Ocean
/// Seas section, the row Sargasso is selected.](List-4-iOS)
///
/// > Note: In iOS 15, iPadOS 15, and tvOS 15 and earlier, lists support
///   selection only in edit mode, even for single selections.
///
/// ### Creating hierarchical lists
///
/// You can also create a hierarchical list of arbitrary depth by providing
/// tree-structured data and a `children` parameter that provides a key path to
/// get the child nodes at any level. The following example uses a deeply-nested
/// collection of a custom `FileItem` type to simulate the contents of a
/// file system. The list created from this data uses collapsing cells to allow
/// the user to navigate the tree structure.
///
///     struct ContentView: View {
///         struct FileItem: Hashable, Identifiable, CustomStringConvertible {
///             var id: Self { self }
///             var name: String
///             var children: [FileItem]? = nil
///             var description: String {
///                 switch children {
///                 case nil:
///                     return "📄 \(name)"
///                 case .some(let children):
///                     return children.isEmpty ? "📂 \(name)" : "📁 \(name)"
///                 }
///             }
///         }
///         let fileHierarchyData: [FileItem] = [
///           FileItem(name: "users", children:
///             [FileItem(name: "user1234", children:
///               [FileItem(name: "Photos", children:
///                 [FileItem(name: "photo001.jpg"),
///                  FileItem(name: "photo002.jpg")]),
///                FileItem(name: "Movies", children:
///                  [FileItem(name: "movie001.mp4")]),
///                   FileItem(name: "Documents", children: [])
///               ]),
///              FileItem(name: "newuser", children:
///                [FileItem(name: "Documents", children: [])
///                ])
///             ]),
///             FileItem(name: "private", children: nil)
///         ]
///         var body: some View {
///             List(fileHierarchyData, children: \.children) { item in
///                 Text(item.description)
///             }
///         }
///     }
///
/// ![A list providing an expanded view of a tree structure. Some rows have a
/// chevron on the right to indicate that they have child rows. The chevron
/// points right when the row's child rows are hidden and points down when they
/// are visible. Row content that is slightly indented from the content in the
/// previous row indicates that the row is a child of the row above. The first
/// three rows, titled users, user1234, and Photos, have downward facing
/// chevrons and are progressively indented. The next two rows, indented
/// together from Photos and titled photo001.jpg and photo002.jpg, have no
/// chevron. The next two rows, titled Movies and Documents have right facing
/// chevrons and align with the Photos row. The next row, titled newuser, has a
/// right facing chevron and is aligned with user1234. The last row is titled
/// private, has no chevron, and is aligned with users.](List-5-iOS)
///
/// ### Styling lists
///
/// SwiftUI chooses a display style for a list based on the platform and the
/// view type in which it appears. Use the ``View/listStyle(_:)`` modifier to
/// apply a different ``ListStyle`` to all lists within a view. For example,
/// adding `.listStyle(.plain)` to the example shown in the
/// "Creating Multidimensional Lists" topic applies the
/// ``ListStyle/plain`` style, the following screenshot shows:
///
/// ![A vertical list split into sections titled Major Pacific Ocean Seas,
/// Major Atlantic Ocean Seas, etc. Each section has a different number of
/// rows, with the names of various seas. Within the Major Atlantic Ocean
/// Seas section, the row Sargasso is selected.](List-6-iOS)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@MainActor public struct List<SelectionValue, Content> : View where SelectionValue : Hashable, Content : View {
/// Creates a list with the given content that supports selecting multiple
/// rows.
///
/// - Parameters:
///   - selection: A binding to a set that identifies selected rows.
///   - content: The content of the list.
@available(watchOS, unavailable)
@MainActor public init(selection: Binding<Set<SelectionValue>>?, @ViewBuilder content: () -> Content)
/// Creates a list with the given content that supports selecting a single
/// row.
///
/// - Parameters:
///   - selection: A binding to a selected row.
///   - content: The content of the list.
@available(watchOS 10.0, *)
@MainActor public init(selection: Binding<SelectionValue?>?, @ViewBuilder content: () -> Content)
/// The content of the list.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension List {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, optionally allowing users to select
/// multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Data, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that computes its rows on demand from an
/// underlying collection of identifiable data, optionally allowing users to
/// select multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data, optionally allowing users to select
/// multiple rows.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data, optionally allowing users to
/// select multiple rows.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a list that computes its views on demand over a constant range,
/// optionally allowing users to select multiple rows.
///
/// This instance only reads the initial value of `data` and doesn't need to
/// identify views across updates. To compute views on demand over a dynamic
/// range, use ``List/init(_:id:selection:rowContent:)-9a28m``.
///
/// - Parameters:
///   - data: A constant range of data to populate the list.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<RowContent>(_ data: Range<Int>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, HStack<RowContent>>, RowContent : View
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, optionally allowing users to select a
/// single row.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS 10.0, *)
@MainActor public init<Data, RowContent>(_ data: Data, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that computes its rows on demand from an
/// underlying collection of identifiable data, optionally allowing users to
/// select a single row.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data, optionally allowing users to select a
/// single row.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS 10.0, *)
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data, optionally allowing users to
/// select a single row.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a list that computes its views on demand over a constant range,
/// optionally allowing users to select a single row.
///
/// This instance only reads the initial value of `data` and doesn't need to
/// identify views across updates. To compute views on demand over a dynamic
/// range, use ``List/init(_:id:selection:rowContent:)-2r2u9``.
///
/// - Parameters:
///   - data: A constant range of data to populate the list.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<RowContent>(_ data: Range<Int>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, RowContent>, RowContent : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension List where SelectionValue == Never {
/// Creates a list with the given content.
///
/// - Parameter content: The content of the list.
@MainActor public init(@ViewBuilder content: () -> Content)
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data.
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Data, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that computes its rows on demand from an
/// underlying collection of identifiable data.
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a list that computes its views on demand over a constant range.
///
/// This instance only reads the initial value of `data` and doesn't need to
/// identify views across updates. To compute views on demand over a dynamic
/// range, use ``List/init(_:id:rowContent:)-4s0aj``.
///
/// - Parameters:
///   - data: A constant range of data to populate the list.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<RowContent>(_ data: Range<Int>, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, RowContent>, RowContent : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension List {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, optionally allowing users to select
/// multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data, optionally allowing users to select
/// multiple rows.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, optionally allowing users to select a
/// single row.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data, optionally allowing users to select a
/// single row.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension List where SelectionValue == Never {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data.
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that identifies its rows based on a key path to the
/// identifier of the underlying data.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension List {
/// Creates a hierarchical list that computes its rows on demand from a
/// binding to an underlying collection of identifiable data, optionally
/// allowing users to select multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data, optionally allowing users to
/// select multiple rows.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View
/// Creates a hierarchical list that computes its rows on demand from a
/// binding to an underlying collection of identifiable data, optionally
/// allowing users to select a single row.
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data, optionally allowing users to
/// select a single row.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension List where SelectionValue == Never {
/// Creates a hierarchical list that computes its rows on demand from a
/// binding to an underlying collection of identifiable data.
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, children: WritableKeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
/// Creates a hierarchical list that identifies its rows based on a key path
/// to the identifier of the underlying data.
///
/// - Parameters:
///   - data: The data for populating the list.
///   - id: The key path to the data model's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes a node capable
///     of having children that is currently childless, such as an empty
///     directory in a file system. On the other hand, if the property at the
///     key path is `nil`, then `data` is treated as a leaf node in the tree,
///     like a regular file in a file system.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, children: WritableKeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension List {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable, allows to edit the collection, and
/// optionally allows users to select multiple rows.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection, and select multiple elements.
///
///     List(
///         $foods,
///         editActions: [.delete, .move],
///         selection: $selectedFoods
///     ) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: The identifiable data for computing and to be edited by
///     the list.
///   - editActions: The edit actions that are synthesized on `data`.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, editActions: EditActions<Data>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, Data.Element.ID>, Data.Element.ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable, allows to edit the collection, and
/// optionally allows users to select multiple rows.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection, and select multiple elements.
///
///     List(
///         $foods,
///         editActions: [.delete, .move],
///         selection: $selectedFoods
///     ) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: The identifiable data for computing and to be edited by
///     the list.
///   - id: The key path to the data model's identifier.
///   - editActions: The edit actions that are synthesized on `data`.
///   - selection: A binding to a set that identifies selected rows.
///   - rowContent: A view builder that creates the view for a single row of
///
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, editActions: EditActions<Data>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, ID>, ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension List {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, allows to edit the collection, and
/// optionally allowing users to select a single row.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection, and select a single elements.
///
///     List(
///         $foods,
///         editActions: [.delete, .move],
///         selection: $selectedFood
///     ) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - editActions: The edit actions that are synthesized on `data`.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, editActions: EditActions<Data>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, Data.Element.ID>, Data.Element.ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data, allows to edit the collection, and
/// optionally allowing users to select a single row.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection, and select a single elements.
///
///     List(
///         $foods,
///         editActions: [.delete, .move],
///         selection: $selectedFood
///     ) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: The identifiable data for computing the list.
///   - id: The key path to the data model's identifier.
///   - editActions: The edit actions that are synthesized on `data`.
///   - selection: A binding to a selected value.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@available(watchOS, unavailable)
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, editActions: EditActions<Data>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, ID>, ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension List where SelectionValue == Never {
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data and allows to edit the collection.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection.
///
///     List($foods, editActions: [.delete, .move]) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - editActions: The edit actions that are synthesized on `data`.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, RowContent>(_ data: Binding<Data>, editActions: EditActions<Data>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, Data.Element.ID>, Data.Element.ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable
/// Creates a list that computes its rows on demand from an underlying
/// collection of identifiable data and allows to edit the collection.
///
/// The following example creates a list to display a collection of favorite
/// foods allowing the user to delete or move elements from the
/// collection.
///
///     List($foods, editActions: [.delete, .move]) { $food in
///        HStack {
///            Text(food.name)
///            Toggle("Favorite", isOn: $food.isFavorite)
///        }
///     }
///
/// Use ``View/deleteDisabled(_:)`` and ``View/moveDisabled(_:)``
/// to disable respectively delete or move actions on a per-row basis.
///
/// Explicit ``DynamicViewContent.onDelete(perform:)``,
/// ``DynamicViewContent.onMove(perform:)``, or
/// ``View.swipeActions(edge:allowsFullSwipe:content:)``
/// modifiers will override any synthesized action
///
/// - Parameters:
///   - data: A collection of identifiable data for computing the list.
///   - id: The key path to the data model's identifier.
///   - editActions: The edit actions that are synthesized on `data`.
///   - rowContent: A view builder that creates the view for a single row of
///     the list.
@MainActor public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, editActions: EditActions<Data>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, ID>, ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
}
/// The configuration of a tint effect applied to content within a List.
///
/// - See Also: `View.listItemTint(_:)`
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ListItemTint : Sendable {
/// An explicit tint color.
///
/// This tint effect is fixed and not overridable by other
/// system effects.
public static func fixed(_ tint: Color) -> ListItemTint
/// An explicit tint color that is overridable.
///
/// This tint effect is overridable by system effects, for
/// example when the system has a custom user accent
/// color on macOS.
public static func preferred(_ tint: Color) -> ListItemTint
/// A standard grayscale tint effect.
///
/// Monochrome tints are not overridable.
public static let monochrome: ListItemTint
}
/// The spacing options between two adjacent sections in a list.
@available(iOS 17.0, watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public struct ListSectionSpacing : Sendable {
/// The default spacing between sections
public static let `default`: ListSectionSpacing
/// Compact spacing between sections
public static let compact: ListSectionSpacing
/// Creates a custom spacing value.
///
/// - Parameter spacing: the amount of spacing to use.
public static func custom(_ spacing: CGFloat) -> ListSectionSpacing
}
/// A protocol that describes the behavior and appearance of a list.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ListStyle {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ListStyle where Self == DefaultListStyle {
/// The list style that describes a platform's default behavior and
/// appearance for a list.
public static var automatic: DefaultListStyle { get }
}
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ListStyle where Self == SidebarListStyle {
/// The list style that describes the behavior and appearance of a
/// sidebar list.
///
/// On macOS and iOS, the sidebar list style displays disclosure indicators in
/// the section headers that allow the user to collapse and expand sections.
public static var sidebar: SidebarListStyle { get }
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ListStyle where Self == InsetListStyle {
/// The list style that describes the behavior and appearance of an inset
/// list.
public static var inset: InsetListStyle { get }
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension ListStyle where Self == GroupedListStyle {
/// The list style that describes the behavior and appearance of a grouped
/// list.
///
/// On iOS, the grouped list style displays a larger header and footer than
/// the ``ListStyle/plain`` style, which visually distances the members of
/// different sections.
public static var grouped: GroupedListStyle { get }
}
@available(iOS 14.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ListStyle where Self == InsetGroupedListStyle {
/// The list style that describes the behavior and appearance of an inset
/// grouped list.
///
/// On iOS, the inset grouped list style displays a continuous background color
/// that extends from the section header, around both sides of list items in the
/// section, and down to the section footer. This visually groups the items
/// to a greater degree than either the ``ListStyle/inset`` or
/// ``ListStyle/grouped`` styles do.
public static var insetGrouped: InsetGroupedListStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ListStyle where Self == PlainListStyle {
/// The list style that describes the behavior and appearance of a plain
/// list.
public static var plain: PlainListStyle { get }
}
/// The local coordinate space of the current view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct LocalCoordinateSpace : CoordinateSpaceProtocol {
public init()
/// The resolved coordinate space.
public var coordinateSpace: CoordinateSpace { get }
}
/// The key used to look up an entry in a strings file or strings dictionary
/// file.
///
/// Initializers for several SwiftUI types -- such as ``Text``, ``Toggle``,
/// ``Picker`` and others --  implicitly look up a localized string when you
/// provide a string literal. When you use the initializer `Text("Hello")`,
/// SwiftUI creates a `LocalizedStringKey` for you and uses that to look up a
/// localization of the `Hello` string. This works because `LocalizedStringKey`
/// conforms to
/// <doc://com.apple.documentation/documentation/Swift/ExpressibleByStringLiteral>.
///
/// Types whose initializers take a `LocalizedStringKey` usually have
/// a corresponding initializer that accepts a parameter that conforms to
/// <doc://com.apple.documentation/documentation/Swift/StringProtocol>. Passing
/// a `String` variable to these initializers avoids localization, which is
/// usually appropriate when the variable contains a user-provided value.
///
/// As a general rule, use a string literal argument when you want
/// localization, and a string variable argument when you don't. In the case
/// where you want to localize the value of a string variable, use the string to
/// create a new `LocalizedStringKey` instance.
///
/// The following example shows how to create ``Text`` instances both
/// with and without localization. The title parameter provided to the
/// ``Section`` is a literal string, so SwiftUI creates a
/// `LocalizedStringKey` for it. However, the string entries in the
/// `messageStore.today` array are `String` variables, so the ``Text`` views
/// in the list use the string values verbatim.
///
///     List {
///         Section(header: Text("Today")) {
///             ForEach(messageStore.today) { message in
///                 Text(message.title)
///             }
///         }
///     }
///
/// If the app is localized into Japanese with the following
/// translation of its `Localizable.strings` file:
///
/// ```other
/// "Today" = "今日";
/// ```
///
/// When run in Japanese, the example produces a
/// list like the following, localizing "Today" for the section header, but not
/// the list items.
///
/// ![A list with a single section header displayed in Japanese.
/// The items in the list are all in English: New for Monday, Account update,
/// and Server
/// maintenance.](SwiftUI-LocalizedStringKey-Today-List-Japanese.png)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct LocalizedStringKey : Equatable, ExpressibleByStringInterpolation {
/// Creates a localized string key from the given string value.
///
/// - Parameter value: The string to use as a localization key.
public init(_ value: String)
/// Creates a localized string key from the given string literal.
///
/// - Parameter value: The string literal to use as a localization key.
public init(stringLiteral value: String)
/// Creates a localized string key from the given string interpolation.
///
/// To create a localized string key from a string interpolation, use
/// the `\()` string interpolation syntax. Swift matches the parameter
/// types in the expression to one of the `appendInterpolation` methods
/// in ``LocalizedStringKey/StringInterpolation``. The interpolated
/// types can include numeric values, Foundation types, and SwiftUI
/// ``Text`` and ``Image`` instances.
///
/// The following example uses a string interpolation with two arguments:
/// an unlabeled
/// <doc://com.apple.documentation/documentation/Foundation/Date>
/// and a ``Text/DateStyle`` labeled `style`. The compiler maps these to the
/// method
/// ``LocalizedStringKey/StringInterpolation/appendInterpolation(_:style:)``
/// as it builds the string that it creates the
/// ``LocalizedStringKey`` with.
///
///     let key = LocalizedStringKey("Date is \(company.foundedDate, style: .offset)")
///     let text = Text(key) // Text contains "Date is +45 years"
///
/// You can write this example more concisely, implicitly creating a
/// ``LocalizedStringKey`` as the parameter to the ``Text``
/// initializer:
///
///     let text = Text("Date is \(company.foundedDate, style: .offset)")
///
/// - Parameter stringInterpolation: The string interpolation to use as the
///   localization key.
public init(stringInterpolation: LocalizedStringKey.StringInterpolation)
/// Represents the contents of a string literal with interpolations
/// while it’s being built, for use in creating a localized string key.
public struct StringInterpolation : StringInterpolationProtocol {
/// Creates an empty instance ready to be filled with string literal content.
///
/// Don't call this initializer directly. Instead, initialize a variable or
/// constant using a string literal with interpolated expressions.
///
/// Swift passes this initializer a pair of arguments specifying the size of
/// the literal segments and the number of interpolated segments. Use this
/// information to estimate the amount of storage you will need.
///
/// - Parameter literalCapacity: The approximate size of all literal segments
///   combined. This is meant to be passed to `String.reserveCapacity(_:)`;
///   it may be slightly larger or smaller than the sum of the counts of each
///   literal segment.
/// - Parameter interpolationCount: The number of interpolations which will be
///   appended. Use this value to estimate how much additional capacity will
///   be needed for the interpolated segments.
public init(literalCapacity: Int, interpolationCount: Int)
/// Appends a literal string.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameter literal: The literal string to append.
public mutating func appendLiteral(_ literal: String)
/// Appends a literal string segment to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameter string: The literal string to append.
public mutating func appendInterpolation(_ string: String)
/// Appends an optionally-formatted instance of a Foundation type
/// to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - subject: The Foundation object to append.
///   - formatter: A formatter to convert `subject` to a string
///     representation.
public mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : ReferenceConvertible
/// Appends an optionally-formatted instance of an Objective-C subclass
/// to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// The following example shows how to use a
/// <doc://com.apple.documentation/documentation/Foundation/Measurement>
/// value and a
/// <doc://com.apple.documentation/documentation/Foundation/MeasurementFormatter>
/// to create a ``LocalizedStringKey`` that uses the formatter
/// style
/// <doc://com.apple.documentation/documentation/foundation/Formatter/UnitStyle/long>
/// when generating the measurement's string representation. Rather than
/// calling `appendInterpolation(_:formatter)` directly, the code
/// gets the formatting behavior implicitly by using the `\()`
/// string interpolation syntax.
///
///     let siResistance = Measurement(value: 640, unit: UnitElectricResistance.ohms)
///     let formatter = MeasurementFormatter()
///     formatter.unitStyle = .long
///     let key = LocalizedStringKey ("Resistance: \(siResistance, formatter: formatter)")
///     let text1 = Text(key) // Text contains "Resistance: 640 ohms"
///
/// - Parameters:
///   - subject: An <doc://com.apple.documentation/documentation/objectivec/NSObject>
///     to append.
///   - formatter: A formatter to convert `subject` to a string
///     representation.
public mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : NSObject
/// Appends the formatted representation  of a nonstring type
/// supported by a corresponding format style.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// The following example shows how to use a string interpolation to
/// format a
/// <doc://com.apple.documentation/documentation/Foundation/Date>
/// with a
/// <doc://com.apple.documentation/documentation/Foundation/Date/FormatStyle> and
/// append it to static text. The resulting interpolation implicitly
/// creates a ``LocalizedStringKey``, which a ``Text`` uses to provide
/// its content.
///
///     Text("The time is \(myDate, format: Date.FormatStyle(date: .omitted, time:.complete))")
///
/// - Parameters:
///   - input: The instance to format and append.
///   - format: A format style to use when converting `input` into a string
///   representation.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public mutating func appendInterpolation<F>(_ input: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String
/// Appends a type, convertible to a string by using a default format
/// specifier, to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - value: A primitive type to append, such as
///     <doc://com.apple.documentation/documentation/swift/Int>,
///     <doc://com.apple.documentation/documentation/swift/UInt32>, or
///     <doc://com.apple.documentation/documentation/swift/Double>.
public mutating func appendInterpolation<T>(_ value: T) where T : _FormatSpecifiable
/// Appends a type, convertible to a string with a format specifier,
/// to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - value: The value to append.
///   - specifier: A format specifier to convert `subject` to a string
///     representation, like `%f` for a
///     <doc://com.apple.documentation/documentation/swift/Double>, or
///     `%x` to create a hexidecimal representation of a
///     <doc://com.apple.documentation/documentation/swift/UInt32>. For a
///     list of available specifier strings, see
///     [String Format Specifers](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265).
public mutating func appendInterpolation<T>(_ value: T, specifier: String) where T : _FormatSpecifiable
/// Appends the string displayed by a text view to a string
/// interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - value: A ``Text`` instance to append.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public mutating func appendInterpolation(_ text: Text)
/// Appends an attributed string to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// The following example shows how to use a string interpolation to
/// format an
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString>
/// and append it to static text. The resulting interpolation implicitly
/// creates a ``LocalizedStringKey``, which a ``Text`` view uses to provide
/// its content.
///
///     struct ContentView: View {
///
///         var nextDate: AttributedString {
///             var result = Calendar.current
///                 .nextWeekend(startingAfter: Date.now)!
///                 .start
///                 .formatted(
///                     .dateTime
///                     .month(.wide)
///                     .day()
///                     .attributed
///                 )
///             result.backgroundColor = .green
///             result.foregroundColor = .white
///             return result
///         }
///
///         var body: some View {
///             Text("Our next catch-up is on \(nextDate)!")
///         }
///     }
///
/// For this example, assume that the app runs on a device set to a
/// Russian locale, and has the following entry in a Russian-localized
/// `Localizable.strings` file:
///
///     "Our next catch-up is on %@!" = "Наша следующая встреча состоится %@!";
///
/// The attributed string `nextDate` replaces the format specifier
/// `%@`,  maintaining its color and date-formatting attributes, when
/// the ``Text`` view renders its contents:
///
/// ![A text view with Russian text, ending with a date that uses white
/// text on a green
/// background.](LocalizedStringKey-AttributedString-Russian)
///
/// - Parameter attributedString: The attributed string to append.
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
public mutating func appendInterpolation(_ attributedString: AttributedString)
/// The type that should be used for literal segments.
public typealias StringLiteralType = String
}
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: LocalizedStringKey, b: LocalizedStringKey) -> Bool
/// A type that represents an extended grapheme cluster literal.
///
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`,
/// `String`, and `StaticString`.
public typealias ExtendedGraphemeClusterLiteralType = String
/// A type that represents a string literal.
///
/// Valid types for `StringLiteralType` are `String` and `StaticString`.
public typealias StringLiteralType = String
/// A type that represents a Unicode scalar literal.
///
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`,
/// `Character`, `String`, and `StaticString`.
public typealias UnicodeScalarLiteralType = String
}
extension LocalizedStringKey.StringInterpolation {
/// Appends the localized string resource to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - value: The localized string resource to append.
@available(iOS 16.0, macOS 13, tvOS 16.0, watchOS 9.0, *)
public mutating func appendInterpolation(_ resource: LocalizedStringResource)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LocalizedStringKey.StringInterpolation {
/// Appends an image to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameter image: The image to append.
public mutating func appendInterpolation(_ image: Image)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension LocalizedStringKey.StringInterpolation {
/// Appends a formatted date to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///   - date: The date to append.
///   - style: A predefined style to format the date with.
public mutating func appendInterpolation(_ date: Date, style: Text.DateStyle)
/// Appends a date range to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameter dates: The closed range of dates to append.
public mutating func appendInterpolation(_ dates: ClosedRange<Date>)
/// Appends a date interval to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameter interval: The date interval to append.
public mutating func appendInterpolation(_ interval: DateInterval)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension LocalizedStringKey.StringInterpolation {
/// Appends a timer interval to a string interpolation.
///
/// Don't call this method directly; it's used by the compiler when
/// interpreting string interpolations.
///
/// - Parameters:
///     - timerInterval: The interval between where to run the timer.
///     - pauseTime: If present, the date at which to pause the timer.
///         The default is `nil` which indicates to never pause.
///     - countsDown: Whether to count up or down. The default is `true`.
///     - showsHours: Whether to include an hours component if there are
///         more than 60 minutes left on the timer. The default is `true`.
public mutating func appendInterpolation(timerInterval: ClosedRange<Date>, pauseTime: Date? = nil, countsDown: Bool = true, showsHours: Bool = true)
}
/// A gesture that succeeds when the user performs a long press.
///
/// To recognize a long-press gesture on a view, create and configure the
/// gesture, then add it to the view using the ``View/gesture(_:including:)``
/// modifier.
///
/// Add a long-press gesture to a ``Circle`` to animate its color from blue to
/// red, and then change it to green when the gesture ends:
///
///     struct LongPressGestureView: View {
///         @GestureState private var isDetectingLongPress = false
///         @State private var completedLongPress = false
///
///         var longPress: some Gesture {
///             LongPressGesture(minimumDuration: 3)
///                 .updating($isDetectingLongPress) { currentState, gestureState,
///                         transaction in
///                     gestureState = currentState
///                     transaction.animation = Animation.easeIn(duration: 2.0)
///                 }
///                 .onEnded { finished in
///                     self.completedLongPress = finished
///                 }
///         }
///
///         var body: some View {
///             Circle()
///                 .fill(self.isDetectingLongPress ?
///                     Color.red :
///                     (self.completedLongPress ? Color.green : Color.blue))
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .gesture(longPress)
///         }
///     }
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *)
public struct LongPressGesture : Gesture {
/// The minimum duration of the long press that must elapse before the
/// gesture succeeds.
public var minimumDuration: Double
/// The maximum distance that the long press can move before the gesture
/// fails.
@available(tvOS, unavailable)
public var maximumDistance: CGFloat
/// Creates a long-press gesture with a minimum duration and a maximum
/// distance that the interaction can move before the gesture fails.
///
/// - Parameters:
///   - minimumDuration: The minimum duration of the long press that must
///     elapse before the gesture succeeds.
///   - maximumDistance: The maximum distance that the fingers or cursor
///     performing the long press can move before the gesture fails.
@available(tvOS, unavailable)
public init(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10)
/// The type representing the gesture's value.
public typealias Value = Bool
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "MagnifyGesture")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "MagnifyGesture")
@available(watchOS, unavailable)
@available(tvOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "MagnifyGesture")
public struct MagnificationGesture : Gesture {
/// The minimum required delta before the gesture starts.
public var minimumScaleDelta: CGFloat
/// Creates a magnification gesture with a given minimum delta for the
/// gesture to start.
///
/// - Parameter minimumScaleDelta: The minimum scale delta required before
///   the gesture starts.
public init(minimumScaleDelta: CGFloat = 0.01)
/// The type representing the gesture's value.
public typealias Value = CGFloat
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A gesture that recognizes a magnification motion and tracks the amount of
/// magnification.
///
/// A magnify gesture tracks how a magnification event sequence changes.
/// To recognize a magnify gesture on a view, create and configure the
/// gesture, and then add it to the view using the
/// ``View/gesture(_:including:)`` modifier.
///
/// Add a magnify gesture to a ``Circle`` that changes its size while the
/// user performs the gesture:
///
///     struct MagnifyGestureView: View {
///         @GestureState private var magnifyBy = 1.0
///
///         var magnification: some Gesture {
///             MagnifyGesture()
///                 .updating($magnifyBy) { value, gestureState, transaction in
///                     gestureState = value.magnification
///                 }
///         }
///
///         var body: some View {
///             Circle()
///                 .frame(width: 100, height: 100)
///                 .scaleEffect(magnifyBy)
///                 .gesture(magnification)
///         }
///     }
///
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct MagnifyGesture : Gesture {
/// The type representing the gesture's value.
public struct Value : Equatable, Sendable {
/// The time associated with the gesture's current event.
public var time: Date
/// The relative amount that the gesture has magnified by.
///
/// A value of 2.0 means that the user has interacted with the gesture
/// to increase the magnification by a factor of 2 more than before the
/// gesture.
public var magnification: CGFloat
/// The current magnification velocity.
public var velocity: CGFloat
/// The initial anchor point of the gesture in the modified view's
/// coordinate space.
public var startAnchor: UnitPoint
/// The initial center of the gesture in the modified view's coordinate
/// space.
public var startLocation: CGPoint
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: MagnifyGesture.Value, b: MagnifyGesture.Value) -> Bool
}
/// The minimum required delta before the gesture starts.
public var minimumScaleDelta: CGFloat
/// Creates a magnify gesture with a given minimum delta for the
/// gesture to start.
///
/// - Parameter minimumScaleDelta: The minimum scale delta required before
///   the gesture starts.
public init(minimumScaleDelta: CGFloat = 0.01)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A set of view properties that may be synchronized between views
/// using the `View.matchedGeometryEffect()` function.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public struct MatchedGeometryProperties : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt32)
/// The view's position, in window coordinates.
public static let position: MatchedGeometryProperties
/// The view's size, in local coordinates.
public static let size: MatchedGeometryProperties
/// Both the `position` and `size` properties.
public static let frame: MatchedGeometryProperties
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = MatchedGeometryProperties
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = MatchedGeometryProperties
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension MatchedGeometryProperties : Sendable {
}
/// A background material type.
///
/// You can apply a blur effect to a view that appears behind another view by
/// adding a material with the ``View/background(_:ignoresSafeAreaEdges:)``
/// modifier:
///
///     ZStack {
///         Color.teal
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background(.regularMaterial)
///     }
///
/// In the example above, the ``ZStack`` layers a ``Label`` on top of the color
/// ``ShapeStyle/teal``. The background modifier inserts the
/// regular material below the label, blurring the part of
/// the background that the label --- including its padding --- covers:
///
/// ![A screenshot of a label on a teal background, where the area behind
/// the label appears blurred.](Material-1)
///
/// A material isn't a view, but adding a material is like inserting a
/// translucent layer between the modified view and its background:
///
/// ![An illustration that shows a background layer below a material layer,
/// which in turn appears below a foreground layer.](Material-2)
///
/// The blurring effect provided by the material isn't simple opacity. Instead,
/// it uses a platform-specific blending that produces an effect that resembles
/// heavily frosted glass. You can see this more easily with a complex
/// background, like an image:
///
///     ZStack {
///         Image("chili_peppers")
///             .resizable()
///             .aspectRatio(contentMode: .fit)
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background(.regularMaterial)
///     }
///
/// ![A screenshot of a label on an image background, where the area behind
/// the label appears blurred.](Material-3)
///
/// For physical materials, the degree to which the background colors pass
/// through depends on the thickness. The effect also varies with light and
/// dark appearance:
///
/// ![An array of labels on a teal background. The first column, labeled light
/// appearance, shows a succession of labels on blurred backgrounds where the
/// blur increases from top to bottom, resulting in lighter and lighter blur.
/// The second column, labeled dark appearance, shows a similar succession of
/// labels, except that the blur gets darker from top to bottom. The rows are
/// labeled, from top to bottom: no material, ultra thin, thin, regular, thick,
/// and ultra thick.](Material-4)
///
/// If you need a material to have a particular shape, you can use the
/// ``View/background(_:in:fillStyle:)-20tq5`` modifier. For example, you can
/// create a material with rounded corners:
///
///     ZStack {
///         Color.teal
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background(.regularMaterial, in: RoundedRectangle(cornerRadius: 8))
///     }
///
/// ![A screenshot of a label on a teal background, where the area behind
/// the label appears blurred. The blurred area has rounded corners.](Material-5)
///
/// When you add a material, foreground elements exhibit vibrancy,
/// a context-specific blend of the foreground and background colors
/// that improves contrast. However using ``View/foregroundStyle(_:)``
/// to set a custom foreground style --- excluding the hierarchical styles,
/// like ``ShapeStyle/secondary-swift.type.property`` --- disables vibrancy.
///
/// > Note: A material blurs a background that's part of your app, but not
/// what appears behind your app on the screen.
/// For example, the content on the Home Screen doesn't affect the appearance
/// of a widget.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct Material : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 10.0, *)
extension Material {
/// A material that's somewhat translucent.
public static let regular: Material
/// A material that's more opaque than translucent.
public static let thick: Material
/// A material that's more translucent than opaque.
public static let thin: Material
/// A mostly translucent material.
public static let ultraThin: Material
/// A mostly opaque material.
public static let ultraThick: Material
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Material {
/// A material matching the style of system toolbars.
public static let bar: Material
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Material : ShapeStyle {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A control for presenting a menu of actions.
///
/// The following example presents a menu of three buttons and a submenu, which
/// contains three buttons of its own.
///
///     Menu("Actions") {
///         Button("Duplicate", action: duplicate)
///         Button("Rename", action: rename)
///         Button("Delete…", action: delete)
///         Menu("Copy") {
///             Button("Copy", action: copy)
///             Button("Copy Formatted", action: copyFormatted)
///             Button("Copy Library Path", action: copyPath)
///         }
///     }
///
/// You can create the menu's title with a ``LocalizedStringKey``, as seen in
/// the previous example, or with a view builder that creates multiple views,
/// such as an image and a text view:
///
///     Menu {
///         Button("Open in Preview", action: openInPreview)
///         Button("Save as PDF", action: saveAsPDF)
///     } label: {
///         Label("PDF", systemImage: "doc.fill")
///     }
///
/// ### Primary action
///
/// Menus can be created with a custom primary action. The primary action will
/// be performed when the user taps or clicks on the body of the control, and
/// the menu presentation will happen on a secondary gesture, such as on
/// long press or on click of the menu indicator. The following example creates
/// a menu that adds bookmarks, with advanced options that are presented in a
/// menu.
///
///     Menu {
///         Button(action: addCurrentTabToReadingList) {
///             Label("Add to Reading List", systemImage: "eyeglasses")
///         }
///         Button(action: bookmarkAll) {
///             Label("Add Bookmarks for All Tabs", systemImage: "book")
///         }
///         Button(action: show) {
///             Label("Show All Bookmarks", systemImage: "books.vertical")
///         }
///     } label: {
///         Label("Add Bookmark", systemImage: "book")
///     } primaryAction: {
///         addBookmark()
///     }
///
/// ### Styling menus
///
/// Use the ``View/menuStyle(_:)`` modifier to change the style of all menus
/// in a view. The following example shows how to apply a custom style:
///
///     Menu("Editing") {
///         Button("Set In Point", action: setInPoint)
///         Button("Set Out Point", action: setOutPoint)
///     }
///     .menuStyle(EditingControlsMenuStyle())
///
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct Menu<Label, Content> : View where Label : View, Content : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Menu {
/// Creates a menu with a custom label.
///
/// - Parameters:
///     - content: A group of menu items.
///     - label: A view describing the content of the menu.
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label)
/// Creates a menu that generates its label from a localized string key.
///
/// - Parameters:
///     - titleKey: The key for the link's localized title, which describes
///         the contents of the menu.
///     - content: A group of menu items.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) where Label == Text
/// Creates a menu that generates its label from a string.
///
/// To create the label with a localized string key, use
/// ``Menu/init(_:content:)-7v768`` instead.
///
/// - Parameters:
///     - title: A string that describes the contents of the menu.
///     - content: A group of menu items.
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where Label == Text, S : StringProtocol
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Menu {
/// Creates a menu with a custom primary action and custom label.
///
/// - Parameters:
///   - content: A group of menu items.
///   - label: A view describing the content of the menu.
///   - primaryAction: The action to perform on primary
///     interaction with the menu.
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label, primaryAction: @escaping () -> Void)
/// Creates a menu with a custom primary action that generates its label
/// from a localized string key.
///
/// - Parameters:
///   - titleKey: The key for the link's localized title, which describes
///     the contents of the menu.
///   - primaryAction: The action to perform on primary
///     interaction with the menu.
///   - content: A group of menu items.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void) where Label == Text
/// Creates a menu with a custom primary action that generates its label
/// from a string.
///
/// To create the label with a localized string key, use
/// `Menu(_:primaryAction:content:)` instead.
///
/// - Parameters:
///   - title: A string that describes the contents of the menu.
///   - primaryAction: The action to perform on primary
///     interaction with the menu.
///   - content: A group of menu items.
public init<S>(_ title: S, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void) where Label == Text, S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Menu where Label == Label<Text, Image> {
/// Creates a menu that generates its label from a localized string key
/// and system image.
///
/// - Parameters:
///   - titleKey: The key for the link's localized title, which describes
///     the contents of the menu.
///   - systemImage: The name of the image resource to lookup.
///   - content: A group of menu items.
public init(_ titleKey: LocalizedStringKey, systemImage: String, @ViewBuilder content: () -> Content)
/// Creates a menu that generates its label from a string and system image.
///
/// To create the label with a localized string key, use
/// ``Menu/init(_:content:)-7v768`` instead.
///
/// - Parameters:
///   - title: A string that describes the contents of the menu.
///   - systemImage: The name of the image resource to lookup.
///   - content: A group of menu items.
public init<S>(_ title: S, systemImage: String, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a menu with a custom primary action that generates its label
/// from a localized string key and system image.
///
/// - Parameters:
///   - titleKey: The key for the link's localized title, which describes
///     the contents of the menu.
///   - systemImage: The name of the image resource to lookup.
///   - primaryAction: The action to perform on primary
///     interaction with the menu.
///   - content: A group of menu items.
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public init(_ titleKey: LocalizedStringKey, systemImage: String, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Menu where Label == Label<Text, Image> {
/// Creates a menu that generates its label from a localized string key
/// and image resource.
///
/// - Parameters:
///   - titleKey: The key for the link's localized title, which describes
///     the contents of the menu.
///   - image: The name of the image resource to lookup.
///   - content: A group of menu items.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, @ViewBuilder content: () -> Content)
/// Creates a menu that generates its label from a string and
/// image resource.
///
/// To create the label with a localized string key, use
/// ``Menu/init(_:content:)-7v768`` instead.
///
/// - Parameters:
///   - title: A string that describes the contents of the menu.
///   - image: The name of the image resource to lookup.
///   - content: A group of menu items.
public init<S>(_ title: S, image: ImageResource, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a menu with a custom primary action that generates its label
/// from a localized string key.
///
/// - Parameters:
///   - titleKey: The key for the link's localized title, which describes
///     the contents of the menu.
///   - image: The name of the image resource to lookup.
///   - primaryAction: The action to perform on primary
///     interaction with the menu.
///   - content: A group of menu items.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void)
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Menu where Label == MenuStyleConfiguration.Label, Content == MenuStyleConfiguration.Content {
/// Creates a menu based on a style configuration.
///
/// Use this initializer within the ``MenuStyle/makeBody(configuration:)``
/// method of a ``MenuStyle`` instance to create an instance of the menu
/// being styled. This is useful for custom menu styles that modify the
/// current menu style.
///
/// For example, the following code creates a new, custom style that adds a
/// red border around the current menu style:
///
///     struct RedBorderMenuStyle: MenuStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Menu(configuration)
///                 .border(Color.red)
///         }
///     }
///
public init(_ configuration: MenuStyleConfiguration)
}
/// The set of menu dismissal behavior options.
///
/// Configure the menu dismissal behavior for a view hierarchy using the
/// ``View/menuActionDismissBehavior(_:)`` view modifier.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct MenuActionDismissBehavior : Equatable {
/// Use the a dismissal behavior that's appropriate for the given context.
///
/// In most cases, the default behavior is ``enabled``. There are some
/// cases, like ``Stepper``, that use ``disabled`` by default.
public static let automatic: MenuActionDismissBehavior
/// Always dismiss the presented menu after performing an action.
public static let enabled: MenuActionDismissBehavior
/// Never dismiss the presented menu after performing an action.
@available(tvOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public static let disabled: MenuActionDismissBehavior
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: MenuActionDismissBehavior, b: MenuActionDismissBehavior) -> Bool
}
/// A control group style that presents its content as a menu when the user
/// presses the control, or as a submenu when nested within a larger menu.
///
/// Use ``ControlGroupStyle/menu`` to construct this style.
@available(iOS 16.4, macOS 13.3, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct MenuControlGroupStyle : ControlGroupStyle {
/// Creates a menu control group style.
public init()
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@MainActor public func makeBody(configuration: MenuControlGroupStyle.Configuration) -> some View
/// A view representing the body of a control group.
public typealias Body = some View
}
/// The order in which a menu presents its content.
///
/// You can configure the preferred menu order using the
/// ``View/menuOrder(_:)`` view modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct MenuOrder : Equatable, Hashable, Sendable {
/// The ordering of the menu chosen by the system for the current context.
///
/// On iOS, this order resolves to ``fixed`` for menus
/// presented within scrollable content. Pickers that use the
/// ``PickerStyle/menu`` style also default to ``fixed`` order. In all
/// other cases, menus default to ``priority`` order.
///
/// On macOS, tvOS and watchOS, the `automatic` order always resolves to
/// ``fixed`` order.
public static let automatic: MenuOrder
/// Keep the first items closest to user's interaction point.
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static let priority: MenuOrder
/// Order items from top to bottom.
public static let fixed: MenuOrder
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: MenuOrder, b: MenuOrder) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A picker style that presents the options as a menu when the user presses a
/// button, or as a submenu when nested within a larger menu.
///
/// You can also use ``PickerStyle/menu`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct MenuPickerStyle : PickerStyle {
/// Creates a menu picker style.
public init()
}
/// A type that applies standard interaction behavior and a custom appearance
/// to all menus within a view hierarchy.
///
/// To configure the current menu style for a view hierarchy, use the
/// ``View/menuStyle(_:)`` modifier.
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public protocol MenuStyle {
/// A view that represents the body of a menu.
associatedtype Body : View
/// Creates a view that represents the body of a menu.
///
/// - Parameter configuration: The properties of the menu.
///
/// The system calls this method for each ``Menu`` instance in a view
/// hierarchy where this style is the current menu style.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a menu.
typealias Configuration = MenuStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension MenuStyle where Self == ButtonMenuStyle {
/// A menu style that displays a button that toggles the display of
/// the menu's contents when pressed.
///
/// On macOS, the button displays an arrow to indicate that it presents a
/// menu.
///
/// Pressing and then dragging into the contents activates the selected
/// action on release.
public static var button: ButtonMenuStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension MenuStyle where Self == DefaultMenuStyle {
/// The default menu style, based on the menu's context.
///
/// The default menu style can vary by platform. By default, macOS uses the
/// bordered button style.
///
/// If you create a menu inside a container, the style resolves to the
/// recommended style for menus inside that container for that specific
/// platform. For example, a menu nested within another menu will resolve to
/// a submenu:
///
///     Menu("Edit") {
///         Menu("Arrange") {
///             Button("Bring to Front", action: moveSelectionToFront)
///             Button("Send to Back", action: moveSelectionToBack)
///         }
///         Button("Delete", action: deleteSelection)
///     }
///
/// You can override a menu's style. To apply the default style to a menu,
/// or to a view that contains a menu, use the ``View/menuStyle(_:)``
/// modifier.
public static var automatic: DefaultMenuStyle { get }
}
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(tvOS, introduced: 17.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use .menuStyle(.button) and .buttonStyle(.borderless).")
extension MenuStyle where Self == BorderlessButtonMenuStyle {
/// A menu style that displays a borderless button that toggles the display of
/// the menu's contents when pressed.
///
/// On macOS, the button optionally displays an arrow indicating that it
/// presents a menu.
///
/// Pressing and then dragging into the contents triggers the chosen action on
/// release.
public static var borderlessButton: BorderlessButtonMenuStyle { get }
}
/// A configuration of a menu.
///
/// Use the ``Menu/init(_:)`` initializer of ``Menu`` to create an
/// instance using the current menu style, which you can modify to create a
/// custom style.
///
/// For example, the following code creates a new, custom style that adds a red
/// border to the current menu style:
///
///     struct RedBorderMenuStyle: MenuStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Menu(configuration)
///                 .border(Color.red)
///         }
///     }
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct MenuStyleConfiguration {
/// A type-erased label of a menu.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased content of a menu.
public struct Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
}
/// A value with a modifier applied to it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ModifiedContent<Content, Modifier> {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
/// The content that the modifier transforms into a new view or new
/// view modifier.
public var content: Content
/// The view modifier.
public var modifier: Modifier
/// A structure that the defines the content and modifier needed to produce
/// a new view or view modifier.
///
/// If `content` is a ``View`` and `modifier` is a ``ViewModifier``, the
/// result is a ``View``. If `content` and `modifier` are both view
/// modifiers, then the result is a new ``ViewModifier`` combining them.
///
/// - Parameters:
///     - content: The content that the modifier changes.
///     - modifier: The modifier to apply to the content.
@inlinable public init(content: Content, modifier: Modifier)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel(_ label: Text) -> ModifiedContent<Content, Modifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel(_ labelKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel<S>(_ label: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds an accessibility adjustable action to the view. Actions allow
/// assistive technologies, such as the VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how an adjustable action to navigate
/// through pages could be added to a view.
///
///     var body: some View {
///         PageControl()
///             .accessibilityAdjustableAction { direction in
///                 switch direction {
///                 case .increment:
///                     // Go to next page
///                 case .decrement:
///                     // Go to previous page
///                 }
///             }
///     }
///
public func accessibilityAdjustableAction(_ handler: @escaping (AccessibilityAdjustmentDirection) -> Void) -> ModifiedContent<Content, Modifier>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Sets an accessibility text content type.
///
/// Use this modifier to set the content type of this accessibility
/// element. Assistive technologies can use this property to choose
/// an appropriate way to output the text. For example, when
/// encountering a source coding context, VoiceOver could
/// choose to speak all punctuation.
///
/// The default content type ``AccessibilityTextContentType/plain``.
///
/// - Parameter value: The accessibility content type from the available
/// ``AccessibilityTextContentType`` options.
public func accessibilityTextContentType(_ textContentType: AccessibilityTextContentType) -> ModifiedContent<Content, Modifier>
/// Set the level of this heading.
///
/// Use this modifier to set the level of this heading in relation to other headings. The system speaks
///  the level number of levels ``AccessibilityHeadingLevel/h1``
///  through ``AccessibilityHeadingLevel/h6`` alongside the text.
///
/// The default heading level if you don’t use this modifier
/// is ``AccessibilityHeadingLevel/unspecified``.
///
/// - Parameter level: The heading level to associate with this element
///   from the available ``AccessibilityHeadingLevel`` levels.
public func accessibilityHeading(_ level: AccessibilityHeadingLevel) -> ModifiedContent<Content, Modifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent : Equatable where Content : Equatable, Modifier : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ModifiedContent<Content, Modifier>, b: ModifiedContent<Content, Modifier>) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent : View where Content : View, Modifier : ViewModifier {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: ModifiedContent<Content, Modifier>.Body { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent : ViewModifier where Content : ViewModifier, Modifier : ViewModifier {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue(_ valueDescription: Text) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue(_ valueKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier>
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue<S>(_ value: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol
}
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibility(label:),
/// you can provide the current volume setting, like "60%", using accessibility(value:).
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
public func accessibility(value: Text) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
///
/// > Note: On macOS, if the view does not have an action and it has been
///   made into a container with ``accessibilityElement(children: .contain)``,
///   this will be used to describe the container. For example, if the container is
///   for a graph, the hint could be "graph".
public func accessibilityHint(_ hint: Text) -> ModifiedContent<Content, Modifier>
/// Sets alternate input labels with which users identify a view.
///
/// If you don't specify any input labels, the user can still refer to the view using the accessibility
/// label that you add with the accessibilityLabel() modifier. Provide labels in descending order
/// of importance. Voice Control and Full Keyboard Access use the input labels.
public func accessibilityInputLabels(_ inputLabels: [Text]) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
public func accessibilityHint(_ hintKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier>
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
public func accessibilityHint<S>(_ hint: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   `accessibilityLabel()` modifier.
public func accessibilityInputLabels(_ inputLabelKeys: [LocalizedStringKey]) -> ModifiedContent<Content, Modifier>
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   `accessibilityLabel()` modifier.
public func accessibilityInputLabels<S>(_ inputLabels: [S]) -> ModifiedContent<Content, Modifier> where S : StringProtocol
}
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Specifies whether to hide this view from system accessibility features.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
public func accessibility(hidden: Bool) -> ModifiedContent<Content, Modifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
public func accessibility(label: Text) -> ModifiedContent<Content, Modifier>
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
public func accessibility(hint: Text) -> ModifiedContent<Content, Modifier>
/// Sets alternate input labels with which users identify a view.
///
/// If you don't specify any input labels, the user can still refer to the view using the accessibility
/// label that you add with the accessibilityLabel() modifier. Provide labels in descending order
/// of importance. Voice Control and Full Keyboard Access use the input labels.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
public func accessibility(inputLabels: [Text]) -> ModifiedContent<Content, Modifier>
/// Uses the specified string to identify the view.
///
/// Use this value for testing. It isn't visible to the user.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
public func accessibility(identifier: String) -> ModifiedContent<Content, Modifier>
@available(iOS, deprecated, introduced: 13.0)
@available(macOS, deprecated, introduced: 10.15)
@available(tvOS, deprecated, introduced: 13.0)
@available(watchOS, deprecated, introduced: 6)
@available(visionOS, introduced: 1.0, deprecated: 1.0)
public func accessibility(selectionIdentifier: AnyHashable) -> ModifiedContent<Content, Modifier>
/// Sets the sort priority order for this view's accessibility
/// element, relative to other elements at the same level.
///
/// Higher numbers are sorted first. The default sort priority is zero.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
public func accessibility(sortPriority: Double) -> ModifiedContent<Content, Modifier>
/// Specifies the point where activations occur in the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
public func accessibility(activationPoint: CGPoint) -> ModifiedContent<Content, Modifier>
/// Specifies the unit point where activations occur in the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
public func accessibility(activationPoint: UnitPoint) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Sets the sort priority order for this view's accessibility
/// element, relative to other elements at the same level.
///
/// Higher numbers are sorted first. The default sort priority is zero.
public func accessibilitySortPriority(_ sortPriority: Double) -> ModifiedContent<Content, Modifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent : DynamicViewContent where Content : DynamicViewContent, Modifier : ViewModifier {
/// The collection of underlying data.
public var data: Content.Data { get }
/// The type of the underlying collection of data.
public typealias Data = Content.Data
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds an accessibility scroll action to the view. Actions allow
/// assistive technologies, such as the VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how a scroll action to trigger
/// a refresh could be added to a view.
///
///     var body: some View {
///         ScrollView {
///             ContentView()
///         }
///         .accessibilityScrollAction { edge in
///             if edge == .top {
///                 // Refresh content
///             }
///         }
///     }
///
public func accessibilityScrollAction(_ handler: @escaping (Edge) -> Void) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent : Scene where Content : Scene, Modifier : _SceneModifier {
/// The content and behavior of the scene.
///
/// For any scene that you create, provide a computed `body` property that
/// defines the scene as a composition of other scenes. You can assemble a
/// scene from built-in scenes that SwiftUI provides, as well as other
/// scenes that you've defined.
///
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype``
/// associated type based on the contents of the `body` property.
@MainActor public var body: ModifiedContent<Content, Modifier>.Body { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Explicitly set whether this Accessibility element responds to user
/// interaction and would thus be interacted with by technologies such as
/// Switch Control, Voice Control or Full Keyboard Access.
///
/// If this is not set, the value is inferred from the traits of the
/// Accessibility element, the presence of Accessibility actions on the
/// element, or the presence of gestures on the element or containing views.
public func accessibilityRespondsToUserInteraction(_ respondsToUserInteraction: Bool = true) -> ModifiedContent<Content, Modifier>
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ModifiedContent : TableRowContent where Content : TableRowContent, Modifier : _TableRowContentModifier {
/// The type of value represented by this table row content.
public typealias TableRowValue = Content.TableRowValue
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// The composition of content that comprise the table row content.
public var tableRowBody: Never { get }
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ModifiedContent : DynamicTableRowContent where Content : DynamicTableRowContent, Modifier : _TableRowContentModifier {
/// The collection of underlying data.
public var data: Content.Data { get }
/// The type of the underlying collection of data.
public typealias Data = Content.Data
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Explicitly set whether this accessibility element is a direct touch
/// area. Direct touch areas passthrough touch events to the app rather
/// than being handled through an assistive technology, such as VoiceOver.
/// The modifier accepts an optional `AccessibilityDirectTouchOptions`
/// option set to customize the functionality of the direct touch area.
///
/// For example, this is how a direct touch area would allow a VoiceOver
/// user to interact with a view with a `rotationEffect` controlled by a
/// `RotationGesture`. The direct touch area would require a user to
/// activate the area before using the direct touch area.
///
///     var body: some View {
///         Rectangle()
///             .frame(width: 200, height: 200, alignment: .center)
///             .rotationEffect(angle)
///             .gesture(rotation)
///             .accessibilityDirectTouch(options: .requiresActivation)
///     }
///
public func accessibilityDirectTouch(_ isDirectTouchArea: Bool = true, options: AccessibilityDirectTouchOptions = []) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Specifies whether to hide this view from system accessibility features.
public func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Uses the string you specify to identify the view.
///
/// Use this value for testing. It isn't visible to the user.
public func accessibilityIdentifier(_ identifier: String) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds the given traits to the view.
public func accessibilityAddTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier>
/// Removes the given traits from this view.
public func accessibilityRemoveTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier>
}
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds the given traits to the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
public func accessibility(addTraits traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier>
/// Removes the given traits from this view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
public func accessibility(removeTraits traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ value: Text?, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter valueKey: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent<V>(_ key: AccessibilityCustomContentKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> where V : StringProtocol
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example: `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter label: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ label: Text, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example: `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter label: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent<V>(_ labelKey: LocalizedStringKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> where V : StringProtocol
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds an accessibility zoom action to the view. Actions allow
/// assistive technologies, such as VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how a zoom action is used to transform the scale
/// of a shape which has a `MagnificationGesture`.
///
///     var body: some View {
///         Circle()
///             .scaleEffect(magnifyBy)
///             .gesture(magnification)
///             .accessibilityLabel("Circle Magnifier")
///             .accessibilityZoomAction { action in
///                 switch action.direction {
///                 case .zoomIn:
///                     magnifyBy += 0.5
///                 case .zoomOut:
///                      magnifyBy -= 0.5
///                 }
///             }
///     }
///
public func accessibilityZoomAction(_ handler: @escaping (AccessibilityZoomGestureAction) -> Void) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// The activation point for an element is the location
/// assistive technologies use to initiate gestures.
///
/// Use this modifier to ensure that the activation point for a
/// small element remains accurate even if you present a larger
/// version of the element to VoiceOver.
///
/// If an activation point is not provided, an activation point
/// will be derrived from one of the accessibility elements
/// decendents or from the center of the accessibility frame.
public func accessibilityActivationPoint(_ activationPoint: CGPoint) -> ModifiedContent<Content, Modifier>
/// The activation point for an element is the location
/// assistive technologies use to initiate gestures.
///
/// Use this modifier to ensure that the activation point for a
/// small element remains accurate even if you present a larger
/// version of the element to VoiceOver.
///
/// If an activation point is not provided, an activation point
/// will be derrived from one of the accessibility elements
/// decendents or from the center of the accessibility frame.
public func accessibilityActivationPoint(_ activationPoint: UnitPoint) -> ModifiedContent<Content, Modifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a `.default` action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(_ actionKind: AccessibilityActionKind = .default, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier>
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: Text("New Message")) {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(named name: Text, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier {
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: "New Message") {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(named nameKey: LocalizedStringKey, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier>
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: "New Message") {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction<S>(named name: S, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier> where S : StringProtocol
}
/// A keyframe that immediately moves to the given value without interpolating.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct MoveKeyframe<Value> : KeyframeTrackContent where Value : Animatable {
/// Creates a new keyframe using the given value.
///
/// - Parameters:
///   - to: The value of the keyframe.
public init(_ to: Value)
public typealias Body = MoveKeyframe<Value>
}
/// Returns a transition that moves the view away, towards the specified
/// edge of the view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct MoveTransition : Transition {
/// The edge to move the view towards.
public var edge: Edge
/// Creates a transition that moves the view away, towards the specified
/// edge of the view.
public init(edge: Edge)
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: MoveTransition.Content, phase: TransitionPhase) -> some View
/// The type of view representing the body.
public typealias Body = some View
}
/// A control for picking multiple dates.
///
/// Use a `MultiDatePicker` when you want to provide a view that allows the
/// user to select multiple dates.
///
/// The following example creates a basic `MultiDatePicker`, which appears as a
/// calendar view representing the selected dates:
///
///     @State private var dates: Set<DateComponents> = []
///
///     var body: some View {
///         MultiDatePicker("Dates Available", selection: $dates)
///     }
///
/// You can limit the `MultiDatePicker` to specific ranges of dates
/// allowing selections only before or after a certain date or between two
/// dates. The following example shows a multi-date picker that only permits
/// selections within the 6th and (excluding) the 16th of December 2021
/// (in the `UTC` time zone):
///
///     @Environment(\.calendar) var calendar
///     @Environment(\.timeZone) var timeZone
///
///     var bounds: Range<Date> {
///         let start = calendar.date(from: DateComponents(
///             timeZone: timeZone, year: 2022, month: 6, day: 6))!
///         let end = calendar.date(from: DateComponents(
///             timeZone: timeZone, year: 2022, month: 6, day: 16))!
///         return start ..< end
///     }
///
///     @State private var dates: Set<DateComponents> = []
///
///     var body: some View {
///         MultiDatePicker("Dates Available", selection: $dates, in: bounds)
///     }
///
/// You can also specify an alternative locale, calendar and time zone through
/// environment values. This can be useful when using a ``PreviewProvider`` to
/// see how your multi-date picker behaves in environments that differ from
/// your own.
///
/// The following example shows a multi-date picker with a custom locale,
/// calendar and time zone:
///
///     struct ContentView_Previews: PreviewProvider {
///         static var previews: some View {
///             MultiDatePicker("Dates Available", selection: .constant([]))
///                 .environment(\.locale, Locale.init(identifier: "zh"))
///                 .environment(
///                     \.calendar, Calendar.init(identifier: .chinese))
///                 .environment(\.timeZone, TimeZone(abbreviation: "HKT")!)
///         }
///     }
///
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct MultiDatePicker<Label> : View where Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension MultiDatePicker {
/// Creates an instance that selects multiple dates with an unbounded
/// range.
///
/// - Parameters:
///   - selection: The date values being displayed and selected.
///   - label: A view that describes the use of the dates.
public init(selection: Binding<Set<DateComponents>>, @ViewBuilder label: () -> Label)
/// Creates an instance that selects multiple dates in a range.
///
/// - Parameters:
///   - selection: The date values being displayed and selected.
///   - bounds: The exclusive range of selectable dates.
///   - label: A view that describes the use of the dates.
public init(selection: Binding<Set<DateComponents>>, in bounds: Range<Date>, @ViewBuilder label: () -> Label)
/// Creates an instance that selects multiple dates on or after some
/// start date.
///
/// - Parameters:
///   - selection: The date values being displayed and selected.
///   - bounds: The open range from some selectable start date.
///   - label: A view that describes the use of the dates.
public init(selection: Binding<Set<DateComponents>>, in bounds: PartialRangeFrom<Date>, @ViewBuilder label: () -> Label)
/// Creates an instance that selects multiple dates before some end date.
///
/// - Parameters:
///   - selection: The date values being displayed and selected.
///   - bounds: The open range before some end date.
///   - label: A view that describes the use of the dates.
public init(selection: Binding<Set<DateComponents>>, in bounds: PartialRangeUpTo<Date>, @ViewBuilder label: () -> Label)
}
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension MultiDatePicker where Label == Text {
/// Creates an instance that selects multiple dates with an unbounded
/// range.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date values being displayed and selected.
public init(_ titleKey: LocalizedStringKey, selection: Binding<Set<DateComponents>>)
/// Creates an instance that selects multiple dates in a range.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The exclusive range of selectable dates.
public init(_ titleKey: LocalizedStringKey, selection: Binding<Set<DateComponents>>, in bounds: Range<Date>)
/// Creates an instance that selects multiple dates on or after some
/// start date.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The open range from some selectable start date.
public init(_ titleKey: LocalizedStringKey, selection: Binding<Set<DateComponents>>, in bounds: PartialRangeFrom<Date>)
/// Creates an instance that selects multiple dates before some end date.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The open range before some end date.
public init(_ titleKey: LocalizedStringKey, selection: Binding<Set<DateComponents>>, in bounds: PartialRangeUpTo<Date>)
}
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension MultiDatePicker where Label == Text {
/// Creates an instance that selects multiple dates with an unbounded
/// range.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date values being displayed and selected.
public init<S>(_ title: S, selection: Binding<Set<DateComponents>>) where S : StringProtocol
/// Creates an instance that selects multiple dates in a range.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The exclusive range of selectable dates.
public init<S>(_ title: S, selection: Binding<Set<DateComponents>>, in bounds: Range<Date>) where S : StringProtocol
/// Creates an instance that selects multiple dates on or after some
/// start date.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The open range from some selectable start date.
public init<S>(_ title: S, selection: Binding<Set<DateComponents>>, in bounds: PartialRangeFrom<Date>) where S : StringProtocol
/// Creates an instance that selects multiple dates before some end date.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - selection: The date values being displayed and selected.
///   - bounds: The open range before some end date.
public init<S>(_ title: S, selection: Binding<Set<DateComponents>>, in bounds: PartialRangeUpTo<Date>) where S : StringProtocol
}
/// A named coordinate space.
///
/// Use the `coordinateSpace(_:)` modifier to assign a name to the local
/// coordinate space of a  parent view. Child views can then refer to that
/// coordinate space using `.named(_:)`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct NamedCoordinateSpace : CoordinateSpaceProtocol, Equatable {
/// The resolved coordinate space.
public var coordinateSpace: CoordinateSpace { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: NamedCoordinateSpace, b: NamedCoordinateSpace) -> Bool
}
/// A dynamic property type that allows access to a namespace defined
/// by the persistent identity of the object containing the property
/// (e.g. a view).
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen @propertyWrapper public struct Namespace : DynamicProperty {
@inlinable public init()
public var wrappedValue: Namespace.ID { get }
/// A namespace defined by the persistent identity of an
/// `@Namespace` dynamic property.
@frozen public struct ID : Hashable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Namespace.ID, b: Namespace.ID) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Namespace : Sendable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Namespace.ID : Sendable {
}
/// A configuration for a navigation bar that represents a view at the top of a
/// navigation stack.
///
/// Use one of the ``TitleDisplayMode`` values to configure a navigation bar
/// title's display mode with the ``View/navigationBarTitleDisplayMode(_:)``
/// view modifier.
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
public struct NavigationBarItem : Sendable {
/// A style for displaying the title of a navigation bar.
///
/// Use one of these values with the
/// ``View/navigationBarTitleDisplayMode(_:)`` view modifier to configure
/// the title of a navigation bar.
public enum TitleDisplayMode : Sendable {
/// Inherit the display mode from the previous navigation item.
case automatic
/// Display the title within the standard bounds of the navigation bar.
case inline
/// Display a large title within an expanded navigation bar.
@available(watchOS 8.0, *)
@available(tvOS, unavailable)
case large
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: NavigationBarItem.TitleDisplayMode, b: NavigationBarItem.TitleDisplayMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension NavigationBarItem.TitleDisplayMode : Equatable {
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension NavigationBarItem.TitleDisplayMode : Hashable {
}
/// The navigation control group style.
///
/// You can also use ``ControlGroupStyle/navigation`` to construct this style.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct NavigationControlGroupStyle : ControlGroupStyle {
/// Creates a navigation control group style.
public init()
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@MainActor public func makeBody(configuration: NavigationControlGroupStyle.Configuration) -> some View
/// A view representing the body of a control group.
public typealias Body = some View
}
/// A view that controls a navigation presentation.
///
/// People click or tap a navigation link to present a view inside a
/// ``NavigationStack`` or ``NavigationSplitView``. You control the visual
/// appearance of the link by providing view content in the link's `label`
/// closure. For example, you can use a ``Label`` to display a link:
///
///     NavigationLink {
///         FolderDetail(id: workFolder.id)
///     } label: {
///         Label("Work Folder", systemImage: "folder")
///     }
///
/// For a link composed only of text, you can use one of the convenience
/// initializers that takes a string and creates a ``Text`` view for you:
///
///     NavigationLink("Work Folder") {
///         FolderDetail(id: workFolder.id)
///     }
///
/// ### Link to a destination view
///
/// You can perform navigation by initializing a link with a destination view
/// that you provide in the `destination` closure. For example, consider a
/// `ColorDetail` view that fills itself with a color:
///
///     struct ColorDetail: View {
///         var color: Color
///
///         var body: some View {
///             color.navigationTitle(color.description)
///         }
///     }
///
/// The following ``NavigationStack`` presents three links to color detail
/// views:
///
///     NavigationStack {
///         List {
///             NavigationLink("Mint") { ColorDetail(color: .mint) }
///             NavigationLink("Pink") { ColorDetail(color: .pink) }
///             NavigationLink("Teal") { ColorDetail(color: .teal) }
///         }
///         .navigationTitle("Colors")
///     }
///
/// ### Create a presentation link
///
/// Alternatively, you can use a navigation link to perform navigation based
/// on a presented data value. To support this, use the
/// ``View/navigationDestination(for:destination:)`` view modifier
/// inside a navigation stack to associate a view with a kind of data, and
/// then present a value of that data type from a navigation link. The
/// following example reimplements the previous example as a series of
/// presentation links:
///
///     NavigationStack {
///         List {
///             NavigationLink("Mint", value: Color.mint)
///             NavigationLink("Pink", value: Color.pink)
///             NavigationLink("Teal", value: Color.teal)
///         }
///         .navigationDestination(for: Color.self) { color in
///             ColorDetail(color: color)
///         }
///         .navigationTitle("Colors")
///     }
///
/// Separating the view from the data facilitates programmatic navigation
/// because you can manage navigation state by recording the presented data.
///
/// ### Control a presentation link programmatically
///
/// To navigate programmatically, introduce a state variable that tracks the
/// items on a stack. For example, you can create an array of colors to
/// store the stack state from the previous example, and initialize it as
/// an empty array to start with an empty stack:
///
///     @State private var colors: [Color] = []
///
/// Then pass a ``Binding`` to the state to the navigation stack:
///
///     NavigationStack(path: $colors) {
///         // ...
///     }
///
/// You can use the array to observe the current state of the stack. You can
/// also modify the array to change the contents of the stack. For example,
/// you can programmatically add ``ShapeStyle/blue`` to the array, and
/// navigation to a new color detail view using the following method:
///
///     func showBlue() {
///         colors.append(.blue)
///     }
///
/// ### Coordinate with a list
///
/// You can also use a navigation link to control ``List`` selection in a
/// ``NavigationSplitView``:
///
///     let colors: [Color] = [.mint, .pink, .teal]
///     @State private var selection: Color? // Nothing selected by default.
///
///     var body: some View {
///         NavigationSplitView {
///             List(colors, id: \.self, selection: $selection) { color in
///                 NavigationLink(color.description, value: color)
///             }
///         } detail: {
///             if let color = selection {
///                 ColorDetail(color: color)
///             } else {
///                 Text("Pick a color")
///             }
///         }
///     }
///
/// The list coordinates with the navigation logic so that changing the
/// selection state variable in another part of your code activates the
/// navigation link with the corresponding color. Similarly, if someone
/// chooses the navigation link associated with a particular color, the
/// list updates the selection value that other parts of your code can read.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct NavigationLink<Label, Destination> : View where Label : View, Destination : View {
/// Creates a navigation link that presents the destination view.
/// - Parameters:
///   - destination: A view for the navigation link to present.
///   - label: A view builder to produce a label describing the `destination`
///    to present.
public init(@ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label)
/// Creates a navigation link that presents the destination view when active.
/// - Parameters:
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
///   - destination: A view for the navigation link to present.
///   - label: A view builder to produce a label describing the `destination`
///    to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init(isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label)
/// Creates a navigation link that presents the destination view when
/// a bound selection variable equals a given tag value.
/// - Parameters:
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
///   - destination: A view for the navigation link to present.
///   - label: A view builder to produce a label describing the
///   `destination` to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<V>(tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label) where V : Hashable
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// Creates a navigation link that presents the destination view.
/// - Parameters:
///   - destination: A view for the navigation link to present.
///   - label: A view builder to produce a label describing the `destination`
///    to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Pass a closure as the destination")
public init(destination: Destination, @ViewBuilder label: () -> Label)
/// Creates a navigation link that presents the destination view when active.
/// - Parameters:
///   - destination: A view for the navigation link to present.
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
///   - label: A view builder to produce a label describing the `destination`
///    to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init(destination: Destination, isActive: Binding<Bool>, @ViewBuilder label: () -> Label)
/// Creates a navigation link that presents the destination view when
/// a bound selection variable equals a given tag value.
/// - Parameters:
///   - destination: A view for the navigation link to present.
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
///   - label: A view builder to produce a label describing the
///   `destination` to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<V>(destination: Destination, tag: V, selection: Binding<V?>, @ViewBuilder label: () -> Label) where V : Hashable
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationLink where Destination == Never {
/// Creates a navigation link that presents the view corresponding to a
/// value.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// If you want to be able to serialize a ``NavigationPath`` that includes
/// this link, use use a `value` that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol.
///
/// - Parameters:
///   - value: An optional value to present.
///     When the user selects the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
///   - label: A label that describes the view that this link presents.
public init<P>(value: P?, @ViewBuilder label: () -> Label) where P : Hashable
/// Creates a navigation link that presents the view corresponding to a
/// value, with a text label that the link generates from a
/// localized string key.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// If you want to be able to serialize a ``NavigationPath`` that includes
/// this link, use use a `value` that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol.
///
/// - Parameters:
///   - titleKey: A localized string that describes the view that this link
///     presents.
///   - value: An optional value to present.
///     When the user selects the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
public init<P>(_ titleKey: LocalizedStringKey, value: P?) where Label == Text, P : Hashable
/// Creates a navigation link that presents the view corresponding to a
/// value, with a text label that the link generates from a
/// title string.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// If you want to be able to serialize a ``NavigationPath`` that includes
/// this link, use use a `value` that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol.
///
/// - Parameters:
///   - title: A string that describes the view that this link presents.
///   - value: An optional value to present.
///     When the user selects the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
public init<S, P>(_ title: S, value: P?) where Label == Text, S : StringProtocol, P : Hashable
/// Creates a navigation link that presents the view corresponding to a
/// codable value.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// Because this initializer takes a value that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// you ensure that a ``NavigationPath`` that includes this link can produce
/// a non-`nil` value for its ``NavigationPath/codable`` property. This
/// helps to make the path serializable.
///
/// - Parameters:
///   - value: An optional value to present.
///     When the user selects the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
///   - label: A label that describes the view that this link presents.
public init<P>(value: P?, @ViewBuilder label: () -> Label) where P : Decodable, P : Encodable, P : Hashable
/// Creates a navigation link that presents the view corresponding to a
/// codable value, with a text label that the link generates from a
/// localized string key.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// Because this initializer takes a value that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// you ensure that a ``NavigationPath`` that includes this link can produce
/// a non-`nil` value for its ``NavigationPath/codable`` property. This
/// helps to make the path serializable.
///
/// - Parameters:
///   - titleKey: A localized string that describes the view that this link
///     presents.
///   - value: An optional value to present. When someone
///     taps or clicks the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
public init<P>(_ titleKey: LocalizedStringKey, value: P?) where Label == Text, P : Decodable, P : Encodable, P : Hashable
/// Creates a navigation link that presents the view corresponding to a
/// codable value, with a text label that the link generates from a
/// title string.
///
/// When someone activates the navigation link that this initializer
/// creates, SwiftUI looks for a nearby
/// ``View/navigationDestination(for:destination:)`` view modifier
/// with a `data` input parameter that matches the type of this
/// initializer's `value` input, with one of the following outcomes:
///
/// * If SwiftUI finds a matching modifier within the view hierarchy of an
///   enclosing ``NavigationStack``, it pushes the modifier's corresponding
///   `destination` view onto the stack.
/// * If SwiftUI finds a matching modifier in the view hierarchy of a stack
///   that's in a later column of a ``NavigationSplitView``, it puts the
///   modifier's destination view as the first and only item onto the stack
///   while preserving the stack's root view.
/// * If there's no matching modifier, but the link appears in a ``List``
///   with selection inside a leading column of a navigation split view,
///   the link updates the selection, which might affect the appearance of
///   a trailing view. For an example of this, see ``NavigationLink``.
/// * In other cases, the link doesn't do anything.
///
/// Because this initializer takes a value that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// you ensure that a ``NavigationPath`` that includes this link can produce
/// a non-`nil` value for its ``NavigationPath/codable`` property. This
/// helps to make the path serializable.
///
/// - Parameters:
///   - title: A string that describes the view that this link presents.
///   - value: An optional value to present.
///     When the user selects the link, SwiftUI stores a copy of the value.
///     Pass a `nil` value to disable the link.
public init<S, P>(_ title: S, value: P?) where Label == Text, S : StringProtocol, P : Decodable, P : Encodable, P : Hashable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension NavigationLink where Label == Text {
/// Creates a navigation link that presents a destination view, with a text label
/// that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - destination: A view for the navigation link to present.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder destination: () -> Destination)
/// Creates a navigation link that presents a destination view, with a text label
/// that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - destination: A view for the navigation link to present.
public init<S>(_ title: S, @ViewBuilder destination: () -> Destination) where S : StringProtocol
/// Creates a navigation link that presents a destination view when active, with a
/// text label that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init(_ titleKey: LocalizedStringKey, isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination)
/// Creates a navigation link that presents a destination view when active, with a
/// text label that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<S>(_ title: S, isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination) where S : StringProtocol
/// Creates a navigation link that presents a destination view when a bound
/// selection variable matches a value you provide, using a text label
/// that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<V>(_ titleKey: LocalizedStringKey, tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination) where V : Hashable
/// Creates a navigation link that presents a destination view when a bound
/// selection variable matches a value you provide, using a text label
/// that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<S, V>(_ title: S, tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination) where S : StringProtocol, V : Hashable
/// Creates a navigation link that presents a destination view, with a text
/// label that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Pass a closure as the destination")
public init(_ titleKey: LocalizedStringKey, destination: Destination)
/// Creates a navigation link that presents a destination view, with a text
/// label that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - destination: A view for the navigation link to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Pass a closure as the destination")
public init<S>(_ title: S, destination: Destination) where S : StringProtocol
/// Creates a navigation link that presents a destination view when active, with a
/// text label that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - destination: A view for the navigation link to present.
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init(_ titleKey: LocalizedStringKey, destination: Destination, isActive: Binding<Bool>)
/// Creates a navigation link that presents a destination view when active, with a
/// text label that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - destination: A view for the navigation link to present.
///   - isActive: A binding to a Boolean value that indicates whether
///   `destination` is currently presented.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<S>(_ title: S, destination: Destination, isActive: Binding<Bool>) where S : StringProtocol
/// Creates a navigation link that presents a destination view when a bound
/// selection variable matches a value you provide, using a text label
/// that the link generates from a localized string key.
/// - Parameters:
///   - titleKey: A localized string key for creating a text label.
///   - destination: A view for the navigation link to present.
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<V>(_ titleKey: LocalizedStringKey, destination: Destination, tag: V, selection: Binding<V?>) where V : Hashable
/// Creates a navigation link that presents a destination view when a bound
/// selection variable matches a value you provide, using a text label
/// that the link generates from a title string.
/// - Parameters:
///   - title: A string for creating a text label.
///   - destination: A view for the navigation link to present.
///   - tag: The value of `selection` that causes the link to present
///   `destination`.
///   - selection: A bound variable that causes the link to present
///   `destination` when `selection` becomes equal to `tag`.
@available(iOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(macOS, introduced: 10.15, deprecated: 13.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(tvOS, introduced: 13.0, deprecated: 16.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(watchOS, introduced: 6.0, deprecated: 9.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "use NavigationLink(value:label:), or navigationDestination(isPresented:destination:), inside a NavigationStack or NavigationSplitView")
public init<S, V>(_ title: S, destination: Destination, tag: V, selection: Binding<V?>) where S : StringProtocol, V : Hashable
}
@available(iOS 13.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension NavigationLink {
/// Sets the navigation link to present its destination as the detail
/// component of the containing navigation view.
///
/// This method sets the behavior when the navigation link is used in a
/// ``NavigationSplitView``, or a
/// multi-column navigation view, such as one using
/// ``ColumnNavigationViewStyle``.
///
/// For example, in a two-column navigation split view, if `isDetailLink` is
/// `true`, triggering the link in the sidebar column sets the contents of
/// the detail column to be the link's destination view. If `isDetailLink`
/// is `false`, the link navigates to the destination view within the
/// primary column.
///
/// If you do not set the detail link behavior with this method, the
/// behavior defaults to `true`.
///
/// The `isDetailLink` modifier only affects view-destination links. Links
/// that present data values always search for a matching navigation
/// destination beginning in the column that contains the link.
///
/// - Parameter isDetailLink: A Boolean value that specifies whether this
/// link presents its destination as the detail component when used in a
/// multi-column navigation view.
/// - Returns: A view that applies the specified detail link behavior.
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func isDetailLink(_ isDetailLink: Bool) -> some View
}
/// A picker style represented by a navigation link that presents the options
/// by pushing a List-style picker view.
///
/// In navigation stacks, prefer the default ``PickerStyle/menu`` style.
/// Consider the navigation link style when you have a large number of
/// options or your design is better expressed by pushing onto a stack.
///
/// You can also use ``PickerStyle/navigationLink`` to construct this style.
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@available(macOS, unavailable)
public struct NavigationLinkPickerStyle : PickerStyle {
/// Creates a navigation link picker style.
public init()
}
/// A type-erased list of data representing the content of a navigation stack.
///
/// You can manage the state of a ``NavigationStack`` by initializing the stack
/// with a binding to a collection of data. The stack stores data items in the
/// collection for each view on the stack. You also can read and write the
/// collection to observe and alter the stack's state.
///
/// When a stack displays views that rely on only one kind of data, you can use
/// a standard collection, like an array, to hold the data. If you need to
/// present different kinds of data in a single stack, use a navigation path
/// instead. The path uses type erasure so you can manage a collection of
/// heterogeneous elements. The path also provides the usual collection
/// controls for adding, counting, and removing data elements.
///
/// ### Serialize the path
///
/// When the values you present on the navigation stack conform to
/// the <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// you can use the path's ``codable`` property to get a serializable
/// representation of the path. Use that representation to save and restore
/// the contents of the stack. For example, you can define an
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// that handles serializing and deserializing the path:
///
///     class MyModelObject: ObservableObject {
///         @Published var path: NavigationPath
///
///         static func readSerializedData() -> Data? {
///             // Read data representing the path from app's persistent storage.
///         }
///
///         static func writeSerializedData(_ data: Data) {
///             // Write data representing the path to app's persistent storage.
///         }
///
///         init() {
///             if let data = Self.readSerializedData() {
///                 do {
///                     let representation = try JSONDecoder().decode(
///                         NavigationPath.CodableRepresentation.self,
///                         from: data)
///                     self.path = NavigationPath(representation)
///                 } catch {
///                     self.path = NavigationPath()
///                 }
///             } else {
///                 self.path = NavigationPath()
///             }
///         }
///
///         func save() {
///             guard let representation = path.codable else { return }
///             do {
///                 let encoder = JSONEncoder()
///                 let data = try encoder.encode(representation)
///                 Self.writeSerializedData(data)
///             } catch {
///                 // Handle error.
///             }
///         }
///     }
///
/// Then, using that object in your view, you can save the state of
/// the navigation path when the ``Scene`` enters the ``ScenePhase/background``
/// state:
///
///     @StateObject private var pathState = MyModelObject()
///     @Environment(\.scenePhase) private var scenePhase
///
///     var body: some View {
///         NavigationStack(path: $pathState.path) {
///             // Add a root view here.
///         }
///         .onChange(of: scenePhase) { phase in
///             if phase == .background {
///                 pathState.save()
///             }
///         }
///     }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct NavigationPath {
/// The number of elements in this path.
public var count: Int { get }
/// A Boolean that indicates whether this path is empty.
public var isEmpty: Bool { get }
/// A value that describes the contents of this path in a serializable
/// format.
///
/// This value is `nil` if any of the type-erased elements of the path
/// don't conform to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol.
public var codable: NavigationPath.CodableRepresentation? { get }
/// Creates a new, empty navigation path.
public init()
/// Creates a new navigation path from the contents of a sequence.
///
/// - Parameters:
///   - elements: A sequence used to create the navigation path.
public init<S>(_ elements: S) where S : Sequence, S.Element : Hashable
/// Creates a new navigation path from the contents of a sequence that
/// contains codable elements.
///
/// - Parameters:
///   - elements: A sequence used to create the navigation path.
public init<S>(_ elements: S) where S : Sequence, S.Element : Decodable, S.Element : Encodable, S.Element : Hashable
/// Creates a new navigation path from a serializable version.
///
/// - Parameters:
///   - codable: A value describing the contents of the new path in a
///     serializable format.
public init(_ codable: NavigationPath.CodableRepresentation)
/// Appends a new value to the end of this path.
public mutating func append<V>(_ value: V) where V : Hashable
/// Appends a new codable value to the end of this path.
public mutating func append<V>(_ value: V) where V : Decodable, V : Encodable, V : Hashable
/// Removes values from the end of this path.
///
/// - Parameters:
///   - k: The number of values to remove. The default value is `1`.
///
/// - Precondition: The input parameter `k` must be greater than or equal
///   to zero, and must be less than or equal to the number of elements in
///   the path.
public mutating func removeLast(_ k: Int = 1)
/// A serializable representation of a navigation path.
///
/// When a navigation path contains elements the conform to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// you can use the path's `CodableRepresentation` to convert the path to an
/// external representation and to convert an external representation back
/// into a navigation path.
public struct CodableRepresentation : Codable {
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
public init(from decoder: Decoder) throws
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
public func encode(to encoder: Encoder) throws
}
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationPath : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: NavigationPath, rhs: NavigationPath) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationPath.CodableRepresentation : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: NavigationPath.CodableRepresentation, rhs: NavigationPath.CodableRepresentation) -> Bool
}
/// A view that presents views in two or three columns, where selections in
/// leading columns control presentations in subsequent columns.
///
/// You create a navigation split view with two or three columns, and typically
/// use it as the root view in a ``Scene``. People choose one or more
/// items in a leading column to display details about those items in
/// subsequent columns.
///
/// To create a two-column navigation split view, use the
/// ``init(sidebar:detail:)`` initializer:
///
///     @State private var employeeIds: Set<Employee.ID> = []
///
///     var body: some View {
///         NavigationSplitView {
///             List(model.employees, selection: $employeeIds) { employee in
///                 Text(employee.name)
///             }
///         } detail: {
///             EmployeeDetails(for: employeeIds)
///         }
///     }
///
/// In the above example, the navigation split view coordinates with the
/// ``List`` in its first column, so that when people make a selection, the
/// detail view updates accordingly. Programmatic changes that you make to the
/// selection property also affect both the list appearance and the presented
/// detail view.
///
/// To create a three-column view, use the ``init(sidebar:content:detail:)``
/// initializer. The selection in the first column affects the second, and the
/// selection in the second column affects the third. For example, you can show
/// a list of departments, the list of employees in the selected department,
/// and the details about all of the selected employees:
///
///     @State private var departmentId: Department.ID? // Single selection.
///     @State private var employeeIds: Set<Employee.ID> = [] // Multiple selection.
///
///     var body: some View {
///         NavigationSplitView {
///             List(model.departments, selection: $departmentId) { department in
///                 Text(department.name)
///             }
///         } content: {
///             if let department = model.department(id: departmentId) {
///                 List(department.employees, selection: $employeeIds) { employee in
///                     Text(employee.name)
///                 }
///             } else {
///                 Text("Select a department")
///             }
///         } detail: {
///             EmployeeDetails(for: employeeIds)
///         }
///     }
///
/// You can also embed a ``NavigationStack`` in a column. Tapping or clicking a
/// ``NavigationLink`` that appears in an earlier column sets the view that the
/// stack displays over its root view. Activating a link in the same column
/// adds a view to the stack. Either way, the link must present a data type
/// for which the stack has a corresponding
/// ``View/navigationDestination(for:destination:)`` modifier.
///
/// On watchOS and tvOS, and with narrow sizes like on iPhone or on iPad in
/// Slide Over, the navigation split view collapses all of its columns
/// into a stack, and shows the last column that displays useful information.
/// For example, the three-column example above shows the list of departments to
/// start, the employees in the department after someone selects a department,
/// and the employee details when someone selects an employee. For rows in a
/// list that have ``NavigationLink`` instances, the list draws disclosure
/// chevrons while in the collapsed state.
///
/// ### Control column visibility
///
/// You can programmatically control the visibility of navigation split view
/// columns by creating a ``State`` value of type
/// ``NavigationSplitViewVisibility``. Then pass a ``Binding`` to that state to
/// the appropriate initializer --- such as
/// ``init(columnVisibility:sidebar:detail:)`` for two columns, or
/// the ``init(columnVisibility:sidebar:content:detail:)`` for three columns.
///
/// The following code updates the first example above to always hide the
/// first column when the view appears:
///
///     @State private var employeeIds: Set<Employee.ID> = []
///     @State private var columnVisibility =
///         NavigationSplitViewVisibility.detailOnly
///
///     var body: some View {
///         NavigationSplitView(columnVisibility: $columnVisibility) {
///             List(model.employees, selection: $employeeIds) { employee in
///                 Text(employee.name)
///             }
///         } detail: {
///             EmployeeDetails(for: employeeIds)
///         }
///     }
///
/// The split view ignores the visibility control when it collapses its columns
/// into a stack.
///
/// ### Collapsed split views
///
/// At narrow size classes, such as on iPhone or Apple Watch, a navigation split
/// view collapses into a single stack. Typically SwiftUI automatically chooses
/// the view to show on top of this single stack, based on the content of the
/// split view's columns.
///
/// For custom navigation experiences, you can provide more information to help
/// SwiftUI choose the right column. Create a `State` value of type
/// ``NavigationSplitViewColumn``. Then pass a `Binding` to that state to the
/// appropriate initializer, such as
/// ``init(preferredCompactColumn:sidebar:detail:)`` or
/// ``init(preferredCompactColumn:sidebar:content:detail:)``.
///
/// The following code shows the blue detail view when run on iPhone. When the
/// person using the app taps the back button, they'll see the yellow view. The
/// value of `preferredPreferredCompactColumn` will change from `.detail` to
/// `.sidebar`:
///
///     @State private var preferredColumn =
///         NavigationSplitViewColumn.detail
///
///     var body: some View {
///         NavigationSplitView(preferredCompactColumn: $preferredColumn) {
///             Color.yellow
///         } detail: {
///             Color.blue
///         }
///     }
///
/// ### Customize a split view
///
/// To specify a preferred column width in a navigation split view, use the
/// ``View/navigationSplitViewColumnWidth(_:)`` modifier. To set minimum,
/// maximum, and ideal sizes for a column, use
/// ``View/navigationSplitViewColumnWidth(min:ideal:max:)``. You can specify a
/// different modifier in each column. The navigation split view does its
/// best to accommodate the preferences that you specify, but might make
/// adjustments based on other constraints.
///
/// To specify how columns in a navigation split view interact, use the
/// ``View/navigationSplitViewStyle(_:)`` modifier with a
/// ``NavigationSplitViewStyle`` value. For example, you can specify
/// whether to emphasize the detail column or to give all of the columns equal
/// prominence.
///
/// On some platforms, `NavigationSplitView` adds a
/// ``ToolbarDefaultItemKind/sidebarToggle`` toolbar item. Use the
/// ``View/toolbar(removing:)`` modifier to remove the default
/// item.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct NavigationSplitView<Sidebar, Content, Detail> : View where Sidebar : View, Content : View, Detail : View {
/// Creates a three-column navigation split view.
///
/// - Parameters:
///   - sidebar: The view to show in the leading column.
///   - content: The view to show in the middle column.
///   - detail: The view to show in the detail area.
public init(@ViewBuilder sidebar: () -> Sidebar, @ViewBuilder content: () -> Content, @ViewBuilder detail: () -> Detail)
/// Creates a three-column navigation split view that enables programmatic
/// control of leading columns' visibility.
///
/// - Parameters:
///   - columnVisibility: A ``Binding`` to state that controls the
///     visibility of the leading columns.
///   - sidebar: The view to show in the leading column.
///   - content: The view to show in the middle column.
///   - detail: The view to show in the detail area.
public init(columnVisibility: Binding<NavigationSplitViewVisibility>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder content: () -> Content, @ViewBuilder detail: () -> Detail)
/// Creates a two-column navigation split view.
///
/// - Parameters:
///   - sidebar: The view to show in the leading column.
///   - detail: The view to show in the detail area.
public init(@ViewBuilder sidebar: () -> Sidebar, @ViewBuilder detail: () -> Detail) where Content == EmptyView
/// Creates a two-column navigation split view that enables programmatic
/// control of the sidebar's visibility.
///
/// - Parameters:
///   - columnVisibility: A ``Binding`` to state that controls the
///     visibility of the leading column.
///   - sidebar: The view to show in the leading column.
///   - detail: The view to show in the detail area.
public init(columnVisibility: Binding<NavigationSplitViewVisibility>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder detail: () -> Detail) where Content == EmptyView
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension NavigationSplitView {
/// Creates a three-column navigation split view that enables programmatic
/// control over which column appears on top when the view collapses into a
/// single column in narrow sizes.
///
/// - Parameters:
///   - preferredCompactColumn: A ``Binding`` to state that controls which
///     column appears on top when the view collapses.
///   - sidebar: The view to show in the leading column.
///   - content: The view to show in the middle column.
///   - detail: The view to show in the detail area.
public init(preferredCompactColumn: Binding<NavigationSplitViewColumn>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder content: () -> Content, @ViewBuilder detail: () -> Detail)
/// Creates a three-column navigation split view that enables programmatic
/// control of leading columns' visibility in regular sizes and which column
/// appears on top when the view collapses into a single column in narrow
/// sizes.
///
/// - Parameters:
///   - columnVisibility: A ``Binding`` to state that controls the
///     visibility of the leading columns.
///   - preferredCompactColumn: A ``Binding`` to state that controls which
///     column appears on top when the view collapses.
///   - sidebar: The view to show in the leading column.
///   - content: The view to show in the middle column.
///   - detail: The view to show in the detail area.
public init(columnVisibility: Binding<NavigationSplitViewVisibility>, preferredCompactColumn: Binding<NavigationSplitViewColumn>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder content: () -> Content, @ViewBuilder detail: () -> Detail)
/// Creates a two-column navigation split view that enables programmatic
/// control over which column appears on top when the view collapses into a
/// single column in narrow sizes.
///
/// - Parameters:
///   - preferredCompactColumn: A ``Binding`` to state that controls which
///     column appears on top when the view collapses.
///   - sidebar: The view to show in the leading column.
///   - detail: The view to show in the detail area.
public init(preferredCompactColumn: Binding<NavigationSplitViewColumn>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder detail: () -> Detail) where Content == EmptyView
/// Creates a two-column navigation split view that enables programmatic
/// control of the sidebar's visibility in regular sizes and which column
/// appears on top when the view collapses into a single column in narrow
/// sizes.
///
/// - Parameters:
///   - columnVisibility: A ``Binding`` to state that controls the
///     visibility of the leading column.
///   - preferredCompactColumn: A ``Binding`` to state that controls which
///     column appears on top when the view collapses.
///   - sidebar: The view to show in the leading column.
///   - detail: The view to show in the detail area.
public init(columnVisibility: Binding<NavigationSplitViewVisibility>, preferredCompactColumn: Binding<NavigationSplitViewColumn>, @ViewBuilder sidebar: () -> Sidebar, @ViewBuilder detail: () -> Detail) where Content == EmptyView
}
/// A view that represents a column in a navigation split view.
///
/// A ``NavigationSplitView`` collapses into a single stack in some contexts,
/// like on iPhone or Apple Watch. Use this type with the
/// `preferredCompactColumn` parameter to control which column of the navigation
/// split view appears on top of the collapsed stack.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct NavigationSplitViewColumn : Hashable, Sendable {
public static var sidebar: NavigationSplitViewColumn { get }
public static var content: NavigationSplitViewColumn { get }
public static var detail: NavigationSplitViewColumn { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: NavigationSplitViewColumn, b: NavigationSplitViewColumn) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A type that specifies the appearance and interaction of navigation split
/// views within a view hierarchy.
///
/// To configure the navigation split view style for a view hierarchy, use the
/// ``View/navigationSplitViewStyle(_:)`` modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public protocol NavigationSplitViewStyle {
/// A view that represents the body of a navigation split view.
associatedtype Body : View
/// Creates a view that represents the body of a navigation split view.
///
/// SwiftUI calls this method for each instance of ``NavigationSplitView``,
/// where this style is the current ``NavigationSplitViewStyle``.
///
/// - Parameter configuration: The properties of the instance to create.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a navigation split view instance.
typealias Configuration = NavigationSplitViewStyleConfiguration
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationSplitViewStyle where Self == BalancedNavigationSplitViewStyle {
/// A navigation split style that reduces the size of the detail content
/// to make room when showing the leading column or columns.
public static var balanced: BalancedNavigationSplitViewStyle { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationSplitViewStyle where Self == ProminentDetailNavigationSplitViewStyle {
/// A navigation split style that attempts to maintain the size of the
/// detail content when hiding or showing the leading columns.
public static var prominentDetail: ProminentDetailNavigationSplitViewStyle { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension NavigationSplitViewStyle where Self == AutomaticNavigationSplitViewStyle {
/// A navigation split style that resolves its appearance automatically
/// based on the current context.
public static var automatic: AutomaticNavigationSplitViewStyle { get }
}
/// The properties of a navigation split view instance.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct NavigationSplitViewStyleConfiguration {
}
/// The visibility of the leading columns in a navigation split view.
///
/// Use a value of this type to control the visibility of the columns of a
/// ``NavigationSplitView``. Create a ``State`` property with a
/// value of this type, and pass a ``Binding`` to that state to the
/// ``NavigationSplitView/init(columnVisibility:sidebar:detail:)`` or
/// ``NavigationSplitView/init(columnVisibility:sidebar:content:detail:)``
/// initializer when you create the navigation split view. You can then
/// modify the value elsewhere in your code to:
///
/// * Hide all but the trailing column with ``detailOnly``.
/// * Hide the leading column of a three-column navigation split view
///   with ``doubleColumn``.
/// * Show all the columns with ``all``.
/// * Rely on the automatic behavior for the current context with ``automatic``.
///
/// >Note: Some platforms don't respect every option. For example, macOS always
/// displays the content column.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct NavigationSplitViewVisibility : Equatable, Codable, Sendable {
/// Hide the leading two columns of a three-column navigation split view, so
/// that just the detail area shows.
public static var detailOnly: NavigationSplitViewVisibility { get }
/// Show the content column and detail area of a three-column navigation
/// split view, or the sidebar column and detail area of a two-column
/// navigation split view.
///
/// For a two-column navigation split view, `doubleColumn` is equivalent
/// to `all`.
public static var doubleColumn: NavigationSplitViewVisibility { get }
/// Show all the columns of a three-column navigation split view.
public static var all: NavigationSplitViewVisibility { get }
/// Use the default leading column visibility for the current device.
///
/// This computed property returns one of the three concrete cases:
/// ``detailOnly``, ``doubleColumn``, or ``all``.
public static var automatic: NavigationSplitViewVisibility { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: NavigationSplitViewVisibility, rhs: NavigationSplitViewVisibility) -> Bool
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
public func encode(to encoder: Encoder) throws
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
public init(from decoder: Decoder) throws
}
/// A view that displays a root view and enables you to present additional
/// views over the root view.
///
/// Use a navigation stack to present a stack of views over a root view.
/// People can add views to the top of the stack by clicking or tapping a
/// ``NavigationLink``, and remove views using built-in, platform-appropriate
/// controls, like a Back button or a swipe gesture. The stack always displays
/// the most recently added view that hasn't been removed, and doesn't allow
/// the root view to be removed.
///
/// To create navigation links, associate a view with a data type by adding a
/// ``View/navigationDestination(for:destination:)`` modifier inside
/// the stack's view hierarchy. Then initialize a ``NavigationLink`` that
/// presents an instance of the same kind of data. The following stack displays
/// a `ParkDetails` view for navigation links that present data of type `Park`:
///
///     NavigationStack {
///         List(parks) { park in
///             NavigationLink(park.name, value: park)
///         }
///         .navigationDestination(for: Park.self) { park in
///             ParkDetails(park: park)
///         }
///     }
///
/// In this example, the ``List`` acts as the root view and is always
/// present. Selecting a navigation link from the list adds a `ParkDetails`
/// view to the stack, so that it covers the list. Navigating back removes
/// the detail view and reveals the list again. The system disables backward
/// navigation controls when the stack is empty and the root view, namely
/// the list, is visible.
///
/// ### Manage navigation state
///
/// By default, a navigation stack manages state to keep track of the views on
/// the stack. However, your code can share control of the state by initializing
/// the stack with a binding to a collection of data values that you create.
/// The stack adds items to the collection as it adds views to the stack and
/// removes items when it removes views. For example, you can create a ``State``
/// property to manage the navigation for the park detail view:
///
///     @State private var presentedParks: [Park] = []
///
/// Initializing the state as an empty array indicates a stack with no views.
/// Provide a ``Binding`` to this state property using the dollar sign (`$`)
/// prefix when you create a stack using the ``init(path:root:)-3bt4q``
/// initializer:
///
///     NavigationStack(path: $presentedParks) {
///         List(parks) { park in
///             NavigationLink(park.name, value: park)
///         }
///         .navigationDestination(for: Park.self) { park in
///             ParkDetails(park: park)
///         }
///     }
///
/// Like before, when someone taps or clicks the navigation link for a
/// park, the stack displays the `ParkDetails` view using the associated park
/// data. However, now the stack also puts the park data in the `presentedParks`
/// array. Your code can observe this array to read the current stack state. It
/// can also modify the array to change the views on the stack. For example, you
/// can create a method that configures the stack with a specific set of parks:
///
///     func showParks() {
///         presentedParks = [Park("Yosemite"), Park("Sequoia")]
///     }
///
/// The `showParks` method replaces the stack's display with a view that shows
/// details for Sequoia, the last item in the new `presentedParks` array.
/// Navigating back from that view removes Sequoia from the array, which
/// reveals a view that shows details for Yosemite. Use a path to support
/// deep links, state restoration, or other kinds of programmatic navigation.
///
/// ### Navigate to different view types
///
/// To create a stack that can present more than one kind of view, you can add
/// multiple ``View/navigationDestination(for:destination:)`` modifiers
/// inside the stack's view hierarchy, with each modifier presenting a
/// different data type. The stack matches navigation links with navigation
/// destinations based on their respective data types.
///
/// To create a path for programmatic navigation that contains more than one
/// kind of data, you can use a ``NavigationPath`` instance as the path.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@MainActor public struct NavigationStack<Data, Root> : View where Root : View {
/// Creates a navigation stack that manages its own navigation state.
///
/// If you want to access the navigation state, use
/// ``init(path:root:)-3bt4q`` instead.
///
/// - Parameters:
///   - root: The view to display when the stack is empty.
@MainActor public init(@ViewBuilder root: () -> Root) where Data == NavigationPath
/// Creates a navigation stack with heterogeneous navigation state that you
/// can control.
///
/// If you prefer to store the navigation state as a collection of data
/// values, use ``init(path:root:)-3bt4q`` instead. If you don't need
/// access to the navigation state, use ``init(root:)``.
///
/// - Parameters:
///   - path: A ``Binding`` to the navigation state for this stack.
///   - root: The view to display when the stack is empty.
@MainActor public init(path: Binding<NavigationPath>, @ViewBuilder root: () -> Root) where Data == NavigationPath
/// Creates a navigation stack with homogeneous navigation state that you
/// can control.
///
/// If you prefer to store the navigation state as a ``NavigationPath``,
/// use ``init(path:root:)-63x0h`` instead. If you don't need
/// access to the navigation state, use ``init(root:)``.
///
/// - Parameters:
///   - path: A ``Binding`` to the navigation state for this stack.
///   - root: The view to display when the stack is empty.
@MainActor public init(path: Binding<Data>, @ViewBuilder root: () -> Root) where Data : MutableCollection, Data : RandomAccessCollection, Data : RangeReplaceableCollection, Data.Element : Hashable
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A view for presenting a stack of views that represents a visible path in a
/// navigation hierarchy.
///
/// Use a `NavigationView` to create a navigation-based app in which the user
/// can traverse a collection of views. Users navigate to a destination view
/// by selecting a ``NavigationLink`` that you provide. On iPadOS and macOS, the
/// destination content appears in the next column. Other platforms push a new
/// view onto the stack, and enable removing items from the stack with
/// platform-specific controls, like a Back button or a swipe gesture.
///
/// ![A diagram showing a multicolumn navigation view on
/// macOS, and a stack of views on iOS.](NavigationView-1)
///
/// Use the ``init(content:)`` initializer to create a
/// navigation view that directly associates navigation links and their
/// destination views:
///
///     NavigationView {
///         List(model.notes) { note in
///             NavigationLink(note.title, destination: NoteEditor(id: note.id))
///         }
///         Text("Select a Note")
///     }
///
/// Style a navigation view by modifying it with the
/// ``View/navigationViewStyle(_:)`` view modifier. Use other modifiers, like
/// ``View/navigationTitle(_:)-avgj``, on views presented by the navigation
/// view to customize the navigation interface for the presented view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use NavigationStack or NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use NavigationStack or NavigationSplitView instead")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "use NavigationStack or NavigationSplitView instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use NavigationStack or NavigationSplitView instead")
public struct NavigationView<Content> : View where Content : View {
/// Creates a destination-based navigation view.
///
/// Perform navigation by initializing a link with a destination view.
/// For example, consider a `ColorDetail` view that displays a color sample:
///
///     struct ColorDetail: View {
///         var color: Color
///
///         var body: some View {
///             color
///                 .frame(width: 200, height: 200)
///                 .navigationTitle(color.description.capitalized)
///         }
///     }
///
/// The following ``NavigationView`` presents three links to color detail
/// views:
///
///     NavigationView {
///         List {
///             NavigationLink("Purple", destination: ColorDetail(color: .purple))
///             NavigationLink("Pink", destination: ColorDetail(color: .pink))
///             NavigationLink("Orange", destination: ColorDetail(color: .orange))
///         }
///         .navigationTitle("Colors")
///
///         Text("Select a Color") // A placeholder to show before selection.
///     }
///
/// When the horizontal size class is ``UserInterfaceSizeClass/regular``,
/// like on an iPad in landscape mode, or on a Mac,
/// the navigation view presents itself as a multicolumn view,
/// using its second and later content views --- a single ``Text``
/// view in the example above --- as a placeholder for the corresponding
/// column:
///
/// ![A screenshot of a Mac window showing a multicolumn navigation view.
/// The left column lists the colors Purple, Pink, and Orange, with
/// none selected. The right column presents a placeholder view that says
/// Select a Color.](NavigationView-init-content-1)
///
/// When the user selects one of the navigation links from the
/// list, the linked destination view replaces the placeholder
/// text in the detail column:
///
/// ![A screenshot of a Mac window showing a multicolumn navigation view.
/// The left column lists the colors Purple, Pink, and Orange, with
/// Purple selected. The right column presents a detail view that shows a
/// purple square.](NavigationView-init-content-2)
///
/// When the size class is ``UserInterfaceSizeClass/compact``, like
/// on an iPhone in portrait orientation, the navigation view presents
/// itself as a single column that the user navigates as a stack. Tapping
/// one of the links replaces the list with the detail view, which
/// provides a back button to return to the list:
///
/// ![Two screenshots of an iPhone in portrait orientation connected by an
/// arrow. The first screenshot shows a single column consisting of a list
/// of colors with the names Purple, Pink, and Orange. The second
/// screenshot has the title Purple, and contains a purple square.
/// The arrow connects the Purple item in the list on the left to the
/// screenshot on the right.](NavigationView-init-content-3)
///
/// - Parameter content: A ``ViewBuilder`` that produces the content that
///   the navigation view wraps. Any views after the first act as
///   placeholders for corresponding columns in a multicolumn display.
public init(@ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A specification for the appearance and interaction of a `NavigationView`.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
public protocol NavigationViewStyle {
}
@available(iOS, introduced: 15.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
@available(macOS, introduced: 12.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView")
extension NavigationViewStyle where Self == ColumnNavigationViewStyle {
/// A navigation view style represented by a series of views in columns.
public static var columns: ColumnNavigationViewStyle { get }
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "replace styled NavigationView with NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
extension NavigationViewStyle where Self == DefaultNavigationViewStyle {
/// The default navigation view style in the current context of the view
/// being styled.
public static var automatic: DefaultNavigationViewStyle { get }
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
extension NavigationViewStyle where Self == StackNavigationViewStyle {
/// A navigation view style represented by a view stack that only shows a
/// single top view at a time.
public static var stack: StackNavigationViewStyle { get }
}
/// A property wrapper type that subscribes to an observable object and
/// invalidates a view whenever the observable object changes.
///
/// Add the `@ObservedObject` attribute to a parameter of a SwiftUI ``View``
/// when the input is an
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// and you want the view to update when the object's published properties
/// change. You typically do this to pass a ``StateObject`` into a subview.
///
/// The following example defines a data model as an observable object,
/// instantiates the model in a view as a state object, and then passes
/// the instance to a subview as an observed object:
///
///     class DataModel: ObservableObject {
///         @Published var name = "Some Name"
///         @Published var isEnabled = false
///     }
///
///     struct MyView: View {
///         @StateObject private var model = DataModel()
///
///         var body: some View {
///             Text(model.name)
///             MySubView(model: model)
///         }
///     }
///
///     struct MySubView: View {
///         @ObservedObject var model: DataModel
///
///         var body: some View {
///             Toggle("Enabled", isOn: $model.isEnabled)
///         }
///     }
///
/// When any published property of the observable object changes, SwiftUI
/// updates any view that depends on the object. Subviews can
/// also make updates to the model properties, like the ``Toggle`` in the
/// above example, that propagate to other observers throughout the view
/// hierarchy.
///
/// Don't specify a default or initial value for the observed object. Use the
/// attribute only for a property that acts as an input for a view, as in the
/// above example.
///
/// > Note: Don't wrap objects conforming to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol with `@ObservedObject`. SwiftUI automatically tracks dependencies
/// to `Observable` objects used within body and updates dependent views when
/// their data changes. Attempting to wrap an `Observable` object with
/// `@ObservedObject` may cause a compiler error, because it requires that its
/// wrapped object to conform to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol.
/// >
/// > If the view needs a binding to a property of an `Observable` object in
/// its body, wrap the object with the ``Bindable`` property wrapper instead;
/// for example, `@Bindable var model: DataModel`. For more information, see
/// <doc:Managing-model-data-in-your-app>.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@propertyWrapper @frozen public struct ObservedObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject {
/// A wrapper of the underlying observable object that can create bindings
/// to its properties.
@dynamicMemberLookup @frozen public struct Wrapper {
/// Gets a binding to the value of a specified key path.
///
/// - Parameter keyPath: A key path to a specific  value.
///
/// - Returns: A new binding.
public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<ObjectType, Subject>) -> Binding<Subject> { get }
}
/// Creates an observed object with an initial value.
///
/// This initializer has the same behavior as the ``init(wrappedValue:)``
/// initializer. See that initializer for more information.
///
/// - Parameter initialValue: An initial value.
public init(initialValue: ObjectType)
/// Creates an observed object with an initial wrapped value.
///
/// Don't call this initializer directly. Instead, declare
/// an input to a view with the `@ObservedObject` attribute, and pass a
/// value to this input when you instantiate the view. Unlike a
/// ``StateObject`` which manages data storage, you use an observed
/// object to refer to storage that you manage elsewhere, as in the
/// following example:
///
///     class DataModel: ObservableObject {
///         @Published var name = "Some Name"
///         @Published var isEnabled = false
///     }
///
///     struct MyView: View {
///         @StateObject private var model = DataModel()
///
///         var body: some View {
///             Text(model.name)
///             MySubView(model: model)
///         }
///     }
///
///     struct MySubView: View {
///         @ObservedObject var model: DataModel
///
///         var body: some View {
///             Toggle("Enabled", isOn: $model.isEnabled)
///         }
///     }
///
/// Explicitly calling the observed object initializer in `MySubView` would
/// behave correctly, but would needlessly recreate the same observed object
/// instance every time SwiftUI calls the view's initializer to redraw the
/// view.
///
/// - Parameter wrappedValue: An initial value for the observable object.
public init(wrappedValue: ObjectType)
/// The underlying value that the observed object references.
///
/// The wrapped value property provides primary access to the observed
/// object's data. However, you don't typically access it by name. Instead,
/// SwiftUI accesses this property for you when you refer to the variable
/// that you create with the `@ObservedObject` attribute.
///
///     struct MySubView: View {
///         @ObservedObject var model: DataModel
///
///         var body: some View {
///             Text(model.name) // Reads name from model's wrapped value.
///         }
///     }
///
/// When you change a wrapped value, you can access the new value
/// immediately. However, SwiftUI updates views that display the value
/// asynchronously, so the interface might not update immediately.
@MainActor public var wrappedValue: ObjectType
/// A projection of the observed object that creates bindings to its
/// properties.
///
/// Use the projected value to get a ``Binding`` to a property of an
/// observed object. To access the projected value, prefix the property
/// variable with a dollar sign (`$`). For example, you can get a binding
/// to a model's `isEnabled` Boolean so that a ``Toggle`` can control its
/// value:
///
///     struct MySubView: View {
///         @ObservedObject var model: DataModel
///
///         var body: some View {
///             Toggle("Enabled", isOn: $model.isEnabled)
///         }
///     }
///
@MainActor public var projectedValue: ObservedObject<ObjectType>.Wrapper { get }
}
/// A shape with a translation offset transform applied to it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct OffsetShape<Content> : Shape where Content : Shape {
public var shape: Content
public var offset: CGSize
@inlinable public init(shape: Content, offset: CGSize)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var role: ShapeRole { get }
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, CGSize.AnimatableData>
/// The data to animate.
public var animatableData: OffsetShape<Content>.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension OffsetShape : InsettableShape where Content : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> OffsetShape<Content.InsetShape>
/// The type of the inset shape.
public typealias InsetShape = OffsetShape<Content.InsetShape>
}
/// Returns a transition that offset the view by the specified amount.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct OffsetTransition : Transition {
/// The amount to offset the view by.
public var offset: CGSize
/// Creates a transition that offset the view by the specified amount.
public init(_ offset: CGSize)
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: OffsetTransition.Content, phase: TransitionPhase) -> some View
/// The type of view representing the body.
public typealias Body = some View
}
/// A table row modifier that adds the ability to insert data in some base
/// row content.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct OnInsertTableRowModifier {
public var body: some _TableRowContentModifier { get }
public typealias Body = some _TableRowContentModifier
}
/// A transition from transparent to opaque on insertion, and from opaque to
/// transparent on removal.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct OpacityTransition : Transition {
public init()
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: OpacityTransition.Content, phase: TransitionPhase) -> some View
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
public static let properties: TransitionProperties
/// The type of view representing the body.
public typealias Body = some View
}
/// An action that opens a URL.
///
/// Read the ``EnvironmentValues/openURL`` environment value to get an
/// instance of this structure for a given ``Environment``. Call the
/// instance to open a URL. You call the instance directly because it
/// defines a ``OpenURLAction/callAsFunction(_:)`` method that Swift
/// calls when you call the instance.
///
/// For example, you can open a web site when the user taps a button:
///
///     struct OpenURLExample: View {
///         @Environment(\.openURL) private var openURL
///
///         var body: some View {
///             Button {
///                 if let url = URL(string: "https://www.example.com") {
///                     openURL(url)
///                 }
///             } label: {
///                 Label("Get Help", systemImage: "person.fill.questionmark")
///             }
///         }
///     }
///
/// If you want to know whether the action succeeds, add a completion
/// handler that takes a Boolean value. In this case, Swift implicitly
/// calls the ``OpenURLAction/callAsFunction(_:completion:)`` method
/// instead. That method calls your completion handler after it determines
/// whether it can open the URL, but possibly before it finishes opening
/// the URL. You can add a handler to the example above so that
/// it prints the outcome to the console:
///
///     openURL(url) { accepted in
///         print(accepted ? "Success" : "Failure")
///     }
///
/// The system provides a default open URL action with behavior
/// that depends on the contents of the URL. For example, the default
/// action opens a Universal Link in the associated app if possible,
/// or in the user’s default web browser if not.
///
/// You can also set a custom action using the ``View/environment(_:_:)``
/// view modifier. Any views that read the action from the environment,
/// including the built-in ``Link`` view and ``Text`` views with markdown
/// links, or links in attributed strings, use your action. Initialize an
/// action by calling the ``OpenURLAction/init(handler:)`` initializer with
/// a handler that takes a URL and returns an ``OpenURLAction/Result``:
///
///     Text("Visit [Example Company](https://www.example.com) for details.")
///         .environment(\.openURL, OpenURLAction { url in
///             handleURL(url) // Define this method to take appropriate action.
///             return .handled
///         })
///
/// SwiftUI translates the value that your custom action's handler
/// returns into an appropriate Boolean result for the action call.
/// For example, a view that uses the action declared above
/// receives `true` when calling the action, because the
/// handler always returns ``OpenURLAction/Result/handled``.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct OpenURLAction {
/// The result of a custom open URL action.
///
/// If you declare a custom ``OpenURLAction`` in the ``Environment``,
/// return one of the result values from its handler.
///
/// * Use ``handled`` to indicate that the handler opened the URL.
/// * Use ``discarded`` to indicate that the handler discarded the URL.
/// * Use ``systemAction`` without an argument to ask SwiftUI
///   to open the URL with the system handler.
/// * Use ``systemAction(_:)`` with a URL argument to ask SwiftUI
///   to open the specified URL with the system handler.
///
/// You can use the last option to transform URLs, while
/// still relying on the system to open the URL. For example,
/// you could append a path component to every URL:
///
///     .environment(\.openURL, OpenURLAction { url in
///         .systemAction(url.appendingPathComponent("edit"))
///     })
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct Result {
/// The handler opened the URL.
///
/// The action invokes its completion handler with `true` when your
/// handler returns this value.
public static let handled: OpenURLAction.Result
/// The handler discarded the URL.
///
/// The action invokes its completion handler with `false` when your
/// handler returns this value.
public static let discarded: OpenURLAction.Result
/// The handler asks the system to open the original URL.
///
/// The action invokes its completion handler with a value that
/// depends on the outcome of the system's attempt to open the URL.
public static let systemAction: OpenURLAction.Result
/// The handler asks the system to open the modified URL.
///
/// The action invokes its completion handler with a value that
/// depends on the outcome of the system's attempt to open the URL.
///
/// - Parameter url: The URL that the handler asks the system to open.
public static func systemAction(_ url: URL) -> OpenURLAction.Result
}
/// Creates an action that opens a URL.
///
/// Use this initializer to create a custom action for opening URLs.
/// Provide a handler that takes a URL and returns an
/// ``OpenURLAction/Result``. Place your handler in the environment
/// using the ``View/environment(_:_:)`` view modifier:
///
///     Text("Visit [Example Company](https://www.example.com) for details.")
///         .environment(\.openURL, OpenURLAction { url in
///             handleURL(url) // Define this method to take appropriate action.
///             return .handled
///         })
///
/// Any views that read the action from the environment, including the
/// built-in ``Link`` view and ``Text`` views with markdown links, or
/// links in attributed strings, use your action.
///
/// SwiftUI translates the value that your custom action's handler
/// returns into an appropriate Boolean result for the action call.
/// For example, a view that uses the action declared above
/// receives `true` when calling the action, because the
/// handler always returns ``OpenURLAction/Result/handled``.
///
/// - Parameter handler: The closure to run for the given URL.
///   The closure takes a URL as input, and returns a ``Result``
///   that indicates the outcome of the action.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init(handler: @escaping (URL) -> OpenURLAction.Result)
/// Opens a URL, following system conventions.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``OpenURLAction`` structure that you get from the
/// ``Environment``, using a URL as an argument:
///
///     struct OpenURLExample: View {
///         @Environment(\.openURL) private var openURL
///
///         var body: some View {
///             Button {
///                 if let url = URL(string: "https://www.example.com") {
///                     openURL(url) // Implicitly calls openURL.callAsFunction(url)
///                 }
///             } label: {
///                 Label("Get Help", systemImage: "person.fill.questionmark")
///             }
///         }
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameter url: The URL to open.
public func callAsFunction(_ url: URL)
/// Asynchronously opens a URL, following system conventions.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``OpenURLAction`` structure that you get from the
/// ``Environment``, using a URL and a completion handler as arguments:
///
///     struct OpenURLExample: View {
///         @Environment(\.openURL) private var openURL
///
///         var body: some View {
///             Button {
///                 if let url = URL(string: "https://www.example.com") {
///                     // Implicitly calls openURL.callAsFunction(url) { ... }
///                     openURL(url) { accepted in
///                         print(accepted ? "Success" : "Failure")
///                     }
///                 }
///             } label: {
///                 Label("Get Help", systemImage: "person.fill.questionmark")
///             }
///         }
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameters:
///   - url: The URL to open.
///   - completion: A closure the method calls after determining if
///     it can open the URL, but possibly before fully opening the URL.
///     The closure takes a Boolean value that indicates whether the
///     method can open the URL.
@available(watchOS, unavailable)
public func callAsFunction(_ url: URL, completion: @escaping (_ accepted: Bool) -> Void)
}
/// An action that presents a window.
///
/// Use the ``EnvironmentValues/openWindow`` environment value to get the
/// instance of this structure for a given ``Environment``. Then call the
/// instance to open a window. You call the instance directly because it
/// defines a ``OpenWindowAction/callAsFunction(id:)`` method that Swift calls
/// when you call the instance.
///
/// For example, you can define a button that opens a new mail viewer
/// window:
///
///     @main
///     struct Mail: App {
///         var body: some Scene {
///             WindowGroup(id: "mail-viewer") {
///                 MailViewer()
///             }
///         }
///     }
///
///     struct NewViewerButton: View {
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             Button("Open new mail viewer") {
///                 openWindow(id: "mail-viewer")
///             }
///         }
///     }
///
/// You indicate which scene to open by providing one of the following:
///  * A string identifier that you pass through the `id` parameter,
///    as in the above example.
///  * A `value` parameter that has a type that matches the type that
///    you specify in the scene's initializer.
///  * Both an identifier and a value. This enables you to define
///    multiple window groups that take input values of the same type, like a
///    <doc://com.apple.documentation/documentation/Foundation/UUID>.
///
/// Use the first option to target either a ``WindowGroup`` or a
/// ``Window`` scene in your app that has a matching identifier. For a
/// `WindowGroup`, the system creates a new window for the group. If
/// the window group presents data, the system provides the default value
/// or `nil` to the window's root view. If the targeted scene is a
/// `Window`, the system orders it to the front.
///
/// Use the other two options to target a `WindowGroup` and provide
/// a value to present. If the interface already has a window from
/// the group that's presenting the specified value, the system brings the
/// window to the front. Otherwise, the system creates a new window and
/// passes a binding to the specified value.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct OpenWindowAction {
/// Opens a window defined by a window group that presents the type of
/// the specified value.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/openWindow`` action with a value:
///
///     openWindow(value: message.id)
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameter value: The value to present.
public func callAsFunction<D>(value: D) where D : Decodable, D : Encodable, D : Hashable
/// Opens a window that's associated with the specified identifier.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/openWindow`` action with an identifier:
///
///     openWindow(id: "message")
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameter id: The identifier of the scene to present.
public func callAsFunction(id: String)
/// Opens a window defined by the window group that presents the specified
/// value type and that's associated with the specified identifier.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``EnvironmentValues/openWindow`` action with an identifier
/// and a value:
///
///     openWindow(id: "message", value: message.id)
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
///
/// - Parameters:
///   - id: The identifier of the scene to present.
///   - value: The value to present.
public func callAsFunction<D>(id: String, value: D) where D : Decodable, D : Encodable, D : Hashable
}
/// A structure that computes views and disclosure groups on demand from an
/// underlying collection of tree-structured, identified data.
///
/// Use an outline group when you need a view that can represent a hierarchy
/// of data by using disclosure views. This allows the user to navigate the
/// tree structure by using the disclosure views to expand and collapse
/// branches.
///
/// In the following example, a tree structure of `FileItem` data offers a
/// simplified view of a file system. Passing the root of this tree and the
/// key path of its children allows you to quickly create a visual
/// representation of the file system.
///
///     struct FileItem: Hashable, Identifiable, CustomStringConvertible {
///         var id: Self { self }
///         var name: String
///         var children: [FileItem]? = nil
///         var description: String {
///             switch children {
///             case nil:
///                 return "📄 \(name)"
///             case .some(let children):
///                 return children.isEmpty ? "📂 \(name)" : "📁 \(name)"
///             }
///         }
///     }
///
///     let data =
///       FileItem(name: "users", children:
///         [FileItem(name: "user1234", children:
///           [FileItem(name: "Photos", children:
///             [FileItem(name: "photo001.jpg"),
///              FileItem(name: "photo002.jpg")]),
///            FileItem(name: "Movies", children:
///              [FileItem(name: "movie001.mp4")]),
///               FileItem(name: "Documents", children: [])
///           ]),
///          FileItem(name: "newuser", children:
///            [FileItem(name: "Documents", children: [])
///            ])
///         ])
///
///     OutlineGroup(data, children: \.children) { item in
///         Text("\(item.description)")
///     }
///
/// ### Type parameters
///
/// Five generic type constraints define a specific `OutlineGroup` instance:
///
/// - `Data`: The type of a collection containing the children of an element in
///   the tree-shaped data.
/// - `ID`: The type of the identifier for an element.
/// - `Parent`: The type of the visual representation of an element whose
///   children property is non-`nil`
/// - `Leaf`: The type of the visual representation of an element whose
///   children property is `nil`.
/// - `Subgroup`: A type of a view that groups a parent view and a view
///   representing its children, typically with some mechanism for showing and
///   hiding the children
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct OutlineGroup<Data, ID, Parent, Leaf, Subgroup> where Data : RandomAccessCollection, ID : Hashable {
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup where ID == Data.Element.ID, Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>, Data.Element : Identifiable {
/// Creates an outline group from a root data element and a key path to
/// its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of a data element. A non-`nil` but empty value denotes an
///     element capable of having children that's currently childless, such
///     as an empty directory in a file system. On the other hand, if the
///     property at the key path is `nil`, then the outline group treats the
///     data element as a leaf in the tree, like a regular file in a file
///     system.
///   - content: A view builder that produces a content view based on a
///     data element.
public init<DataElement>(_ root: DataElement, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement : Identifiable, DataElement == Data.Element
/// Creates an outline group from a collection of root data elements and
/// a key path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A view builder that produces a content view based on an
///     element in `data`.
public init<DataElement>(_ data: Data, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement : Identifiable, DataElement == Data.Element
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup where Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren> {
/// Creates an outline group from a root data element, the key path to its
/// identifier, and a key path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of a data element. A non-`nil` but empty value denotes an
///     element capable of having children that's currently childless, such
///     as an empty directory in a file system. On the other hand, if the
///     property at the key path is `nil`, then the outline group treats the
///     data element as a leaf in the tree, like a regular file in a file
///     system.
///   - content: A view builder that produces a content view based on a
///     data element.
public init<DataElement>(_ root: DataElement, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where DataElement == Data.Element
/// Creates an outline group from a collection of root data elements, the
/// key path to a data element's identifier, and a key path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A view builder that produces a content view based on an
///     element in `data`.
public init<DataElement>(_ data: Data, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where DataElement == Data.Element
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup : View where Parent : View, Leaf : View, Subgroup : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup where ID == Data.Element.ID, Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>, Data.Element : Identifiable {
/// Creates an outline group from a binding to a root data element and a key
/// path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of a data element. A non-`nil` but empty value denotes an
///     element capable of having children that's currently childless, such
///     as an empty directory in a file system. On the other hand, if the
///     property at the key path is `nil`, then the outline group treats the
///     data element as a leaf in the tree, like a regular file in a file
///     system.
///   - content: A view builder that produces a content view based on a
///     data element.
public init<C, E>(_ root: Binding<E>, children: WritableKeyPath<E, C?>, @ViewBuilder content: @escaping (Binding<E>) -> Leaf) where Data == Binding<C>, ID == E.ID, C : MutableCollection, C : RandomAccessCollection, E : Identifiable, E == C.Element
/// Creates an outline group from a binding to a collection of root data
/// elements and a key path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A view builder that produces a content view based on an
///     element in `data`.
public init<C, E>(_ data: Binding<C>, children: WritableKeyPath<E, C?>, @ViewBuilder content: @escaping (Binding<E>) -> Leaf) where Data == Binding<C>, ID == E.ID, C : MutableCollection, C : RandomAccessCollection, E : Identifiable, E == C.Element
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup where Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren> {
/// Creates an outline group from a binding to a root data element, the key
/// path to its identifier, and a key path to its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of a data element. A non-`nil` but empty value denotes an
///     element capable of having children that's currently childless, such
///     as an empty directory in a file system. On the other hand, if the
///     property at the key path is `nil`, then the outline group treats the
///     data element as a leaf in the tree, like a regular file in a file
///     system.
///   - content: A view builder that produces a content view based on a
///     data element.
public init<C, E>(_ root: Binding<E>, id: KeyPath<E, ID>, children: WritableKeyPath<E, C?>, @ViewBuilder content: @escaping (Binding<E>) -> Leaf) where Data == Binding<C>, C : MutableCollection, C : RandomAccessCollection, E == C.Element
/// Creates an outline group from a binding to a collection of root data
/// elements, the key path to a data element's identifier, and a key path to
/// its children.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A view builder that produces a content view based on an
///     element in `data`.
public init<C, E>(_ data: Binding<C>, id: KeyPath<E, ID>, children: WritableKeyPath<E, C?>, @ViewBuilder content: @escaping (Binding<E>) -> Leaf) where Data == Binding<C>, C : MutableCollection, C : RandomAccessCollection, E == C.Element
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup where ID == Data.Element.ID, Parent : TableRowContent, Parent == Leaf, Leaf == Subgroup, Data.Element == Parent.TableRowValue {
/// Creates an outline group from a root data element and a key path to
/// its children.
///
/// This initializer provides a default `TableRowBuilder` using `TableRow`
/// for each data element.
///
/// This initializer creates an instance that uniquely identifies table rows
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
public init<DataElement>(_ root: DataElement, children: KeyPath<DataElement, Data?>) where ID == DataElement.ID, Parent == TableRow<DataElement>, Leaf == TableRow<DataElement>, Subgroup == TableRow<DataElement>, DataElement : Identifiable, DataElement == Data.Element
/// Creates an outline group from a collection of root data elements and
/// a key path to element's children.
///
/// This initializer provides a default `TableRowBuilder` using `TableRow`
/// for each data element.
///
/// This initializer creates an instance that uniquely identifies table rows
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
public init<DataElement>(_ data: Data, children: KeyPath<DataElement, Data?>) where ID == DataElement.ID, Parent == TableRow<DataElement>, Leaf == TableRow<DataElement>, Subgroup == TableRow<DataElement>, DataElement : Identifiable, DataElement == Data.Element
/// Creates an outline group from a root data element and a key path to
/// its children.
///
/// This initializer exposes `content` as a `TableRowBuilder` to allow
/// custom table row content for each data element.
///
/// This initializer creates an instance that uniquely identifies table rows
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A table row builder that produces a row based on an
///     element in `data`.
public init<DataElement>(_ root: DataElement, children: KeyPath<DataElement, Data?>, @TableRowBuilder<DataElement> content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement == Data.Element
/// Creates an outline group from a root data element, a key path to the its
/// identifier, as well as a key path to its children.
///
/// This initializer exposes `content` as a `TableRowBuilder` to allow
/// custom table row content for each data element.
///
/// This initializer creates an instance that uniquely identifies views
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// Make sure that the identifier of a data element only changes if you
/// mean to replace that element with a new element, one with a new
/// identity. If the ID of an element changes, then the content view
/// generated from that element will lose any current state and animations.
///
/// - Parameters:
///   - root: The root of a collection of tree-structured, identified
///     data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A view builder that produces a content view based on an
///    element in `data`.
public init<DataElement>(_ root: DataElement, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @TableRowBuilder<DataElement> content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement == Data.Element
/// Creates an outline group from a collection of root data elements and
/// a key path to element's children.
///
/// This initializer exposes `content` as a `TableRowBuilder` to allow
/// custom table row content for each data element.
///
/// This initializer creates an instance that uniquely identifies table rows
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A table row builder that produces a row based on an
///     element in `data`.
public init<DataElement>(_ data: Data, children: KeyPath<DataElement, Data?>, @TableRowBuilder<DataElement> content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement == Data.Element
/// Creates an outline group from a collection of root data elements, a key
/// path to the element's identifier, as well as a key path to element's
/// children.
///
/// This initializer exposes `content` as a `TableRowBuilder` to allow
/// custom table row content for each data element.
///
/// This initializer creates an instance that uniquely identifies table rows
/// across updates based on the identity of the underlying data element.
///
/// All generated disclosure groups begin in the collapsed state.
///
/// - Parameters:
///   - data: A collection of tree-structured, identified data.
///   - id: The key path to a data element's identifier.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`. A non-`nil` but empty value denotes an element
///     capable of having children that's currently childless, such as an
///     empty directory in a file system. On the other hand, if the property
///     at the key path is `nil`, then the outline group treats `data` as a
///     leaf in the tree, like a regular file in a file system.
///   - content: A table row builder that produces a row based on an
///     element in `data`.
public init<DataElement>(_ data: Data, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @TableRowBuilder<DataElement> content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement == Data.Element
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension OutlineGroup : TableRowContent where ID == Data.Element.ID, Parent : TableRowContent, Parent == Leaf, Leaf == Subgroup, Data.Element == Parent.TableRowValue {
/// The type of value represented by this table row content.
public typealias TableRowValue = Leaf.TableRowValue
/// The composition of content that comprise the table row content.
public var tableRowBody: some TableRowContent { get }
/// The type of content representing the body of this table row content.
public typealias TableRowBody = some TableRowContent
}
/// A type-erased view representing the children in an outline subgroup.
///
/// ``OutlineGroup`` uses this type as a generic constraint for the `Content`
/// of the ``DisclosureGroup`` instances it creates.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct OutlineSubgroupChildren : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// An index view style that places a page index view over its content.
///
/// You can also use ``IndexViewStyle/page`` to construct this style.
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *)
@available(macOS, unavailable)
public struct PageIndexViewStyle : IndexViewStyle {
/// The background style for the page index view.
public struct BackgroundDisplayMode : Sendable {
/// Background will use the default for the platform.
public static let automatic: PageIndexViewStyle.BackgroundDisplayMode
/// Background is only shown while the index view is interacted with.
@available(watchOS, unavailable)
public static let interactive: PageIndexViewStyle.BackgroundDisplayMode
/// Background is always displayed behind the page index view.
@available(watchOS, unavailable)
public static let always: PageIndexViewStyle.BackgroundDisplayMode
/// Background is never displayed behind the page index view.
public static let never: PageIndexViewStyle.BackgroundDisplayMode
}
/// Creates a page index view style.
///
/// - Parameter backgroundDisplayMode: The display mode of the background of any
/// page index views receiving this style
public init(backgroundDisplayMode: PageIndexViewStyle.BackgroundDisplayMode = .automatic)
}
/// A `TabViewStyle` that implements a paged scrolling `TabView`.
///
/// You can also use ``TabViewStyle/page`` or
/// ``TabViewStyle/page(indexDisplayMode:)`` to construct this style.
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
@available(macOS, unavailable)
public struct PageTabViewStyle : TabViewStyle {
/// A style for displaying the page index view
public struct IndexDisplayMode : Sendable {
/// Displays an index view when there are more than one page
public static let automatic: PageTabViewStyle.IndexDisplayMode
/// Always display an index view regardless of page count
@available(watchOS 8.0, *)
public static let always: PageTabViewStyle.IndexDisplayMode
/// Never display an index view
@available(watchOS 8.0, *)
public static let never: PageTabViewStyle.IndexDisplayMode
}
/// Creates a new `PageTabViewStyle` with an index display mode
public init(indexDisplayMode: PageTabViewStyle.IndexDisplayMode = .automatic)
}
/// The scroll behavior that aligns scroll targets to container-based geometry.
///
/// In the following example, every view in the lazy stack is flexible
/// in both directions and the scroll view settles to container-aligned
/// boundaries.
///
///     ScrollView {
///         LazyVStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 FullScreenItem(item)
///             }
///         }
///     }
///     .scrollTargetBehavior(.paging)
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct PagingScrollTargetBehavior : ScrollTargetBehavior {
/// Creates a paging scroll behavior.
public init()
/// Updates the proposed target that a scrollable view should scroll to.
///
/// The system calls this method in two main cases:
/// - When a scroll gesture ends, it calculates where it would naturally
///   scroll to using its deceleration rate. The system
///   provides this calculated value as the target of this method.
/// - When a scrollable view's size changes, it calculates where it should
///   be scrolled given the new size and provides this calculates value
///   as the target of this method.
///
/// You can implement this method to override the calculated target
/// which will have the scrollable view scroll to a different position
/// than it would otherwise.
public func updateTarget(_ target: inout ScrollTarget, context: PagingScrollTargetBehavior.TargetContext)
}
/// A control group style that presents its content as a palette.
///
/// Use ``ControlGroupStyle/palette`` to construct this style.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct PaletteControlGroupStyle : ControlGroupStyle {
/// Creates a palette control group style.
public init()
/// Creates a view representing the body of a control group.
///
/// - Parameter configuration: The properties of the control group instance
///   being created.
///
/// This method will be called for each instance of ``ControlGroup`` created
/// within a view hierarchy where this style is the current
/// `ControlGroupStyle`.
@MainActor public func makeBody(configuration: PaletteControlGroupStyle.Configuration) -> some View
/// A view representing the body of a control group.
public typealias Body = some View
}
/// A picker style that presents the options as a row of compact elements.
///
/// You can also use ``PickerStyle/palette`` to construct this style.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct PalettePickerStyle : PickerStyle {
/// Creates a palette picker style.
public init()
}
/// The selection effect to apply to a palette item.
///
/// You can configure the selection effect of a palette item by using the
/// ``View/paletteSelectionEffect(_:)`` view modifier.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct PaletteSelectionEffect : Sendable, Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: PaletteSelectionEffect, rhs: PaletteSelectionEffect) -> Bool
/// Applies the system's default effect when selected.
///
/// When using un-tinted SF Symbols or template images, the current tint
/// color is applied to the selected items' image.
/// If the provided SF Symbols have custom tints, a stroke is drawn around selected items.
public static var automatic: PaletteSelectionEffect
/// Applies the specified symbol variant when selected.
///
/// - Note: This effect only applies to SF Symbols.
public static func symbolVariant(_ variant: SymbolVariants) -> PaletteSelectionEffect
/// Does not apply any system effect when selected.
///
/// - Note: Make sure to manually implement a way to indicate selection when
/// using this case. For example, you could dynamically resolve the item's
/// image based on the selection state.
public static var custom: PaletteSelectionEffect
}
/// A system button that reads items from the pasteboard and delivers it to a
/// closure.
///
/// Use a paste button when you want to provide a button for pasting items from
/// the system pasteboard into your app. The system provides a button
/// appearance and label appropriate to the current environment. However, you
/// can use view modifiers like ``View/buttonBorderShape(_:)``,
/// ``View/labelStyle(_:)``, and ``View/tint(_:)-93mfq`` to customize the button
/// in some contexts.
///
/// You declare what type of items your app will accept; use a type that
/// conforms to the
/// <doc://com.apple.documentation/documentation/coretransferable/transferable>
/// protocol. When the user taps or clicks the button, your closure receives the
/// pasteboard items in the specified type.
///
/// In the following example, a paste button declares that it accepts a string.
/// When the user taps or clicks the button, the sample's closure receives an
/// array of strings and sets the first as the value of `pastedText`, which
/// updates a nearby ``Text`` view.
///
///     @State private var pastedText: String = ""
///
///     var body: some View {
///         HStack {
///             PasteButton(payloadType: String.self) { strings in
///                 pastedText = strings[0]
///             }
///             Divider()
///             Text(pastedText)
///             Spacer()
///         }
///     }
///
/// ![macOS window titled PasteButton Demo showing (from left to right) a button
/// labeled Paste, a vertical divider, and some pasted
/// text.](SwiftUI-PasteButton-pastedText.png)
///
/// A paste button automatically validates and invalidates based on changes to
/// the pasteboard on iOS, but not on macOS.
@available(iOS 16.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public struct PasteButton : View {
/// Creates a Paste button that accepts specific types of data from the
/// pasteboard.
///
/// Set the contents of `supportedContentTypes` in order of your app's
/// preference for its supported types. The Paste button takes the
/// most-preferred type that the pasteboard source supports and delivers
/// this to the `payloadAction` closure.
///
/// - Parameters:
///   - supportedContentTypes: The exact uniform type identifiers supported
///     by the button. If the pasteboard doesn't contain any of the
///     supported types, the button becomes disabled.
///   - payloadAction: The handler to call when the user clicks the Paste
///     button and the pasteboard has items that conform to
///     `supportedContentTypes`. This closure receives an array of
///     item providers that you use to inspect and load the pasteboard data.
@available(iOS 16.0, macOS 11.0, *)
@MainActor public init(supportedContentTypes: [UTType], payloadAction: @escaping ([NSItemProvider]) -> Void)
/// Creates an instance that accepts values of the specified type.
/// - Parameters:
///   - type: The type that you want to paste via the `PasteButton`.
///   - onPaste: The handler to call on trigger of the button with at least
///     one item of the specified `Transferable` type from the pasteboard.
@available(iOS 16.0, macOS 13.0, *)
@MainActor public init<T>(payloadType: T.Type, onPaste: @escaping ([T]) -> Void) where T : Transferable
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// The outline of a 2D shape.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Path : Equatable, LosslessStringConvertible, @unchecked Sendable {
/// Creates an empty path.
public init()
/// Creates a path from an immutable shape path.
///
/// - Parameter path: The immutable CoreGraphics path to initialize
///   the new path from.
///
public init(_ path: CGPath)
/// Creates a path from a copy of a mutable shape path.
///
/// - Parameter path: The CoreGraphics path to initialize the new
///   path from.
///
public init(_ path: CGMutablePath)
/// Creates a path containing a rectangle.
///
/// This is a convenience function that creates a path of a
/// rectangle. Using this convenience function is more efficient
/// than creating a path and adding a rectangle to it.
///
/// Calling this function is equivalent to using `minX` and related
/// properties to find the corners of the rectangle, then using the
/// `move(to:)`, `addLine(to:)`, and `closeSubpath()` functions to
/// add the rectangle.
///
/// - Parameter rect: The rectangle to add.
///
public init(_ rect: CGRect)
/// Creates a path containing a rounded rectangle.
///
/// This is a convenience function that creates a path of a rounded
/// rectangle. Using this convenience function is more efficient
/// than creating a path and adding a rounded rectangle to it.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - cornerSize: The size of the corners, specified in user space
///     coordinates.
///   - style: The corner style. Defaults to the `continous` style
///     if not specified.
///
public init(roundedRect rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .continuous)
/// Creates a path containing a rounded rectangle.
///
/// This is a convenience function that creates a path of a rounded
/// rectangle. Using this convenience function is more efficient
/// than creating a path and adding a rounded rectangle to it.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - cornerRadius: The radius of all corners of the rectangle,
///     specified in user space coordinates.
///   - style: The corner style. Defaults to the `continous` style
///     if not specified.
///
public init(roundedRect rect: CGRect, cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous)
/// Creates a path as the given rounded rectangle, which may have
/// uneven corner radii.
///
/// This is a convenience function that creates a path of a rounded
/// rectangle. Using this function is more efficient than creating
/// a path and adding a rounded rectangle to it.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - cornerRadii: The radius of each corner of the rectangle,
///     specified in user space coordinates.
///   - style: The corner style. Defaults to the `continous` style
///     if not specified.
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init(roundedRect rect: CGRect, cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous)
/// Creates a path as an ellipse within the given rectangle.
///
/// This is a convenience function that creates a path of an
/// ellipse. Using this convenience function is more efficient than
/// creating a path and adding an ellipse to it.
///
/// The ellipse is approximated by a sequence of Bézier
/// curves. Its center is the midpoint of the rectangle defined by
/// the rect parameter. If the rectangle is square, then the
/// ellipse is circular with a radius equal to one-half the width
/// (or height) of the rectangle. If the rect parameter specifies a
/// rectangular shape, then the major and minor axes of the ellipse
/// are defined by the width and height of the rectangle.
///
/// The ellipse forms a complete subpath of the path—that
/// is, the ellipse drawing starts with a move-to operation and
/// ends with a close-subpath operation, with all moves oriented in
/// the clockwise direction. If you supply an affine transform,
/// then the constructed Bézier curves that define the
/// ellipse are transformed before they are added to the path.
///
/// - Parameter rect: The rectangle that bounds the ellipse.
///
public init(ellipseIn rect: CGRect)
/// Creates an empty path, then executes a closure to add its
/// initial elements.
///
/// - Parameter callback: The Swift function that will be called to
///   initialize the new path.
///
public init(_ callback: (inout Path) -> ())
/// Initializes from the result of a previous call to
/// `Path.stringRepresentation`. Fails if the `string` does not
/// describe a valid path.
public init?(_ string: String)
/// A description of the path that may be used to recreate the path
/// via `init?(_:)`.
public var description: String { get }
/// An immutable path representing the elements in the path.
public var cgPath: CGPath { get }
/// A Boolean value indicating whether the path contains zero elements.
public var isEmpty: Bool { get }
/// A rectangle containing all path segments.
///
/// This is the smallest rectangle completely enclosing all points
/// in the path but not including control points for Bézier
/// curves.
public var boundingRect: CGRect { get }
/// Returns true if the path contains a specified point.
///
/// If `eoFill` is true, this method uses the even-odd rule to define which
/// points are inside the path. Otherwise, it uses the non-zero rule.
public func contains(_ p: CGPoint, eoFill: Bool = false) -> Bool
/// An element of a path.
@frozen public enum Element : Equatable {
/// A path element that terminates the current subpath (without closing
/// it) and defines a new current point.
case move(to: CGPoint)
/// A line from the previous current point to the given point, which
/// becomes the new current point.
case line(to: CGPoint)
/// A quadratic Bézier curve from the previous current point to the
/// given end-point, using the single control point to define the curve.
///
/// The end-point of the curve becomes the new current point.
case quadCurve(to: CGPoint, control: CGPoint)
/// A cubic Bézier curve from the previous current point to the given
/// end-point, using the two control points to define the curve.
///
/// The end-point of the curve becomes the new current point.
case curve(to: CGPoint, control1: CGPoint, control2: CGPoint)
/// A line from the start point of the current subpath (if any) to the
/// current point, which terminates the subpath.
///
/// After closing the subpath, the current point becomes undefined.
case closeSubpath
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Path.Element, b: Path.Element) -> Bool
}
/// Calls `body` with each element in the path.
public func forEach(_ body: (Path.Element) -> Void)
/// Returns a stroked copy of the path using `style` to define how the
/// stroked outline is created.
public func strokedPath(_ style: StrokeStyle) -> Path
/// Returns a partial copy of the path.
///
/// The returned path contains the region between `from` and `to`, both of
/// which must be fractions between zero and one defining points
/// linearly-interpolated along the path.
public func trimmedPath(from: CGFloat, to: CGFloat) -> Path
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Path, b: Path) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Path : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in _: CGRect) -> Path
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Path {
/// Begins a new subpath at the specified point.
///
/// The specified point becomes the start point of a new subpath.
/// The current point is set to this start point.
///
/// - Parameter end: The point, in user space coordinates, at which
///   to start a new subpath.
///
public mutating func move(to end: CGPoint)
/// Appends a straight line segment from the current point to the
/// specified point.
///
/// After adding the line segment, the current point is set to the
/// endpoint of the line segment.
///
/// - Parameter end: The location, in user space coordinates, for the
///   end of the new line segment.
///
public mutating func addLine(to end: CGPoint)
///     the curve.
///   - control: The control point of the curve, in user space
///     coordinates.
///
public mutating func addQuadCurve(to end: CGPoint, control: CGPoint)
///     the curve.
///   - control1: The first control point of the curve, in user
///     space coordinates.
///   - control2: The second control point of the curve, in user
///     space coordinates.
///
public mutating func addCurve(to end: CGPoint, control1: CGPoint, control2: CGPoint)
/// Closes and completes the current subpath.
///
/// Appends a line from the current point to the starting point of
/// the current subpath and ends the subpath.
///
/// After closing the subpath, your application can begin a new
/// subpath without first calling `move(to:)`. In this case, a new
/// subpath is implicitly created with a starting and current point
/// equal to the previous subpath's starting point.
///
public mutating func closeSubpath()
/// Adds a rectangular subpath to the path.
///
/// This is a convenience function that adds a rectangle to a path,
/// starting by moving to the bottom-left corner and then adding
/// lines counter-clockwise to create a rectangle, closing the
/// subpath.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - transform: An affine transform to apply to the rectangle
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
public mutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity)
/// Adds a rounded rectangle to the path.
///
/// This is a convenience function that adds a rounded rectangle to
/// a path, starting by moving to the center of the right edge and
/// then adding lines and curves counter-clockwise to create a
/// rounded rectangle, closing the subpath.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - cornerSize: The size of the corners, specified in user space
///     coordinates.
///   - style: The corner style. Defaults to the `continous` style
///     if not specified.
///   - transform: An affine transform to apply to the rectangle
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
public mutating func addRoundedRect(in rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .continuous, transform: CGAffineTransform = .identity)
/// Adds a rounded rectangle with uneven corners to the path.
///
/// This is a convenience function that adds a rounded rectangle to
/// a path, starting by moving to the center of the right edge and
/// then adding lines and curves counter-clockwise to create a
/// rounded rectangle, closing the subpath.
///
/// - Parameters:
///   - rect: A rectangle, specified in user space coordinates.
///   - cornerRadii: The radius of each corner of the rectangle,
///     specified in user space coordinates.
///   - style: The corner style. Defaults to the `continous` style
///     if not specified.
///   - transform: An affine transform to apply to the rectangle
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public mutating func addRoundedRect(in rect: CGRect, cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous, transform: CGAffineTransform = .identity)
/// Adds an ellipse that fits inside the specified rectangle to the
/// path.
///
/// The ellipse is approximated by a sequence of Bézier
/// curves. Its center is the midpoint of the rectangle defined by
/// the `rect` parameter. If the rectangle is square, then the
/// ellipse is circular with a radius equal to one-half the width
/// (or height) of the rectangle. If the `rect` parameter specifies
/// a rectangular shape, then the major and minor axes of the
/// ellipse are defined by the width and height of the rectangle.
///
/// The ellipse forms a complete subpath of the path—
/// that is, the ellipse drawing starts with a move-to operation
/// and ends with a close-subpath operation, with all moves
/// oriented in the clockwise direction.
///
/// - Parameter:
///   - rect: A rectangle that defines the area for the ellipse to
///     fit in.
///   - transform: An affine transform to apply to the ellipse
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
public mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity)
/// Adds a set of rectangular subpaths to the path.
///
/// Calling this convenience method is equivalent to repeatedly
/// calling the `addRect(_:transform:)` method for each rectangle
/// in the array.
///
/// - Parameter:
///   - rects: An array of rectangles, specified in user space
///     coordinates.
///   - transform: An affine transform to apply to the ellipse
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
public mutating func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity)
/// Adds a sequence of connected straight-line segments to the path.
///
/// Calling this convenience method is equivalent to applying the
/// transform to all points in the array, then calling the
/// `move(to:)` method with the first value in the `points` array,
/// then calling the `addLine(to:)` method for each subsequent
/// point until the array is exhausted. After calling this method,
/// the path's current point is the last point in the array.
///
/// - Parameter:
///   - lines: An array of values that specify the start and end
///     points of the line segments to draw. Each point in the
///     array specifies a position in user space. The first point
///     in the array specifies the initial starting point.
///   - transform: An affine transform to apply to the points
///     before adding to the path. Defaults to the identity
///     transform if not specified.
///
public mutating func addLines(_ lines: [CGPoint])
/// Adds an arc of a circle to the path, specified with a radius
/// and a difference in angle.
///
/// This method calculates starting and ending points using the
/// radius and angles you specify, uses a sequence of cubic
/// Bézier curves to approximate a segment of a circle
/// between those points, and then appends those curves to the
/// path.
///
/// The `delta` parameter determines both the length of the arc the
/// direction in which the arc is created; the actual direction of
/// the final path is dependent on the `transform` parameter and
/// the current transform of a context where the path is drawn.
/// However, because SwiftUI by default uses a vertically-flipped
/// coordinate system (with the origin in the top-left of the
/// view), specifying a clockwise arc results in a counterclockwise
/// arc after the transformation is applied.
///
/// If the path ends with an unclosed subpath, this method adds a
/// line connecting the current point to the starting point of the
/// arc. If there is no unclosed subpath, this method creates a new
/// subpath whose starting point is the starting point of the arc.
/// The ending point of the arc becomes the new current point of
/// the path.
///
/// - Parameters:
///   - center: The center of the arc, in user space coordinates.
///   - radius: The radius of the arc, in user space coordinates.
///   - startAngle: The angle to the starting point of the arc,
///     measured from the positive x-axis.
///   - delta: The difference between the starting angle and ending
///     angle of the arc. A positive value creates a counter-
///     clockwise arc (in user space coordinates), and vice versa.
///   - transform: An affine transform to apply to the arc before
///     adding to the path. Defaults to the identity transform if
///     not specified.
////
public mutating func addRelativeArc(center: CGPoint, radius: CGFloat, startAngle: Angle, delta: Angle, transform: CGAffineTransform = .identity)
/// Adds an arc of a circle to the path, specified with a radius
/// and angles.
///
/// This method calculates starting and ending points using the
/// radius and angles you specify, uses a sequence of cubic
/// Bézier curves to approximate a segment of a circle
/// between those points, and then appends those curves to the
/// path.
///
/// The `clockwise` parameter determines the direction in which the
/// arc is created; the actual direction of the final path is
/// dependent on the `transform` parameter and the current
/// transform of a context where the path is drawn. However,
/// because SwiftUI by default uses a vertically-flipped coordinate
/// system (with the origin in the top-left of the view),
/// specifying a clockwise arc results in a counterclockwise arc
/// after the transformation is applied.
///
/// If the path ends with an unclosed subpath, this method adds a
/// line connecting the current point to the starting point of the
/// arc. If there is no unclosed subpath, this method creates a new
/// subpath whose starting point is the starting point of the arc.
/// The ending point of the arc becomes the new current point of
/// the path.
///
/// - Parameters:
///   - center: The center of the arc, in user space coordinates.
///   - radius: The radius of the arc, in user space coordinates.
///   - startAngle: The angle to the starting point of the arc,
///     measured from the positive x-axis.
///   - endAngle: The angle to the end point of the arc, measured
///     from the positive x-axis.
///   - clockwise: true to make a clockwise arc; false to make a
///     counterclockwise arc.
///   - transform: An affine transform to apply to the arc before
///     adding to the path. Defaults to the identity transform if
///     not specified.
///
public mutating func addArc(center: CGPoint, radius: CGFloat, startAngle: Angle, endAngle: Angle, clockwise: Bool, transform: CGAffineTransform = .identity)
/// Adds an arc of a circle to the path, specified with a radius
/// and two tangent lines.
///
/// This method calculates two tangent lines—the first
/// from the current point to the tangent1End point, and the second
/// from the `tangent1End` point to the `tangent2End`
/// point—then calculates the start and end points for a
/// circular arc of the specified radius such that the arc is
/// tangent to both lines. Finally, this method approximates that
/// arc with a sequence of cubic Bézier curves and appends
/// those curves to the path.
///
/// If the starting point of the arc (that is, the point where a
/// circle of the specified radius must meet the first tangent line
/// in order to also be tangent to the second line) is not the
/// current point, this method appends a straight line segment from
/// the current point to the starting point of the arc.
///
/// The ending point of the arc (that is, the point where a circle
/// of the specified radius must meet the second tangent line in
/// order to also be tangent to the first line) becomes the new
/// current point of the path.
///
/// - Parameters:
///   - tangent1End:The end point, in user space coordinates, for
///     the first tangent line to be used in constructing the arc.
///     (The start point for this tangent line is the path's
///     current point.)
///   - tangent2End: The end point, in user space coordinates, for
///     the second tangent line to be used in constructing the arc.
///     (The start point for this tangent line is the tangent1End
///     point.)
///   - radius: The radius of the arc, in user space coordinates.
///   - transform: An affine transform to apply to the arc before
///     adding to the path. Defaults to the identity transform if
///     not specified.
///
public mutating func addArc(tangent1End: CGPoint, tangent2End: CGPoint, radius: CGFloat, transform: CGAffineTransform = .identity)
/// Appends another path value to this path.
///
/// If the `path` parameter is a non-empty empty path, its elements
/// are appended in order to this path. Afterward, the start point
/// and current point of this path are those of the last subpath in
/// the `path` parameter.
///
/// - Parameters:
///   - path: The path to add.
///   - transform: An affine transform to apply to the path
///     parameter before adding to this path. Defaults to the
///     identity transform if not specified.
///
public mutating func addPath(_ path: Path, transform: CGAffineTransform = .identity)
/// Returns the last point in the path, or nil if the path contains
/// no points.
public var currentPoint: CGPoint? { get }
/// Returns a new weakly-simple copy of this path.
///
/// - Parameters:
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The returned path is a weakly-simple path, has no
/// self-intersections, and has a normalized orientation. The
/// result of filling this path using either even-odd or non-zero
/// fill rules is identical.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func normalized(eoFill: Bool = true) -> Path
/// Returns a new path with filled regions common to both paths.
///
/// - Parameters:
///   - other: The path to intersect.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The filled region of the resulting path is the overlapping area
/// of the filled region of both paths.  This can be used to clip
/// the fill of a path to a mask.
///
/// Any unclosed subpaths in either path are assumed to be closed.
/// The result of filling this path using either even-odd or
/// non-zero fill rules is identical.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func intersection(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a new path with filled regions in either this path or
/// the given path.
///
/// - Parameters:
///   - other: The path to union.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The filled region of resulting path is the combination of the
/// filled region of both paths added together.
///
/// Any unclosed subpaths in either path are assumed to be closed.
/// The result of filling this path using either even-odd or
/// non-zero fill rules is identical.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func union(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a new path with filled regions from this path that are
/// not in the given path.
///
/// - Parameters:
///   - other: The path to subtract.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The filled region of the resulting path is the filled region of
/// this path with the filled region `other` removed from it.
///
/// Any unclosed subpaths in either path are assumed to be closed.
/// The result of filling this path using either even-odd or
/// non-zero fill rules is identical.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func subtracting(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a new path with filled regions either from this path or
/// the given path, but not in both.
///
/// - Parameters:
///   - other: The path to difference.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The filled region of the resulting path is the filled region
/// contained in either this path or `other`, but not both.
///
/// Any unclosed subpaths in either path are assumed to be closed.
/// The result of filling this path using either even-odd or
/// non-zero fill rules is identical.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func symmetricDifference(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a new path with a line from this path that overlaps the
/// filled regions of the given path.
///
/// - Parameters:
///   - other: The path to intersect.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The line of the resulting path is the line of this path that
/// overlaps the filled region of `other`.
///
/// Intersected subpaths that are clipped create open subpaths.
/// Closed subpaths that do not intersect `other` remain closed.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func lineIntersection(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a new path with a line from this path that does not
/// overlap the filled region of the given path.
///
/// - Parameters:
///   - other: The path to subtract.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the paths (if true),
///       or the non-zero rule (if false).
/// - Returns: A new path.
///
/// The line of the resulting path is the line of this path that
/// does not overlap the filled region of `other`.
///
/// Intersected subpaths that are clipped create open subpaths.
/// Closed subpaths that do not intersect `other` remain closed.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func lineSubtraction(_ other: Path, eoFill: Bool = false) -> Path
/// Returns a path constructed by applying the transform to all
/// points of the path.
///
/// - Parameter transform: An affine transform to apply to the path.
///
/// - Returns: a new copy of the path with the transform applied to
///   all points.
///
public func applying(_ transform: CGAffineTransform) -> Path
/// Returns a path constructed by translating all its points.
///
/// - Parameters:
///   - dx: The offset to apply in the horizontal axis.
///   - dy: The offset to apply in the vertical axis.
///
/// - Returns: a new copy of the path with the offset applied to
///   all points.
///
public func offsetBy(dx: CGFloat, dy: CGFloat) -> Path
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Path.Element : Sendable {
}
/// A schedule for updating a timeline view at regular intervals.
///
/// You can also use ``TimelineSchedule/periodic(from:by:)`` to construct this
/// schedule.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct PeriodicTimelineSchedule : TimelineSchedule, Sendable {
/// The sequence of dates in periodic schedule.
///
/// The ``PeriodicTimelineSchedule/entries(from:mode:)`` method returns
/// a value of this type, which is a
/// <doc://com.apple.documentation/documentation/Swift/Sequence>
/// of periodic dates in ascending order. A ``TimelineView`` that you
/// create updates its content at the moments in time corresponding to the
/// dates included in the sequence.
public struct Entries : Sequence, IteratorProtocol, Sendable {
/// Advances to the next element and returns it, or `nil` if no next element
/// exists.
///
/// Repeatedly calling this method returns, in order, all the elements of the
/// underlying sequence. As soon as the sequence has run out of elements, all
/// subsequent calls return `nil`.
///
/// You must not call this method if any other copy of this iterator has been
/// advanced with a call to its `next()` method.
///
/// The following example shows how an iterator can be used explicitly to
/// emulate a `for`-`in` loop. First, retrieve a sequence's iterator, and
/// then call the iterator's `next()` method until it returns `nil`.
///
///     let numbers = [2, 3, 5, 7]
///     var numbersIterator = numbers.makeIterator()
///
///     while let num = numbersIterator.next() {
///         print(num)
///     }
///     // Prints "2"
///     // Prints "3"
///     // Prints "5"
///     // Prints "7"
///
/// - Returns: The next element in the underlying sequence, if a next element
///   exists; otherwise, `nil`.
public mutating func next() -> Date?
/// A type representing the sequence's elements.
public typealias Element = Date
/// A type that provides the sequence's iteration interface and
/// encapsulates its iteration state.
public typealias Iterator = PeriodicTimelineSchedule.Entries
}
/// Creates a periodic update schedule.
///
/// Use the ``PeriodicTimelineSchedule/entries(from:mode:)`` method
/// to get the sequence of dates.
///
/// - Parameters:
///   - startDate: The date on which to start the sequence.
///   - interval: The time interval between successive sequence entries.
public init(from startDate: Date, by interval: TimeInterval)
/// Provides a sequence of periodic dates starting from around a given date.
///
/// A ``TimelineView`` that you create with a schedule calls this method
/// to ask the schedule when to update its content. The method returns
/// a sequence of equally spaced dates in increasing order that represent
/// points in time when the timeline view should update.
///
/// The schedule defines its periodicity and phase aligment based on the
/// parameters you pass to its ``init(from:by:)`` initializer.
/// For example, for a `startDate` and `interval` of `10:09:30` and
/// `60` seconds, the schedule prepares to issue dates half past each
/// minute. The `startDate` that you pass to the `entries(from:mode:)`
/// method then dictates the first date of the sequence as the beginning of
/// the interval that the start date overlaps. Continuing the example above,
/// a start date of `10:34:45` causes the first sequence entry to be
/// `10:34:30`, because that's the start of the interval in which the
/// start date appears.
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> PeriodicTimelineSchedule.Entries
}
/// A container that animates its content by automatically cycling through
/// a collection of phases that you provide, each defining a discrete step
/// within an animation.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct PhaseAnimator<Phase, Content> : View where Phase : Equatable, Content : View {
/// Cycles through the given phases when the trigger value changes,
/// updating the view builder closure that you supply.
///
/// The phases that you provide specify the individual values that will
/// be animated to when the trigger value changes.
///
/// When the view first appears, the value from the first phase is provided
/// to the `content` closure. When the trigger value changes, the content
/// closure is called with the value from the second phase and its
/// corresponding animation. This continues until the last phase is
/// reached, after which the first phase is animated to.
///
/// - Parameters:
///   - phases: Phases defining the states that will be cycled through.
///     This sequence must not be empty. If an empty sequence is provided,
///     a visual warning will be displayed in place of this view, and a
///     warning will be logged.
///   - trigger: A value to observe for changes.
///   - content: A view builder closure.
///   - animation: A closure that returns the animation to use when
///     transitioning to the next phase. If `nil` is returned, the
///     transition will not be animated.
public init(_ phases: some Sequence<Phase>, trigger: some Equatable, @ViewBuilder content: @escaping (Phase) -> Content, animation: @escaping (Phase) -> Animation? = { _ in .default })
/// Cycles through the given phases continuously, updating the content
/// using the view builder closure that you supply.
///
/// The phases that you provide define the individual values that will
/// be animated between.
///
/// When the view first appears, the the first phase is provided
/// to the `content` closure. The animator then immediately animates
/// to the second phase, using an animation returned from the `animation`
/// closure. This continues until the last phase is reached, after which
/// the animator loops back to the beginning.
///
/// - Parameters:
///   - phases: Phases defining the states that will be cycled through.
///     This sequence must not be empty. If an empty sequence is provided,
///     a visual warning will be displayed in place of this view, and a
///     warning will be logged.
///   - content: A view builder closure.
///   - animation: A closure that returns the animation to use when
///     transitioning to the next phase. If `nil` is returned, the
///     transition will not be animated.
public init(_ phases: some Sequence<Phase>, @ViewBuilder content: @escaping (Phase) -> Content, animation: @escaping (Phase) -> Animation? = { _ in .default })
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A control for selecting from a set of mutually exclusive values.
///
/// You create a picker by providing a selection binding, a label, and the
/// content for the picker to display. Set the `selection` parameter to a bound
/// property that provides the value to display as the current selection. Set
/// the label to a view that visually describes the purpose of selecting content
/// in the picker, and then provide the content for the picker to display.
///
/// For example, consider an enumeration of ice cream flavors and a ``State``
/// variable to hold the selected flavor:
///
///     enum Flavor: String, CaseIterable, Identifiable {
///         case chocolate, vanilla, strawberry
///         var id: Self { self }
///     }
///
///     @State private var selectedFlavor: Flavor = .chocolate
///
/// You can create a picker to select among the values by providing a label, a
/// binding to the current selection, and a collection of views for the picker's
/// content. Append a tag to each of these content views using the
/// ``View/tag(_:)`` view modifier so that the type of each selection matches
/// the type of the bound state variable:
///
///     List {
///         Picker("Flavor", selection: $selectedFlavor) {
///             Text("Chocolate").tag(Flavor.chocolate)
///             Text("Vanilla").tag(Flavor.vanilla)
///             Text("Strawberry").tag(Flavor.strawberry)
///         }
///     }
///
/// If you provide a string label for the picker, as the example above does,
/// the picker uses it to initialize a ``Text`` view as a
/// label. Alternatively, you can use the ``init(selection:content:label:)``
/// initializer to compose the label from other views. The exact appearance
/// of the picker depends on the context. If you use a picker in a ``List``
/// in iOS, it appears in a row with the label and selected value, and a
/// chevron to indicate that you can tap the row to select a new value:
///
/// ![A screenshot of a list row that has the string Flavor on the left side,
/// and the string Chocolate on the right. The word Chocolate appears in a less
/// prominent color than the word Flavor. A right facing chevron appears to the
/// right of the word Chocolate.](Picker-1-iOS)
///
/// ### Iterating over a picker’s options
///
/// To provide selection values for the `Picker` without explicitly listing
/// each option, you can create the picker with a ``ForEach``:
///
///     Picker("Flavor", selection: $selectedFlavor) {
///         ForEach(Flavor.allCases) { flavor in
///             Text(flavor.rawValue.capitalized)
///         }
///     }
///
/// ``ForEach`` automatically assigns a tag to the selection views using
/// each option's `id`. This is possible because `Flavor` conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>
/// protocol.
///
/// The example above relies on the fact that `Flavor` defines the type of its
/// `id` parameter to exactly match the selection type. If that's not the case,
/// you need to override the tag. For example, consider a `Topping` type
/// and a suggested topping for each flavor:
///
///     enum Topping: String, CaseIterable, Identifiable {
///         case nuts, cookies, blueberries
///         var id: Self { self }
///     }
///
///     extension Flavor {
///         var suggestedTopping: Topping {
///             switch self {
///             case .chocolate: return .nuts
///             case .vanilla: return .cookies
///             case .strawberry: return .blueberries
///             }
///         }
///     }
///
///     @State private var suggestedTopping: Topping = .nuts
///
/// The following example shows a picker that's bound to a `Topping` type,
/// while the options are all `Flavor` instances. Each option uses the tag
/// modifier to associate the suggested topping with the flavor it displays:
///
///     List {
///         Picker("Flavor", selection: $suggestedTopping) {
///             ForEach(Flavor.allCases) { flavor in
///                 Text(flavor.rawValue.capitalized)
///                     .tag(flavor.suggestedTopping)
///             }
///         }
///         HStack {
///             Text("Suggested Topping")
///             Spacer()
///             Text(suggestedTopping.rawValue.capitalized)
///                 .foregroundStyle(.secondary)
///         }
///     }
///
/// When the user selects chocolate, the picker sets `suggestedTopping`
/// to the value in the associated tag:
///
/// ![A screenshot of two list rows. The first has the string Flavor on the left
/// side, and the string Chocolate on the right. A right facing chevron appears
/// to the right of the word Chocolate. The second row has the string Suggested
/// Topping on the left, and the string Nuts on the right. Both words on the
/// right use a less prominent color than those on the left.](Picker-2-iOS)
///
/// Other examples of when the views in a picker's ``ForEach`` need an explicit
/// tag modifier include when you:
/// * Select over the cases of an enumeration that conforms to the
///   <doc://com.apple.documentation/documentation/Swift/Identifiable> protocol
///   by using anything besides `Self` as the `id` parameter type. For example,
///   a string enumeration might use the case's `rawValue` string as the `id`.
///   That identifier type doesn't match the selection type, which is the type
///   of the enumeration itself.
/// * Use an optional value for the `selection` input parameter. For that to
///   work, you need to explicitly cast the tag modifier's input as
///   <doc://com.apple.documentation/documentation/Swift/Optional> to match.
///   For an example of this, see ``View/tag(_:)``.
///
/// ### Styling pickers
///
/// You can customize the appearance and interaction of pickers using
/// styles that conform to the ``PickerStyle`` protocol, like
/// ``PickerStyle/segmented`` or ``PickerStyle/menu``. To set a specific style
/// for all picker instances within a view, use the ``View/pickerStyle(_:)``
/// modifier. The following example applies the ``PickerStyle/segmented``
/// style to two pickers that independently select a flavor and a topping:
///
///     VStack {
///         Picker("Flavor", selection: $selectedFlavor) {
///             ForEach(Flavor.allCases) { flavor in
///                 Text(flavor.rawValue.capitalized)
///             }
///         }
///         Picker("Topping", selection: $selectedTopping) {
///             ForEach(Topping.allCases) { topping in
///                 Text(topping.rawValue.capitalized)
///             }
///         }
///     }
///     .pickerStyle(.segmented)
///
/// ![A screenshot of two segmented controls. The first has segments labeled
/// Chocolate, Vanilla, and Strawberry, with the first of these selected.
/// The second control has segments labeled Nuts, Cookies, and Blueberries,
/// with the second of these selected.](Picker-3-iOS)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Picker<Label, SelectionValue, Content> : View where Label : View, SelectionValue : Hashable, Content : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Picker {
/// Creates a picker that displays a custom label.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     } label: {
///         Text("Border Thickness")
///     }
///
/// - Parameters:
///     - sources: A collection of values used as the source for displaying
///       the Picker's selection.
///     - selection: The key path of the values that determines the
///       currently-selected options. When a user selects an option from the
///       picker, the values at the key path of all items in the `sources`
///       collection are updated with the selected option.
///     - content: A view that contains the set of options.
///     - label: A view that describes the purpose of selecting an option.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) where C : RandomAccessCollection
/// Creates a picker that displays a custom label.
///
/// - Parameters:
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - content: A view that contains the set of options.
///     - label: A view that describes the purpose of selecting an option.
public init(selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Picker where Label == Text {
/// Creates a picker that generates its label from a localized string key.
///
/// - Parameters:
///     - titleKey: A localized string key that describes the purpose of
///       selecting an option.
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// To initialize a picker with a string variable, use
/// ``init(_:selection:content:)-5njtq`` instead.
public init(_ titleKey: LocalizedStringKey, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content)
/// Creates a picker that generates its label from a localized string key.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///     - titleKey: A localized string key that describes the purpose of
///       selecting an option.
///     - sources: A collection of values used as the source for displaying
///       the Picker's selection.
///     - selection: The key path of the values that determines the
///       currently-selected options. When a user selects an option from the
///       picker, the values at the key path of all items in the `sources`
///       collection are updated with the selected option.
///     - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(_ titleKey: LocalizedStringKey, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection
/// Creates a picker that generates its label from a string.
///
/// - Parameters:
///     - title: A string that describes the purpose of selecting an option.
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// To initialize a picker with a localized string key, use
/// ``init(_:selection:content:)-6lwfn`` instead.
public init<S>(_ title: S, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a picker bound to a collection of bindings that generates its
/// label from a string.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///     - title: A string that describes the purpose of selecting an option.
///     - sources: A collection of values used as the source for displaying
///       the Picker's selection.
///     - selection: The key path of the values that determines the
///       currently-selected options. When a user selects an option from the
///       picker, the values at the key path of all items in the `sources`
///       collection are updated with the selected option.
///     - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more
/// information about localizing strings.
///
/// To initialize a picker with a localized string key, use
/// ``init(_:sources:selection:content:)-6e1x`` instead.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C, S>(_ title: S, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection, S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Picker where Label == Label<Text, Image> {
/// Creates a picker that generates its label from a localized string key
/// and system image.
///
/// - Parameters:
///     - titleKey: A localized string key that describes the purpose of
///       selecting an option.
///     - systemImage: The name of the image resource to lookup.
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// To initialize a picker with a string variable, use
/// ``init(_:selection:content:)-5njtq`` instead.
public init(_ titleKey: LocalizedStringKey, systemImage: String, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content)
/// Creates a picker that generates its label from a localized string key.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///     - titleKey: A localized string key that describes the purpose of
///       selecting an option.
///     - systemImage: The name of the image resource to lookup.
///     - sources: A collection of values used as the source for displaying
///       the Picker's selection.
///     - selection: The key path of the values that determines the
///       currently-selected options. When a user selects an option from the
///       picker, the values at the key path of all items in the `sources`
///       collection are updated with the selected option.
///     - content: A view that contains the set of options.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(_ titleKey: LocalizedStringKey, systemImage: String, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection, C.Element == Binding<SelectionValue>
/// Creates a picker that generates its label from a string and
/// system image.
///
/// - Parameters:
///     - title: A string that describes the purpose of selecting an option.
///     - systemImage: The name of the image resource to lookup.
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - content: A view that contains the set of options.
public init<S>(_ title: S, systemImage: String, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a picker bound to a collection of bindings that generates its
/// label from a string.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///     - title: A string that describes the purpose of selecting an option.
///     - systemImage: The name of the image resource to lookup.
///     - sources: A collection of values used as the source for displaying
///       the Picker's selection.
///     - selection: The key path of the values that determines the
///       currently-selected options. When a user selects an option from the
///       picker, the values at the key path of all items in the `sources`
///       collection are updated with the selected option.
///     - content: A view that contains the set of options.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C, S>(_ title: S, systemImage: String, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection, S : StringProtocol, C.Element == Binding<SelectionValue>
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Picker where Label == Label<Text, Image> {
/// Creates a picker that generates its label from a localized string key
/// and image resource
///
/// - Parameters:
///   - titleKey: A localized string key that describes the purpose of
///     selecting an option.
///   - image: The name of the image resource to lookup.
///   - selection: A binding to a property that determines the
///     currently-selected option.
///   - content: A view that contains the set of options.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// To initialize a picker with a string variable, use
/// ``init(_:selection:content:)-5njtq`` instead.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content)
/// Creates a picker that generates its label from a localized string key
/// and image resource.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///   - titleKey: A localized string key that describes the purpose of
///     selecting an option.
///   - image: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for displaying
///      he Picker's selection.
///   - selection: The key path of the values that determines the
///     currently-selected options. When a user selects an option from the
///     picker, the values at the key path of all items in the `sources`
///     collection are updated with the selected option.
///   - content: A view that contains the set of options.
public init<C>(_ titleKey: LocalizedStringKey, image: ImageResource, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection, C.Element == Binding<SelectionValue>
/// Creates a picker that generates its label from a string and
/// image resource.
///
/// - Parameters:
///   - title: A string that describes the purpose of selecting an option.
///   - systemImage: The name of the image resource to lookup.
///   - selection: A binding to a property that determines the
///     currently-selected option.
///   - content: A view that contains the set of options.
public init<S>(_ title: S, image: ImageResource, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a picker bound to a collection of bindings that generates its
/// label from a string and image resource.
///
/// If the wrapped values of the collection passed to `sources` are not all
/// the same, some styles render the selection in a mixed state. The
/// specific presentation depends on the style.  For example, a Picker
/// with a menu style uses dashes instead of checkmarks to indicate the
/// selected values.
///
/// In the following example, a picker in a document inspector controls the
/// thickness of borders for the currently-selected shapes, which can be of
/// any number.
///
///     enum Thickness: String, CaseIterable, Identifiable {
///         case thin
///         case regular
///         case thick
///
///         var id: String { rawValue }
///     }
///
///     struct Border {
///         var color: Color
///         var thickness: Thickness
///     }
///
///     @State private var selectedObjectBorders = [
///         Border(color: .black, thickness: .thin),
///         Border(color: .red, thickness: .thick)
///     ]
///
///     Picker(
///         "Border Thickness",
///         sources: $selectedObjectBorders,
///         selection: \.thickness
///     ) {
///         ForEach(Thickness.allCases) { thickness in
///             Text(thickness.rawValue)
///         }
///     }
///
/// - Parameters:
///   - title: A string that describes the purpose of selecting an option.
///   - image: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for displaying
///     the Picker's selection.
///   - selection: The key path of the values that determines the
///     currently-selected options. When a user selects an option from the
///     picker, the values at the key path of all items in the `sources`
///     collection are updated with the selected option.
///   - content: A view that contains the set of options.
public init<C, S>(_ title: S, image: ImageResource, sources: C, selection: KeyPath<C.Element, Binding<SelectionValue>>, @ViewBuilder content: () -> Content) where C : RandomAccessCollection, S : StringProtocol, C.Element == Binding<SelectionValue>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Picker {
/// Creates a picker that displays a custom label.
///
/// - Parameters:
///     - selection: A binding to a property that determines the
///       currently-selected option.
///     - label: A view that describes the purpose of selecting an option.
///     - content: A view that contains the set of options.
@available(iOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)")
@available(macOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)")
@available(tvOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)")
@available(watchOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)")
@available(visionOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)")
public init(selection: Binding<SelectionValue>, label: Label, @ViewBuilder content: () -> Content)
}
/// A type that specifies the appearance and interaction of all pickers within
/// a view hierarchy.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol PickerStyle {
}
@available(iOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
extension PickerStyle where Self == WheelPickerStyle {
/// A picker style that presents the options in a scrollable wheel that
/// shows the selected option and a few neighboring options.
///
/// Because most options aren't visible, organize them in a predictable
/// order, such as alphabetically.
///
/// To apply this style to a picker, or to a view that contains pickers, use
/// the ``View/pickerStyle(_:)`` modifier.
public static var wheel: WheelPickerStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension PickerStyle where Self == InlinePickerStyle {
/// A `PickerStyle` where each option is displayed inline with other views
/// in the current container.
public static var inline: InlinePickerStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PickerStyle where Self == DefaultPickerStyle {
/// The default picker style, based on the picker's context.
///
/// How a picker using the default picker style appears largely depends on
/// the platform and the view type in which it appears. For example, in a
/// standard view, the default picker styles by platform are:
///
/// * On iOS and watchOS the default is a wheel.
/// * On macOS, the default is a pop-up button.
/// * On tvOS, the default is a segmented control.
///
/// The default picker style may also take into account other factors — like
/// whether the picker appears in a container view — when setting the
/// appearance of a picker.
///
/// You can override a picker’s style. To apply the default style to a
/// picker, or to a view that contains pickers, use the
/// ``View/pickerStyle(_:)`` modifier.
public static var automatic: DefaultPickerStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@available(watchOS, unavailable)
extension PickerStyle where Self == SegmentedPickerStyle {
/// A picker style that presents the options in a segmented control.
///
/// Use this style when there are two to five options. Consider using
/// ``PickerStyle/menu`` when there are more than five options.
///
/// For each option's label, use sentence-style capitalization without
/// ending punctuation, like a period or colon.
///
/// To apply this style to a picker, or to a view that contains pickers, use
/// the ``View/pickerStyle(_:)`` modifier.
public static var segmented: SegmentedPickerStyle { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension PickerStyle where Self == PalettePickerStyle {
/// A picker style that presents the options as a row of compact elements.
///
/// - Note: When used outside of menus, this style is rendered as a
/// segmented picker. If that is the intended usage, consider
/// ``PickerStyle/segmented`` instead.
///
/// For each option's label, use one symbol per item, if you add more than 6 options, the picker scrolls horizontally on iOS.
///
/// The following example creates a palette picker:
///
///     enum Reaction: Identifiable, CaseIterable {
///         case thumbsup, thumbsdown, heart, questionMark
///         var id: Self { self }
///     }
///
///     @State private var selection: Reaction? = .none
///
///     var body: some View {
///         Menu("Reactions") {
///             Picker("Palette", selection: $selection) {
///                 Label("Thumbs up", systemImage: "hand.thumbsup")
///                     .tag(Reaction.thumbsup)
///                 Label("Thumbs down", systemImage: "hand.thumbsdown")
///                     .tag(Reaction.thumbsdown)
///                 Label("Like", systemImage: "heart")
///                     .tag(Reaction.heart)
///                 Label("Question mark", systemImage: "questionmark")
///                     .tag(Reaction.questionMark)
///             }
///             .pickerStyle(.palette)
///             Button("Reply...") { ... }
///         }
///     }
///
/// Palette pickers will display the selection of untinted SF Symbols or
/// template images by applying the system tint. For tinted SF Symbols, a
/// stroke is outlined around the symbol upon selection. If you would like
/// to supply a particular image (or SF Symbol) to signify selection, we
/// suggest using ``PaletteSelectionEffect/custom``.
/// This deactivates any system selection behavior, allowing the provided
/// image to solely indicate selection instead.
///
/// The following example creates a palette picker that disables the
/// system selection behaviour:
///
///     Menu {
///         Picker("Palettes", selection: $selection) {
///             ForEach(palettes) { palette in
///                 Label(palette.title, systemImage: selection == palette ?
///                       "circle.dashed.inset.filled" : "circle.fill")
///                 .tint(palette.tint)
///                 .tag(palette)
///             }
///         }
///         .pickerStyle(.palette)
///         .paletteSelectionEffect(.custom)
///     } label: {
///         ...
///     }
///
/// If a specific SF Symbol variant is preferable instead, use
/// ``PaletteSelectionEffect/symbolVariant(_:)``:
///
///     Menu {
///         Picker("Flags", selection: $selectedFlag) {
///             ForEach(flags) { flag in
///                 Label(flag.title, systemImage: "flag")
///                     .tint(flag.color)
///                     .tag(flag)
///             }
///         }
///         .pickerStyle(.palette)
///         .paletteSelectionEffect(.symbolVariant(.slash))
///     } label: {
///         ...
///     }
///
/// To apply this style to a picker, or to a view that contains pickers, use
/// the ``View/pickerStyle(_:)`` modifier.
public static var palette: PalettePickerStyle { get }
}
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@available(macOS, unavailable)
extension PickerStyle where Self == NavigationLinkPickerStyle {
/// A picker style represented by a navigation link that presents the options
/// by pushing a List-style picker view.
///
/// In navigation stacks, prefer the default ``PickerStyle/menu`` style.
/// Consider the navigation link style when you have a large number of
/// options or your design is better expressed by pushing onto a stack.
///
/// To apply this style to a picker, or to a view that contains pickers,
/// use the ``View/pickerStyle(_:)`` modifier.
public static var navigationLink: NavigationLinkPickerStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension PickerStyle where Self == MenuPickerStyle {
/// A picker style that presents the options as a menu when the user presses a
/// button, or as a submenu when nested within a larger menu.
///
/// Use this style when there are more than five options. Consider using
/// ``PickerStyle/inline`` when there are fewer than five options.
///
/// The button itself indicates the selected option. You can include additional
/// controls in the set of options, such as a button to customize the list of
/// options.
///
/// To apply this style to a picker, or to a view that contains pickers, use the
/// ``View/pickerStyle(_:)`` modifier.
public static var menu: MenuPickerStyle { get }
}
/// A set of view types that may be pinned to the bounds of a scroll view.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct PinnedScrollableViews : OptionSet, Sendable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt32
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: UInt32)
/// The header view of each `Section` will be pinned.
public static let sectionHeaders: PinnedScrollableViews
/// The footer view of each `Section` will be pinned.
public static let sectionFooters: PinnedScrollableViews
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = PinnedScrollableViews
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = PinnedScrollableViews
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt32
}
/// A placeholder used to construct an inline modifier, transition, or other
/// helper type.
///
/// You don't use this type directly. Instead SwiftUI creates this type on
/// your behalf.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct PlaceholderContentView<Value> : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A style appropriate for placeholder text.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct PlaceholderTextShapeStyle : ShapeStyle {
/// Creates a new placeholder text shape style.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A button style that doesn't style or decorate its content while idle, but
/// may apply a visual effect to indicate the pressed, focused, or enabled state
/// of the button.
///
/// You can also use ``PrimitiveButtonStyle/plain`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct PlainButtonStyle : PrimitiveButtonStyle {
/// Creates a plain button style.
public init()
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
public func makeBody(configuration: PlainButtonStyle.Configuration) -> some View
/// A view that represents the body of a button.
public typealias Body = some View
}
/// The list style that describes the behavior and appearance of a plain list.
///
/// You can also use ``ListStyle/plain`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct PlainListStyle : ListStyle {
/// Creates a plain list style.
public init()
}
/// A text editor style with no decoration.
///
/// You can also use ``TextEditorStyle/plain`` to create this style.
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct PlainTextEditorStyle : TextEditorStyle {
/// Creates a view that represents the body of a text editor.
///
/// The system calls this method for each ``TextEditor`` instance in a view
/// hierarchy where this style is the current text editor style.
///
/// - Parameter configuration: The properties of the text editor.
public func makeBody(configuration: PlainTextEditorStyle.Configuration) -> some View
public init()
/// A view that represents the body of a text editor.
public typealias Body = some View
}
/// A text field style with no decoration.
///
/// You can also use ``TextFieldStyle/plain`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct PlainTextFieldStyle : TextFieldStyle {
public init()
}
/// An attachment anchor for a popover.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum PopoverAttachmentAnchor {
/// The anchor point for the popover relative to the source's frame.
case rect(Anchor<CGRect>.Source)
/// The anchor point for the popover expressed as a unit point  that
/// describes possible alignments relative to a SwiftUI view.
case point(UnitPoint)
}
/// A named value produced by a view.
///
/// A view with multiple children automatically combines its values for a given
/// preference into a single value visible to its ancestors.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol PreferenceKey {
/// The type of value produced by this preference.
associatedtype Value
/// The default value of the preference.
///
/// Views that have no explicit value for the key produce this default
/// value. Combining child views may remove an implicit value produced by
/// using the default. This means that `reduce(value: &x, nextValue:
/// {defaultValue})` shouldn't change the meaning of `x`.
static var defaultValue: Self.Value { get }
/// Combines a sequence of values by modifying the previously-accumulated
/// value with the result of a closure that provides the next value.
///
/// This method receives its values in view-tree order. Conceptually, this
/// combines the preference value from one tree with that of its next
/// sibling.
///
/// - Parameters:
///   - value: The value accumulated through previous calls to this method.
///     The implementation should modify this value.
///   - nextValue: A closure that returns the next value in the sequence.
static func reduce(value: inout Self.Value, nextValue: () -> Self.Value)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PreferenceKey where Self.Value : ExpressibleByNilLiteral {
/// Let nil-expressible values default-initialize to nil.
public static var defaultValue: Self.Value { get }
}
/// A key for specifying the preferred color scheme.
///
/// Don't use this key directly. Instead, set a preferred color scheme for a
/// view using the ``View/preferredColorScheme(_:)`` view modifier. Get the
/// current color scheme for a view by accessing the
/// ``EnvironmentValues/colorScheme`` value.
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
public struct PreferredColorSchemeKey : PreferenceKey {
/// The type of value produced by this preference.
public typealias Value = ColorScheme?
/// Combines a sequence of values by modifying the previously-accumulated
/// value with the result of a closure that provides the next value.
///
/// This method receives its values in view-tree order. Conceptually, this
/// combines the preference value from one tree with that of its next
/// sibling.
///
/// - Parameters:
///   - value: The value accumulated through previous calls to this method.
///     The implementation should modify this value.
///   - nextValue: A closure that returns the next value in the sequence.
public static func reduce(value: inout PreferredColorSchemeKey.Value, nextValue: () -> PreferredColorSchemeKey.Value)
}
/// Strategies for adapting a presentation to a different size class.
///
/// Use values of this type with the ``View/presentationCompactAdaptation(_:)``
/// and ``View/presentationCompactAdaptation(horizontal:vertical:)`` modifiers.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct PresentationAdaptation : Sendable {
/// Use the default presentation adaptation.
public static var automatic: PresentationAdaptation { get }
/// Don't adapt for the size class, if possible.
public static var none: PresentationAdaptation { get }
/// Prefer a popover appearance when adapting for size classes.
public static var popover: PresentationAdaptation { get }
/// Prefer a sheet appearance when adapting for size classes.
public static var sheet: PresentationAdaptation { get }
/// Prefer a full-screen-cover appearance when adapting for size classes.
public static var fullScreenCover: PresentationAdaptation { get }
}
/// The kinds of interaction available to views behind a presentation.
///
/// Use values of this type with the
/// ``View/presentationBackgroundInteraction(_:)`` modifier.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct PresentationBackgroundInteraction : Sendable {
/// The default background interaction for the presentation.
public static var automatic: PresentationBackgroundInteraction { get }
/// People can interact with the view behind a presentation.
public static var enabled: PresentationBackgroundInteraction { get }
/// People can interact with the view behind a presentation up through a
/// specified detent.
///
/// At detents larger than the one you specify, SwiftUI disables
/// interaction.
///
/// - Parameter detent: The largest detent at which people can interact with
///   the view behind the presentation.
public static func enabled(upThrough detent: PresentationDetent) -> PresentationBackgroundInteraction
/// People can't interact with the view behind a presentation.
public static var disabled: PresentationBackgroundInteraction { get }
}
/// A behavior that you can use to influence how a presentation responds to
/// swipe gestures.
///
/// Use values of this type with the
/// ``View/presentationContentInteraction(_:)`` modifier.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct PresentationContentInteraction : Equatable, Sendable {
/// The default swipe behavior for the presentation.
public static var automatic: PresentationContentInteraction { get }
/// A behavior that prioritizes resizing a presentation when swiping, rather
/// than scrolling the content of the presentation.
public static var resizes: PresentationContentInteraction { get }
/// A behavior that prioritizes scrolling the content of a presentation when
/// swiping, rather than resizing the presentation.
public static var scrolls: PresentationContentInteraction { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: PresentationContentInteraction, b: PresentationContentInteraction) -> Bool
}
/// A type that represents a height where a sheet naturally rests.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct PresentationDetent : Hashable, Sendable {
/// The system detent for a sheet that's approximately half the height of
/// the screen, and is inactive in compact height.
public static let medium: PresentationDetent
/// The system detent for a sheet at full height.
public static let large: PresentationDetent
/// A custom detent with the specified fractional height.
public static func fraction(_ fraction: CGFloat) -> PresentationDetent
/// A custom detent with the specified height.
public static func height(_ height: CGFloat) -> PresentationDetent
/// A custom detent with a calculated height.
public static func custom<D>(_ type: D.Type) -> PresentationDetent where D : CustomPresentationDetent
/// Information that you use to calculate the presentation's height.
@dynamicMemberLookup public struct Context {
/// The height that the presentation appears in.
public var maxDetentValue: CGFloat { get }
/// Returns the value specified by the keyPath from the environment.
///
/// This uses the environment from where the sheet is shown, not the
/// environment where the presentation modifier is applied.
public subscript<T>(dynamicMember keyPath: KeyPath<EnvironmentValues, T>) -> T { get }
}
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: PresentationDetent, b: PresentationDetent) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// An indication whether a view is currently presented by another view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss")
public struct PresentationMode {
/// Indicates whether a view is currently presented.
public var isPresented: Bool { get }
/// Dismisses the view if it is currently presented.
///
/// If `isPresented` is false, `dismiss()` is a no-op.
public mutating func dismiss()
}
/// A view that represents the content of a presented window.
///
/// You don't create this type directly. ``WindowGroup`` creates values for you.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct PresentedWindowContent<Data, Content> : View where Data : Decodable, Data : Encodable, Data : Hashable, Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// Creates a preview of a SwiftUI view.
///
/// - Parameters:
///   - name: Optional display name for the preview, which appears in the canvas.
///   - traits: Trait customizing the appearance of the preview.
///   - additionalTraits: Optional additional traits.
///   - body: A closure producing a SwiftUI view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@freestanding(declaration) public macro Preview(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>, _ additionalTraits: PreviewTrait<Preview.ViewTraits>..., body: @escaping @MainActor () -> View) = #externalMacro(module: "PreviewsMacros", type: "SwiftUIView")
/// Creates a preview of a SwiftUI view.
///
/// - Parameters:
///   - name: Optional display name for the preview, which appears in the canvas.
///   - body: A closure producing a SwiftUI view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@freestanding(declaration) public macro Preview(_ name: String? = nil, body: @escaping @MainActor () -> View) = #externalMacro(module: "PreviewsMacros", type: "SwiftUIView")
/// A context type for use with a preview.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol PreviewContext {
/// Returns the context's value for a key, or a the key's default value
/// if the context doesn't define a value for the key.
subscript<Key>(key: Key.Type) -> Key.Value where Key : PreviewContextKey { get }
}
/// A key type for a preview context.
///
/// The default value is `nil`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol PreviewContextKey {
/// The type of the value returned by the key.
associatedtype Value
/// The default value of the key.
static var defaultValue: Self.Value { get }
}
/// A simulator device that runs a preview.
///
/// Create a preview device by name, like "iPhone X", or by model number,
/// like "iPad8,1". Use the device in a call to the ``View/previewDevice(_:)``
/// modifier to set a preview device that doesn't change when you change the
/// run destination in Xcode:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)"))
///         }
///     }
///
/// You can get a list of supported preview device names by using the
/// `xcrun` command in the Terminal app:
///
///     % xcrun simctl list devicetypes
///
/// Additionally, you can use the following values for macOS platform
/// development:
/// - "Mac"
/// - "Mac Catalyst"
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct PreviewDevice : RawRepresentable, ExpressibleByStringLiteral, Sendable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: String
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init(rawValue: String)
/// Creates an instance initialized to the given string value.
///
/// - Parameter value: The value of the new instance.
public init(stringLiteral: String)
/// A type that represents an extended grapheme cluster literal.
///
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`,
/// `String`, and `StaticString`.
public typealias ExtendedGraphemeClusterLiteralType = String
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = String
/// A type that represents a string literal.
///
/// Valid types for `StringLiteralType` are `String` and `StaticString`.
public typealias StringLiteralType = String
/// A type that represents a Unicode scalar literal.
///
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`,
/// `Character`, `String`, and `StaticString`.
public typealias UnicodeScalarLiteralType = String
}
/// Platforms that can run the preview.
///
/// Xcode infers the platform for a preview based on the currently
/// selected target. If you have a multiplatform target and want to
/// suggest a particular target for a preview, implement the
/// ``PreviewProvider/platform-75xu4`` computed property as a hint,
/// and specify one of the preview platforms:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///         }
///
///         static var platform: PreviewPlatform? {
///             PreviewPlatform.tvOS
///         }
///     }
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum PreviewPlatform : Sendable {
/// Specifies iOS as the preview platform.
case iOS
/// Specifies macOS as the preview platform.
case macOS
/// Specifies tvOS as the preview platform.
case tvOS
/// Specifies watchOS as the preview platform.
case watchOS
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: PreviewPlatform, b: PreviewPlatform) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PreviewPlatform : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PreviewPlatform : Hashable {
}
/// A type that produces view previews in Xcode.
///
/// Create an Xcode preview by declaring a structure that conforms to the
/// `PreviewProvider` protocol. Implement the required
/// ``PreviewProvider/previews-swift.type.property`` computed property,
/// and return the view to display:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///         }
///     }
///
/// Xcode statically discovers preview providers in your project and generates
/// previews for any providers currently open in the source editor.
/// Xcode generates the preview using the current run destination as a hint
/// for which device to display. For example, Xcode shows the following preview
/// if you've selected an iOS target to run on the iPhone 12 Pro Max simulator:
///
/// ![A screenshot of the Xcode canvas previewing a circular image on an
/// iPhone in the portrait orientation.](PreviewProvider-1)
///
/// When you create a new file (File > New > File)
/// and choose the SwiftUI view template, Xcode automatically inserts a
/// preview structure at the bottom of the file that you can configure.
/// You can also create new preview structures in an existing SwiftUI
/// view file by choosing Editor > Create Preview.
///
/// Customize the preview's appearance by adding view modifiers, just like you
/// do when building a custom ``View``. This includes preview-specific
/// modifiers that let you control aspects of the preview, like the device
/// orientation:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewInterfaceOrientation(.landscapeLeft)
///         }
///     }
///
/// ![A screenshot of the Xcode canvas previewing a circular image on an
/// iPhone in the landscape left orientation.](PreviewProvider-2)
///
/// For the complete list of preview customizations,
/// see <doc:Previews-in-Xcode>.
///
/// Xcode creates different previews for each view in your preview,
/// so you can see variations side by side. For example, you
/// might want to see a view's light and dark appearances simultaneously:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///             CircleImage()
///                 .preferredColorScheme(.dark)
///         }
///     }
///
/// Use a ``Group`` when you want to maintain different previews, but apply a
/// single modifier to all of them:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             Group {
///                 CircleImage()
///                 CircleImage()
///                     .preferredColorScheme(.dark)
///             }
///             .previewLayout(.sizeThatFits)
///         }
///     }
///
/// ![A screenshot of the Xcode canvas previewing a circular image twice,
/// once with a light appearance and once with a dark appearance. Both
/// previews take up only as much room as they need to fit the circular
/// image.](PreviewProvider-3)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@MainActor public protocol PreviewProvider : _PreviewProvider {
/// The type to preview.
///
/// When you create a preview, Swift infers this type from your
/// implementation of the required
/// ``PreviewProvider/previews-swift.type.property`` property.
associatedtype Previews : View
/// A collection of views to preview.
///
/// Implement a computed `previews` property to indicate the content to
/// preview. Xcode generates a preview for each view that you list. You
/// can apply ``View`` modifiers to the views, like you do
/// when creating a custom view. For a preview, you can also use
/// various preview-specific modifiers that customize the preview.
/// For example, you can choose a specific device for the preview
/// by adding the ``View/previewDevice(_:)`` modifier:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)"))
///         }
///     }
///
/// For the full list of preview-specific modifiers,
/// see <doc:Previews-in-Xcode>.
@ViewBuilder @MainActor static var previews: Self.Previews { get }
/// The platform on which to run the provider.
///
/// Xcode infers the platform for a preview based on the currently
/// selected target. If you have a multiplatform target and want to
/// suggest a particular target for a preview, implement the
/// `platform` computed property to provide a hint,
/// and specify one of the ``PreviewPlatform`` values:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///         }
///
///         static var platform: PreviewPlatform? {
///             PreviewPlatform.tvOS
///         }
///     }
///
/// Xcode ignores this value unless you have a multiplatform target.
@MainActor static var platform: PreviewPlatform? { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PreviewProvider {
/// The platform to run the provider on.
///
/// This default implementation of the ``PreviewProvider/platform-75xu4``
/// computed property returns `nil`. Rely on this implementation unless
/// you have a multiplatform target and want to suggest a particular
/// platform for a preview.
@MainActor public static var platform: PreviewPlatform? { get }
}
/// A type that applies custom interaction behavior and a custom appearance to
/// all buttons within a view hierarchy.
///
/// To configure the current button style for a view hierarchy, use the
/// ``View/buttonStyle(_:)-66fbx`` modifier. Specify a style that conforms to
/// `PrimitiveButtonStyle` to create a button with custom interaction
/// behavior. To create a button with the standard button interaction behavior
/// defined for each platform, use ``ButtonStyle`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol PrimitiveButtonStyle {
/// A view that represents the body of a button.
associatedtype Body : View
/// Creates a view that represents the body of a button.
///
/// The system calls this method for each ``Button`` instance in a view
/// hierarchy where this style is the current button style.
///
/// - Parameter configuration : The properties of the button.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a button.
typealias Configuration = PrimitiveButtonStyleConfiguration
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PrimitiveButtonStyle where Self == DefaultButtonStyle {
/// The default button style, based on the button's context.
///
/// If you create a button directly on a blank canvas, the style varies by
/// platform. iOS uses the borderless button style by default, whereas macOS,
/// tvOS, and watchOS use the bordered button style.
///
/// If you create a button inside a container, like a ``List``, the style
/// resolves to the recommended style for buttons inside that container for
/// that specific platform.
///
/// You can override a button's style. To apply the default style to a
/// button, or to a view that contains buttons, use the
/// ``View/buttonStyle(_:)-66fbx`` modifier.
public static var automatic: DefaultButtonStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 17.0, watchOS 8.0, *)
extension PrimitiveButtonStyle where Self == BorderlessButtonStyle {
/// A button style that doesn't apply a border.
///
/// To apply this style to a button, or to a view that contains buttons, use
/// the ``View/buttonStyle(_:)-66fbx`` modifier.
///
/// On tvOS, this button style adds a default hover effect to the first
/// image of the button's content, if one exists. You can supply a different
/// hover effect by using the ``View/hoverEffect(_:)`` modifier in the
/// button's label.
public static var borderless: BorderlessButtonStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension PrimitiveButtonStyle where Self == PlainButtonStyle {
/// A button style that doesn't style or decorate its content while idle,
/// but may apply a visual effect to indicate the pressed, focused, or
/// enabled state of the button.
///
/// To apply this style to a button, or to a view that contains buttons, use
/// the ``View/buttonStyle(_:)-66fbx`` modifier.
public static var plain: PlainButtonStyle { get }
}
@available(iOS 15.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
extension PrimitiveButtonStyle where Self == BorderedButtonStyle {
/// A button style that applies standard border artwork based on the
/// button's context.
///
/// To apply this style to a button, or to a view that contains buttons, use
/// the ``View/buttonStyle(_:)-66fbx`` modifier.
public static var bordered: BorderedButtonStyle { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension PrimitiveButtonStyle where Self == BorderedProminentButtonStyle {
/// A button style that applies standard border prominent artwork based on
/// the button's context.
///
/// To apply this style to a button, or to a view that contains buttons, use
/// the ``View/buttonStyle(_:)-66fbx`` modifier.
public static var borderedProminent: BorderedProminentButtonStyle { get }
}
/// The properties of a button.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct PrimitiveButtonStyleConfiguration {
/// A type-erased label of a button.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// An optional semantic role describing the button's purpose.
///
/// A value of `nil` means that the Button has no assigned role. If the
/// button does have a role, use it to make adjustments to the button's
/// appearance. The following example shows a custom style that uses
/// bold text when the role is ``ButtonRole/cancel``,
/// ``ShapeStyle/red`` text when the role is ``ButtonRole/destructive``,
/// and adds no special styling otherwise:
///
///     struct MyButtonStyle: PrimitiveButtonStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             configuration.label
///                 .onTapGesture {
///                     configuration.trigger()
///                 }
///                 .font(
///                     configuration.role == .cancel ? .title2.bold() : .title2)
///                 .foregroundColor(
///                     configuration.role == .destructive ? Color.red : nil)
///         }
///     }
///
/// You can create one of each button using this style to see the effect:
///
///     VStack(spacing: 20) {
///         Button("Cancel", role: .cancel) {}
///         Button("Delete", role: .destructive) {}
///         Button("Continue") {}
///     }
///     .buttonStyle(MyButtonStyle())
///
/// ![A screenshot of three buttons stacked vertically. The first says
/// Cancel in black, bold letters. The second says Delete in red, regular
/// weight letters. The third says Continue in black, regular weight
/// letters.](PrimitiveButtonStyleConfiguration-role-1)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public let role: ButtonRole?
/// A view that describes the effect of calling the button's action.
public let label: PrimitiveButtonStyleConfiguration.Label
/// Performs the button's action.
public func trigger()
}
/// A view that shows the progress toward completion of a task.
///
/// Use a progress view to show that a task is incomplete but advancing toward
/// completion. A progress view can show both determinate (percentage complete)
/// and indeterminate (progressing or not) types of progress.
///
/// Create a determinate progress view by initializing a `ProgressView` with
/// a binding to a numeric value that indicates the progress, and a `total`
/// value that represents completion of the task. By default, the progress is
/// `0.0` and the total is `1.0`.
///
/// The example below uses the state property `progress` to show progress in
/// a determinate `ProgressView`. The progress view uses its default total of
/// `1.0`, and because `progress` starts with an initial value of `0.5`,
/// the progress view begins half-complete. A "More" button below the progress
/// view allows people to increment the progress in increments of five percent:
///
///     struct LinearProgressDemoView: View {
///         @State private var progress = 0.5
///
///         var body: some View {
///             VStack {
///                 ProgressView(value: progress)
///                 Button("More") { progress += 0.05 }
///             }
///         }
///     }
///
/// ![A horizontal bar that represents progress, with a More button
/// placed underneath. The progress bar is at 50 percent from the leading
/// edge.](ProgressView-1-macOS)
///
/// To create an indeterminate progress view, use an initializer that doesn't
/// take a progress value:
///
///     var body: some View {
///         ProgressView()
///     }
///
/// ![An indeterminate progress view, presented as a spinning set of gray lines
/// emanating from the center of a circle, with opacity varying from fully
/// opaque to transparent. An animation rotates which line is most opaque,
/// creating the spinning effect.](ProgressView-2-macOS)
///
/// You can also create a progress view that covers a closed range of
/// <doc://com.apple.documentation/documentation/Foundation/Date> values. As long
/// as the current date is within the range, the progress view automatically
/// updates, filling or depleting the progress view as it nears the end of the
/// range. The following example shows a five-minute timer whose start time is
/// that of the progress view's initialization:
///
///     struct DateRelativeProgressDemoView: View {
///         let workoutDateRange = Date()...Date().addingTimeInterval(5*60)
///
///         var body: some View {
///              ProgressView(timerInterval: workoutDateRange) {
///                  Text("Workout")
///              }
///         }
///     }
///
/// ![A horizontal progress view that shows a bar partially filled with as it
/// counts a five-minute duration.](ProgressView-3-macOS)
///
/// ### Styling progress views
///
/// You can customize the appearance and interaction of progress views by
/// creating styles that conform to the ``ProgressViewStyle`` protocol. To set a
/// specific style for all progress view instances within a view, use the
/// ``View/progressViewStyle(_:)`` modifier. In the following example, a custom
/// style adds a rounded pink border to all progress views within the enclosing
/// ``VStack``:
///
///     struct BorderedProgressViews: View {
///         var body: some View {
///             VStack {
///                 ProgressView(value: 0.25) { Text("25% progress") }
///                 ProgressView(value: 0.75) { Text("75% progress") }
///             }
///             .progressViewStyle(PinkBorderedProgressViewStyle())
///         }
///     }
///
///     struct PinkBorderedProgressViewStyle: ProgressViewStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             ProgressView(configuration)
///                 .padding(4)
///                 .border(.pink, width: 3)
///                 .cornerRadius(4)
///         }
///     }
///
/// ![Two horizontal progress views, one at 25 percent complete and the other at 75 percent,
/// each rendered with a rounded pink border.](ProgressView-4-macOS)
///
/// SwiftUI provides two built-in progress view styles,
/// ``ProgressViewStyle/linear`` and ``ProgressViewStyle/circular``, as well as
/// an automatic style that defaults to the most appropriate style in the
/// current context. The following example shows a circular progress view that
/// starts at 60 percent completed.
///
///     struct CircularProgressDemoView: View {
///         @State private var progress = 0.6
///
///         var body: some View {
///             VStack {
///                 ProgressView(value: progress)
///                     .progressViewStyle(.circular)
///             }
///         }
///     }
///
/// ![A ring shape, filled to 60 percent completion with a blue
/// tint.](ProgressView-5-macOS)
///
/// On platforms other than macOS, the circular style may appear as an
/// indeterminate indicator instead.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ProgressView<Label, CurrentValueLabel> : View where Label : View, CurrentValueLabel : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ProgressView {
/// Creates a progress view for showing continuous progress as time passes,
/// with descriptive and current progress labels.
///
/// Use this initializer to create a view that shows continuous progress
/// within a date range. The following example initializes a progress view
/// with a range of `start...end`, where `start` is 30 seconds in the past
/// and `end` is 90 seconds in the future. As a result, the progress view
/// begins at 25 percent complete. This example also provides custom views
/// for a descriptive label (Progress) and a current value label that shows
/// the date range.
///
///     struct ContentView: View {
///         let start = Date().addingTimeInterval(-30)
///         let end = Date().addingTimeInterval(90)
///
///         var body: some View {
///             ProgressView(interval: start...end,
///                          countsDown: false) {
///                 Text("Progress")
///             } currentValueLabel: {
///                 Text(start...end)
///              }
///          }
///     }
///
/// ![A horizontal bar that represents progress, partially filled in from
/// the leading edge. The title, Progress, appears above the bar, and the
/// date range, 1:43 to 1:45 PM, appears below the bar. These values represent
/// the time progress began and when it ends, given a current time of
/// 1:44.](ProgressView-6-macOS)
///
/// By default, the progress view empties as time passes from the start of
/// the date range to the end, but you can use the `countsDown` parameter to
/// create a progress view that fills as time passes, as the above example
/// demonstrates.
///
/// > Note: Date-relative progress views, such as those created with this
///   initializer, don't support custom styles.
///
/// - Parameters:
///     - timerInterval: The date range over which the view should progress.
///     - countsDown: A Boolean value that determines whether the view
///       empties or fills as time passes. If `true` (the default), the
///       view empties.
///     - label: An optional view that describes the purpose of the progress
///       view.
///     - currentValueLabel: A view that displays the current value of the
///       timer.
public init(timerInterval: ClosedRange<Date>, countsDown: Bool = true, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ProgressView where CurrentValueLabel == DefaultDateProgressLabel {
/// Creates a progress view for showing continuous progress as time passes,
/// with a descriptive label.
///
/// Use this initializer to create a view that shows continuous progress
/// within a date range. The following example initializes a progress view
/// with a range of `start...end`, where `start` is 30 seconds in the past
/// and `end` is 90 seconds in the future. As a result, the progress view
/// begins at 25 percent complete. This example also provides a custom
/// descriptive label.
///
///     struct ContentView: View {
///         let start = Date().addingTimeInterval(-30)
///         let end = Date().addingTimeInterval(90)
///
///         var body: some View {
///             ProgressView(interval: start...end,
///                          countsDown: false) {
///                 Text("Progress")
///              }
///         }
///     }
///
/// ![A horizontal bar that represents progress, partially filled in from
/// the leading edge. The title, Progress, appears above the bar, and the
/// elapsed time, 0:34, appears below the bar.](ProgressView-7-macOS)
///
/// By default, the progress view empties as time passes from the start of
/// the date range to the end, but you can use the `countsDown` parameter to
/// create a progress view that fills as time passes, as the above example
/// demonstrates.
///
/// The progress view provided by this initializer uses a text label that
/// automatically updates to describe the current time remaining. To provide
/// a custom label to show the current value, use
/// ``init(value:total:label:currentValueLabel:)`` instead.
///
/// > Note: Date-relative progress views, such as those created with this
///   initializer, don't support custom styles.
///
/// - Parameters:
///     - timerInterval: The date range over which the view progresses.
///     - countsDown: A Boolean value that determines whether the view
///       empties or fills as time passes. If `true` (the default), the
///       view empties.
///     - label: An optional view that describes the purpose of the progress
///       view.
public init(timerInterval: ClosedRange<Date>, countsDown: Bool = true, @ViewBuilder label: () -> Label)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ProgressView where Label == EmptyView, CurrentValueLabel == DefaultDateProgressLabel {
/// Creates a progress view for showing continuous progress as time passes.
///
/// Use this initializer to create a view that shows continuous progress
/// within a date range. The following example initializes a progress view
/// with a range of `start...end`, where `start` is 30 seconds in the past
/// and `end` is 90 seconds in the future. As a result, the progress view
/// begins at 25 percent complete.
///
///     struct ContentView: View {
///         let start = Date().addingTimeInterval(-30)
///         let end = Date().addingTimeInterval(90)
///
///         var body: some View {
///             ProgressView(interval: start...end
///                          countsDown: false)
///         }
///     }
///
/// ![A horizontal bar that represents progress, partially filled in from
/// the leading edge. The elapsed time, 0:34, appears below the
/// bar.](ProgressView-8-macOS)
///
/// By default, the progress view empties as time passes from the start of
/// the date range to the end, but you can use the `countsDown` parameter to
/// create a progress view that fills as time passes, as the above example
/// demonstrates.
///
/// The progress view provided by this initializer omits a descriptive
/// label and provides a text label that automatically updates to describe
/// the current time remaining. To provide custom views for these labels,
/// use ``init(value:total:label:currentValueLabel:)`` instead.
///
/// > Note: Date-relative progress views, such as those created with this
///   initializer, don't support custom styles.
///
/// - Parameters:
///     - timerInterval: The date range over which the view progresses.
///     - countsDown: If `true` (the default), the view empties as time passes.
public init(timerInterval: ClosedRange<Date>, countsDown: Bool = true)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressView where CurrentValueLabel == EmptyView {
/// Creates a progress view for showing indeterminate progress, without a
/// label.
public init() where Label == EmptyView
/// Creates a progress view for showing indeterminate progress that displays
/// a custom label.
///
/// - Parameters:
///     - label: A view builder that creates a view that describes the task
///       in progress.
public init(@ViewBuilder label: () -> Label)
/// Creates a progress view for showing indeterminate progress that
/// generates its label from a localized string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings. To initialize a
/// indeterminate progress view with a string variable, use
/// the corresponding initializer that takes a `StringProtocol` instance.
///
/// - Parameters:
///     - titleKey: The key for the progress view's localized title that
///       describes the task in progress.
public init(_ titleKey: LocalizedStringKey) where Label == Text
/// Creates a progress view for showing indeterminate progress that
/// generates its label from a string.
///
/// - Parameters:
///     - title: A string that describes the task in progress.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(verbatim:)``. See ``Text`` for more
/// information about localizing strings. To initialize a progress view with
/// a localized string key, use the corresponding initializer that takes a
/// `LocalizedStringKey` instance.
public init<S>(_ title: S) where Label == Text, S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressView {
/// Creates a progress view for showing determinate progress.
///
/// If the value is non-`nil`, but outside the range of `0.0` through
/// `total`, the progress view pins the value to those limits, rounding to
/// the nearest possible bound. A value of `nil` represents indeterminate
/// progress, in which case the progress view ignores `total`.
///
/// - Parameters:
///     - value: The completed amount of the task to this point, in a range
///       of `0.0` to `total`, or `nil` if the progress is indeterminate.
///     - total: The full amount representing the complete scope of the
///       task, meaning the task is complete if `value` equals `total`. The
///       default value is `1.0`.
public init<V>(value: V?, total: V = 1.0) where Label == EmptyView, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint
/// Creates a progress view for showing determinate progress, with a
/// custom label.
///
/// If the value is non-`nil`, but outside the range of `0.0` through
/// `total`, the progress view pins the value to those limits, rounding to
/// the nearest possible bound. A value of `nil` represents indeterminate
/// progress, in which case the progress view ignores `total`.
///
/// - Parameters:
///     - value: The completed amount of the task to this point, in a range
///       of `0.0` to `total`, or `nil` if the progress is indeterminate.
///     - total: The full amount representing the complete scope of the
///       task, meaning the task is complete if `value` equals `total`. The
///       default value is `1.0`.
///     - label: A view builder that creates a view that describes the task
///       in progress.
public init<V>(value: V?, total: V = 1.0, @ViewBuilder label: () -> Label) where CurrentValueLabel == EmptyView, V : BinaryFloatingPoint
/// Creates a progress view for showing determinate progress, with a
/// custom label.
///
/// If the value is non-`nil`, but outside the range of `0.0` through
/// `total`, the progress view pins the value to those limits, rounding to
/// the nearest possible bound. A value of `nil` represents indeterminate
/// progress, in which case the progress view ignores `total`.
///
/// - Parameters:
///     - value: The completed amount of the task to this point, in a range
///       of `0.0` to `total`, or `nil` if the progress is indeterminate.
///     - total: The full amount representing the complete scope of the
///       task, meaning the task is complete if `value` equals `total`. The
///       default value is `1.0`.
///     - label: A view builder that creates a view that describes the task
///       in progress.
///     - currentValueLabel: A view builder that creates a view that
///       describes the level of completed progress of the task.
public init<V>(value: V?, total: V = 1.0, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel) where V : BinaryFloatingPoint
/// Creates a progress view for showing determinate progress that generates
/// its label from a localized string.
///
/// If the value is non-`nil`, but outside the range of `0.0` through
/// `total`, the progress view pins the value to those limits, rounding to
/// the nearest possible bound. A value of `nil` represents indeterminate
/// progress, in which case the progress view ignores `total`.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings. To initialize a
///  determinate progress view with a string variable, use
///  the corresponding initializer that takes a `StringProtocol` instance.
///
/// - Parameters:
///     - titleKey: The key for the progress view's localized title that
///       describes the task in progress.
///     - value: The completed amount of the task to this point, in a range
///       of `0.0` to `total`, or `nil` if the progress is
///       indeterminate.
///     - total: The full amount representing the complete scope of the
///       task, meaning the task is complete if `value` equals `total`. The
///       default value is `1.0`.
public init<V>(_ titleKey: LocalizedStringKey, value: V?, total: V = 1.0) where Label == Text, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint
/// Creates a progress view for showing determinate progress that generates
/// its label from a string.
///
/// If the value is non-`nil`, but outside the range of `0.0` through
/// `total`, the progress view pins the value to those limits, rounding to
/// the nearest possible bound. A value of `nil` represents indeterminate
/// progress, in which case the progress view ignores `total`.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(verbatim:)``. See ``Text`` for more
/// information about localizing strings. To initialize a determinate
/// progress view with a localized string key, use the corresponding
/// initializer that takes a `LocalizedStringKey` instance.
///
/// - Parameters:
///     - title: The string that describes the task in progress.
///     - value: The completed amount of the task to this point, in a range
///       of `0.0` to `total`, or `nil` if the progress is
///       indeterminate.
///     - total: The full amount representing the complete scope of the
///       task, meaning the task is complete if `value` equals `total`. The
///       default value is `1.0`.
public init<S, V>(_ title: S, value: V?, total: V = 1.0) where Label == Text, CurrentValueLabel == EmptyView, S : StringProtocol, V : BinaryFloatingPoint
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressView {
/// Creates a progress view for visualizing the given progress instance.
///
/// The progress view synthesizes a default label using the
/// `localizedDescription` of the given progress instance.
public init(_ progress: Progress) where Label == EmptyView, CurrentValueLabel == EmptyView
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressView {
/// Creates a progress view based on a style configuration.
///
/// You can use this initializer within the
/// ``ProgressViewStyle/makeBody(configuration:)`` method of a
/// ``ProgressViewStyle`` to create an instance of the styled progress view.
/// This is useful for custom progress view styles that only modify the
/// current progress view style, as opposed to implementing a brand new
/// style. Because this modifier style can't know how the current style
/// represents progress, avoid making assumptions about the view's contents,
/// such as whether it uses bars or other shapes.
///
/// The following example shows a style that adds a rounded pink border to a
/// progress view, but otherwise preserves the progress view's current
/// style:
///
///     struct PinkBorderedProgressViewStyle: ProgressViewStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             ProgressView(configuration)
///                 .padding(4)
///                 .border(.pink, width: 3)
///                 .cornerRadius(4)
///         }
///     }
///
/// ![Two horizontal progress views, one at 25 percent complete and the
/// other at 75 percent, each rendered with a rounded pink
/// border.](ProgressView-4-macOS)
///
/// - Note: Progress views in widgets don't apply custom styles.
public init(_ configuration: ProgressViewStyleConfiguration) where Label == ProgressViewStyleConfiguration.Label, CurrentValueLabel == ProgressViewStyleConfiguration.CurrentValueLabel
}
/// A type that applies standard interaction behavior to all progress views
/// within a view hierarchy.
///
/// To configure the current progress view style for a view hierarchy, use the
/// ``View/progressViewStyle(_:)`` modifier.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol ProgressViewStyle {
/// A view representing the body of a progress view.
associatedtype Body : View
/// Creates a view representing the body of a progress view.
///
/// - Parameter configuration: The properties of the progress view being
///   created.
///
/// The view hierarchy calls this method for each progress view where this
/// style is the current progress view style.
///
/// - Parameter configuration: The properties of the progress view, such as
///  its preferred progress type.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// A type alias for the properties of a progress view instance.
typealias Configuration = ProgressViewStyleConfiguration
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressViewStyle where Self == LinearProgressViewStyle {
/// A progress view that visually indicates its progress using a horizontal
/// bar.
public static var linear: LinearProgressViewStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressViewStyle where Self == CircularProgressViewStyle {
/// The style of a progress view that uses a circular gauge to indicate the
/// partial completion of an activity.
///
/// On watchOS, and in widgets and complications, a circular progress view
/// appears as a gauge with the ``GaugeStyle/accessoryCircularCapacity``
/// style. If the progress view is indeterminate, the gauge is empty.
///
/// In cases where no determinate circular progress view style is available,
/// circular progress views use an indeterminate style.
public static var circular: CircularProgressViewStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ProgressViewStyle where Self == DefaultProgressViewStyle {
/// The default progress view style in the current context of the view being
/// styled.
///
/// The default style represents the recommended style based on the original
/// initialization parameters of the progress view, and the progress view's
/// context within the view hierarchy.
public static var automatic: DefaultProgressViewStyle { get }
}
/// The properties of a progress view instance.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ProgressViewStyleConfiguration {
/// A type-erased label describing the task represented by the progress
/// view.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A type-erased label that describes the current value of a progress view.
public struct CurrentValueLabel : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The completed fraction of the task represented by the progress view,
/// from `0.0` (not yet started) to `1.0` (fully complete), or `nil` if the
/// progress is indeterminate or relative to a date interval.
public let fractionCompleted: Double?
/// A view that describes the task represented by the progress view.
///
/// If `nil`, then the task is self-evident from the surrounding context,
/// and the style does not need to provide any additional description.
///
/// If the progress view is defined using a `Progress` instance, then this
/// label is equivalent to its `localizedDescription`.
public var label: ProgressViewStyleConfiguration.Label?
/// A view that describes the current value of a progress view.
///
/// If `nil`, then the value of the progress view is either self-evident
/// from the surrounding context or unknown, and the style does not need to
/// provide any additional description.
///
/// If the progress view is defined using a `Progress` instance, then this
/// label is equivalent to its `localizedAdditionalDescription`.
public var currentValueLabel: ProgressViewStyleConfiguration.CurrentValueLabel?
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ProjectionTransform {
public var m11: CGFloat
public var m12: CGFloat
public var m13: CGFloat
public var m21: CGFloat
public var m22: CGFloat
public var m23: CGFloat
public var m31: CGFloat
public var m32: CGFloat
public var m33: CGFloat
@inlinable public init()
@inlinable public init(_ m: CGAffineTransform)
@inlinable public init(_ m: CATransform3D)
@inlinable public var isIdentity: Bool { get }
@inlinable public var isAffine: Bool { get }
public mutating func invert() -> Bool
public func inverted() -> ProjectionTransform
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ProjectionTransform : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ProjectionTransform, b: ProjectionTransform) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ProjectionTransform {
@inlinable public func concatenating(_ rhs: ProjectionTransform) -> ProjectionTransform
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ProjectionTransform : Sendable {
}
/// A type indicating the prominence of a view hierarchy.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public enum Prominence : Sendable {
/// The standard prominence.
case standard
/// An increased prominence.
///
/// - Note: Not all views will react to increased prominence.
case increased
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Prominence, b: Prominence) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Prominence : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Prominence : Hashable {
}
/// A navigation split style that attempts to maintain the size of the
/// detail content when hiding or showing the leading columns.
///
/// Use ``NavigationSplitViewStyle/prominentDetail`` to construct this style.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ProminentDetailNavigationSplitViewStyle : NavigationSplitViewStyle {
/// Creates an instance of ``ProminentDetailNavigationSplitViewStyle``.
///
/// You can also use ``NavigationSplitViewStyle/prominentDetail`` to
/// construct this style.
public init()
/// Creates a view that represents the body of a navigation split view.
///
/// SwiftUI calls this method for each instance of ``NavigationSplitView``,
/// where this style is the current ``NavigationSplitViewStyle``.
///
/// - Parameter configuration: The properties of the instance to create.
public func makeBody(configuration: ProminentDetailNavigationSplitViewStyle.Configuration) -> some View
/// A view that represents the body of a navigation split view.
public typealias Body = some View
}
/// A proposal for the size of a view.
///
/// During layout in SwiftUI, views choose their own size, but they do that
/// in response to a size proposal from their parent view. When you create
/// a custom layout using the ``Layout`` protocol, your layout container
/// participates in this process using `ProposedViewSize` instances.
/// The layout protocol's methods take a proposed size input that you
/// can take into account when arranging views and calculating the size of
/// the composite container. Similarly, your layout proposes a size to each
/// of its own subviews when it measures and places them.
///
/// Layout containers typically measure their subviews by proposing several
/// sizes and looking at the responses. The container can use this information
/// to decide how to allocate space among its subviews. A
/// layout might try the following special proposals:
///
/// * The ``zero`` proposal; the view responds with its minimum size.
/// * The ``infinity`` proposal; the view responds with its maximum size.
/// * The ``unspecified`` proposal; the view responds with its ideal size.
///
/// A layout might also try special cases for one dimension at a time. For
/// example, an ``HStack`` might measure the flexibility of its subviews'
/// widths, while using a fixed value for the height.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct ProposedViewSize : Equatable {
/// The proposed horizontal size measured in points.
///
/// A value of `nil` represents an unspecified width proposal, which a view
/// interprets to mean that it should use its ideal width.
public var width: CGFloat?
/// The proposed vertical size measured in points.
///
/// A value of `nil` represents an unspecified height proposal, which a view
/// interprets to mean that it should use its ideal height.
public var height: CGFloat?
/// A size proposal that contains zero in both dimensions.
///
/// Subviews of a custom layout return their minimum size when you propose
/// this value using the ``LayoutSubview/dimensions(in:)`` method.
/// A custom layout should also return its minimum size from the
/// ``Layout/sizeThatFits(proposal:subviews:cache:)`` method for this
/// value.
public static let zero: ProposedViewSize
/// The proposed size with both dimensions left unspecified.
///
/// Both dimensions contain `nil` in this size proposal.
/// Subviews of a custom layout return their ideal size when you propose
/// this value using the ``LayoutSubview/dimensions(in:)`` method.
/// A custom layout should also return its ideal size from the
/// ``Layout/sizeThatFits(proposal:subviews:cache:)`` method for this
/// value.
public static let unspecified: ProposedViewSize
/// A size proposal that contains infinity in both dimensions.
///
/// Both dimensions contain
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGFloat/1454161-infinity>
/// in this size proposal.
/// Subviews of a custom layout return their maximum size when you propose
/// this value using the ``LayoutSubview/dimensions(in:)`` method.
/// A custom layout should also return its maximum size from the
/// ``Layout/sizeThatFits(proposal:subviews:cache:)`` method for this
/// value.
public static let infinity: ProposedViewSize
/// Creates a new proposed size using the specified width and height.
///
/// - Parameters:
///   - width: A proposed width in points. Use a value of `nil` to indicate
///     that the width is unspecified for this proposal.
///   - height: A proposed height in points. Use a value of `nil` to
///     indicate that the height is unspecified for this proposal.
@inlinable public init(width: CGFloat?, height: CGFloat?)
/// Creates a new proposed size from a specified size.
///
/// - Parameter size: A proposed size with dimensions measured in points.
@inlinable public init(_ size: CGSize)
/// Creates a new proposal that replaces unspecified dimensions in this
/// proposal with the corresponding dimension of the specified size.
///
/// Use the default value to prevent a flexible view from disappearing
/// into a zero-sized frame, and ensure the unspecified value remains
/// visible during debugging.
///
/// - Parameter size: A set of concrete values to use for the size proposal
///   in place of any unspecified dimensions. The default value is `10`
///   for both dimensions.
///
/// - Returns: A new, fully specified size proposal.
@inlinable public func replacingUnspecifiedDimensions(by size: CGSize = CGSize(width: 10, height: 10)) -> CGSize
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ProposedViewSize, b: ProposedViewSize) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ProposedViewSize : Sendable {
}
/// A transition that when added to a view will animate the view's insertion by
/// moving it in from the specified edge while fading it in, and animate its
/// removal by moving it out towards the opposite edge and fading it out.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct PushTransition : Transition {
/// The edge from which the view will be animated in.
public var edge: Edge
/// Creates a transition that animates a view by moving and fading it.
public init(edge: Edge)
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: PushTransition.Content, phase: TransitionPhase) -> some View
/// The type of view representing the body.
public typealias Body = some View
}
/// A radial gradient.
///
/// The gradient applies the color function as the distance from a center
/// point, scaled to fit within the defined start and end radii. The
/// gradient maps the unit space center point into the bounding rectangle of
/// each shape filled with the gradient.
///
/// When using a radial gradient as a shape style, you can also use
/// ``ShapeStyle/radialGradient(_:center:startRadius:endRadius:)-49kel``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct RadialGradient : ShapeStyle, View, Sendable {
/// Creates a radial gradient from a base gradient.
public init(gradient: Gradient, center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat)
/// Creates a radial gradient from a collection of colors.
public init(colors: [Color], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat)
/// Creates a radial gradient from a collection of color stops.
public init(stops: [Gradient.Stop], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A rectangular shape aligned inside the frame of the view containing it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Rectangle : Shape {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// Creates a new rectangle shape.
@inlinable public init()
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Rectangle : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// Describes the corner radius values of a rounded rectangle with
/// uneven corners.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct RectangleCornerRadii : Equatable, Animatable {
/// The radius of the top-leading corner.
public var topLeading: CGFloat
/// The radius of the bottom-leading corner.
public var bottomLeading: CGFloat
/// The radius of the bottom-trailing corner.
public var bottomTrailing: CGFloat
/// The radius of the top-trailing corner.
public var topTrailing: CGFloat
/// Creates a new set of corner radii for a rounded rectangle with
/// uneven corners.
///
/// - Parameters:
///   - topLeading: the radius of the top-leading corner.
///   - bottomLeading: the radius of the bottom-leading corner.
///   - bottomTrailing: the radius of the bottom-trailing corner.
///   - topTrailing: the radius of the top-trailing corner.
public init(topLeading: CGFloat = 0, bottomLeading: CGFloat = 0, bottomTrailing: CGFloat = 0, topTrailing: CGFloat = 0)
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<AnimatablePair<CGFloat, CGFloat>, AnimatablePair<CGFloat, CGFloat>>
/// The data to animate.
public var animatableData: RectangleCornerRadii.AnimatableData
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: RectangleCornerRadii, b: RectangleCornerRadii) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension RectangleCornerRadii : Sendable {
}
/// The reasons to apply a redaction to data displayed on screen.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct RedactionReasons : OptionSet, Sendable {
/// The raw value.
public let rawValue: Int
/// Creates a new set from a raw value.
///
/// - Parameter rawValue: The raw value with which to create the
///   reasons for redaction.
public init(rawValue: Int)
/// Displayed data should appear as generic placeholders.
///
/// Text and images will be automatically masked to appear as
/// generic placeholders, though maintaining their original size and shape.
/// Use this to create a placeholder UI without directly exposing
/// placeholder data to users.
public static let placeholder: RedactionReasons
/// Displayed data should be obscured to protect private information.
///
/// Views marked with `privacySensitive` will be automatically redacted
/// using a standard styling. To apply a custom treatment the redaction
/// reason can be read out of the environment.
///
///     struct BankingContentView: View {
///         @Environment(\.redactionReasons) var redactionReasons
///
///         var body: some View {
///             if redactionReasons.contains(.privacy) {
///                 FullAppCover()
///             } else {
///                 AppContent()
///             }
///         }
///     }
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static let privacy: RedactionReasons
/// Displayed data should appear as invalidated and pending a new update.
///
/// Views marked with `invalidatableContent` will be automatically
/// redacted with a standard styling indicating the content is invalidated
/// and new content will be available soon.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static let invalidated: RedactionReasons
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = RedactionReasons
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = RedactionReasons
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
/// A type that you use to serialize reference type documents to and from file.
///
/// To store a document as a reference type --- like a class --- create a type
/// that conforms to the `ReferenceFileDocument` protocol and implement the
/// required methods and properties. Your implementation:
///
/// * Provides a list of the content types that the document can read from and
///   write to by defining ``readableContentTypes``. If the list of content
///   types that the document can write to is different from those that it reads
///   from, you can optionally also define ``writableContentTypes-6x6w9``.
/// * Loads documents from file in the ``init(configuration:)`` initializer.
/// * Stores documents to file by providing a snapshot of the document's
///   content in the ``snapshot(contentType:)`` method, and then serializing
///   that content in the ``fileWrapper(snapshot:configuration:)`` method.
///
/// > Important: If you store your document as a value type --- like a
///   structure --- use ``FileDocument`` instead.
///
/// Ensure that types that conform to this protocol are thread-safe.
/// In particular, SwiftUI calls the protocol's methods on a background
/// thread. Don't use that thread to perform user interface updates.
/// Use it only to serialize and deserialize the document data.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol ReferenceFileDocument : ObservableObject {
/// A type that represents the document's stored content.
///
/// Define this type to represent all the data that your document stores.
/// When someone issues a Save command, SwiftUI asks your document for a
/// value of this type by calling the document's ``snapshot(contentType:)``
/// method. SwiftUI sends the snapshot that you provide to the document's
/// ``fileWrapper(snapshot:configuration:)`` method, where you serialize
/// the contents of the snapshot into a file wrapper.
associatedtype Snapshot
/// The file and data types that the document reads from.
///
/// Define this list to indicate the content types that your document can
/// read. By default, SwiftUI assumes that your document can also write
/// the same set of content types. If you need to indicate a different set
/// of types for writing files, define the ``writableContentTypes-6x6w9``
/// property in addition to this property.
static var readableContentTypes: [UTType] { get }
/// The file types that the document supports saving or exporting to.
///
/// By default, SwiftUI assumes that your document reads and writes the
/// same set of content types. Only define this property if you need to
/// indicate a different set of types for writing files. Otherwise, the
/// default implementation of this property returns the list that you
/// specify in your implementation of ``readableContentTypes``.
static var writableContentTypes: [UTType] { get }
/// Creates a document and initializes it with the contents of a file.
///
/// SwiftUI calls this initializer when someone opens a file type
/// that matches one of those that your document type supports.
/// Use the ``FileDocumentReadConfiguration/file`` property of the
/// `configuration` input to get document's data. Deserialize the data,
/// and store it in your document's data structure:
///
///     init(configuration: ReadConfiguration) throws {
///         guard let data = configuration.file.regularFileContents
///         else { /* Throw an error. */ }
///         model = try JSONDecoder().decode(Model.self, from: data)
///     }
///
/// The above example assumes that you define `Model` to contain
/// the document's data, that `Model` conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Codable> protocol,
/// and that you store a `model` property of that type inside your document.
///
/// > Note: SwiftUI calls this method on a background thread. Don't
///   make user interface changes from that thread.
///
/// - Parameter configuration: Information about the file that you read
///   document data from.
init(configuration: Self.ReadConfiguration) throws
/// The configuration for reading document contents.
///
/// This type is an alias for ``FileDocumentReadConfiguration``, which
/// contains a content type and a file wrapper that you use to access the
/// contents of a document file. You get a value of this type as an input
/// to the ``init(configuration:)`` initializer. Use it to load a
/// document from a file.
typealias ReadConfiguration = FileDocumentReadConfiguration
/// Creates a snapshot that represents the current state of the document.
///
/// To store a document --- for example, in response to a Save command ---
/// SwiftUI begins by calling this method. Return a copy of the document's
/// content from your implementation of the method. For example, you might
/// define an initializer for your document's model object that copies the
/// contents of the document's instance, and return that:
///
///     func snapshot(contentType: UTType) throws -> Snapshot {
///         Model(from: model) // Creates a copy.
///     }
///
/// SwiftUI prevents document edits during the snapshot operation to ensure
/// that the model state remains coherent. After the call completes, SwiftUI
/// reenables edits, and then calls the
/// ``fileWrapper(snapshot:configuration:)`` method, where you serialize
/// the snapshot and store it to a file.
///
/// > Note: SwiftUI calls this method on a background thread. Don't
///   make user interface changes from that thread.
///
/// - Parameter contentType: The content type that you create the
///   document snapshot for.
///
/// - Returns: A snapshot of the document content that the system
///   provides to the ``fileWrapper(snapshot:configuration:)`` method
///   for serialization.
func snapshot(contentType: UTType) throws -> Self.Snapshot
/// Serializes a document snapshot to a file wrapper.
///
/// To store a document --- for example, in response to a Save command ---
/// SwiftUI begins by calling the ``snapshot(contentType:)`` method to get
/// a copy of the document data in its current state. Then SwiftUI passes
/// that snapshot to this method, where you serialize it and create or
/// modify a file wrapper with the serialized data:
///
///     func fileWrapper(snapshot: Snapshot, configuration: WriteConfiguration) throws -> FileWrapper {
///         let data = try JSONEncoder().encode(snapshot)
///         return FileWrapper(regularFileWithContents: data)
///     }
///
/// SwiftUI disables document edits during the snapshot to ensure that the
/// document's data remains coherent, but reenables edits during the
/// serialization operation.
///
/// > Note: SwiftUI calls this method on a background thread. Don't
///   make user interface changes from that thread.
///
/// - Parameters:
///   - snapshot: The document snapshot to save.
///   - configuration: Information about a file that already exists for the
///     document, if any.
///
/// - Returns: The destination to serialize the document contents to. The
///   value can be a newly created
///   <doc://com.apple.documentation/documentation/Foundation/FileWrapper>
///   or an update of the one provided in the `configuration` input.
func fileWrapper(snapshot: Self.Snapshot, configuration: Self.WriteConfiguration) throws -> FileWrapper
/// The configuration for writing document contents.
///
/// This type is an alias for ``FileDocumentWriteConfiguration``, which
/// contains a content type and a file wrapper that you use to access the
/// contents of a document file, if one already exists. You get a value
/// of this type as an input to the ``fileWrapper(snapshot:configuration:)``
/// method.
typealias WriteConfiguration = FileDocumentWriteConfiguration
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ReferenceFileDocument {
/// The file types that the document supports saving or exporting to.
///
/// By default, SwiftUI assumes that your document reads and writes the
/// same set of content types. Only define this property if you need to
/// indicate a different set of types for writing files. Otherwise, the
/// default implementation of this property returns the list that you
/// specify in your implementation of ``readableContentTypes``.
public static var writableContentTypes: [UTType] { get }
}
/// The properties of an open reference file document.
///
/// You receive an instance of this structure when you create a
/// ``DocumentGroup`` with a reference file type. Use it to access the
/// document in your viewer or editor.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor public struct ReferenceFileDocumentConfiguration<Document> where Document : ReferenceFileDocument {
/// The current document model.
///
/// Changes to the document dirty the document state, indicating that it
/// needs to be saved. SwiftUI doesn't automatically register undo actions.
/// You have to manage undo operations yourself, as demonstrated in
/// <doc://com.apple.documentation/documentation/swiftui/building_a_document-based_app_with_swiftui>.
@ObservedObject @MainActor public var document: Document
@MainActor public var $document: ObservedObject<Document>.Wrapper { get }
/// The URL of the open file document.
@MainActor public var fileURL: URL?
/// A Boolean that indicates whether you can edit the document.
///
/// The value is `false` if the document is in viewing mode, or if the
/// file is not writable.
@MainActor public var isEditable: Bool
}
/// An action that initiates a refresh operation.
///
/// When the ``EnvironmentValues/refresh`` environment value contains an
/// instance of this structure, certain built-in views in the corresponding
/// ``Environment`` begin offering a refresh capability. They apply the
/// instance's handler to any refresh operation that the user initiates.
/// By default, the environment value is `nil`, but you can use the
/// ``View/refreshable(action:)`` modifier to create and store a new
/// refresh action that uses the handler that you specify:
///
///     List(mailbox.conversations) { conversation in
///         ConversationCell(conversation)
///     }
///     .refreshable {
///         await mailbox.fetch()
///     }
///
/// On iOS and iPadOS, the ``List`` in the example above offers a
/// pull to refresh gesture because it detects the refresh action. When
/// the user drags the list down and releases, the list calls the action's
/// handler. Because SwiftUI declares the handler as asynchronous, it can
/// safely make long-running asynchronous calls, like fetching network data.
///
/// ### Refreshing custom views
///
/// You can also offer refresh capability in your custom views.
/// Read the ``EnvironmentValues/refresh`` environment value to get the
/// `RefreshAction` instance for a given ``Environment``. If you find
/// a non-`nil` value, change your view's appearance or behavior to offer
/// the refresh to the user, and call the instance to conduct the
/// refresh. You can call the refresh instance directly because it defines
/// a ``RefreshAction/callAsFunction()`` method that Swift calls
/// when you call the instance:
///
///     struct RefreshableView: View {
///         @Environment(\.refresh) private var refresh
///
///         var body: some View {
///             Button("Refresh") {
///                 Task {
///                     await refresh?()
///                 }
///             }
///             .disabled(refresh == nil)
///         }
///     }
///
/// Be sure to call the handler asynchronously by preceding it
/// with `await`. Because the call is asynchronous, you can use
/// its lifetime to indicate progress to the user. For example,
/// you might reveal an indeterminate ``ProgressView`` before
/// calling the handler, and hide it when the handler completes.
///
/// If your code isn't already in an asynchronous context, create a
/// <doc://com.apple.documentation/documentation/Swift/Task> for the
/// method to run in. If you do this, consider adding a way for the
/// user to cancel the task. For more information, see
/// [Concurrency](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html)
/// in *The Swift Programming Language*.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct RefreshAction : Sendable {
/// Initiates a refresh action.
///
/// Don't call this method directly. SwiftUI calls it when you
/// call the ``RefreshAction`` structure that you get from the
/// ``Environment``:
///
///     struct RefreshableView: View {
///         @Environment(\.refresh) private var refresh
///
///         var body: some View {
///             Button("Refresh") {
///                 Task {
///                     await refresh?()  // Implicitly calls refresh.callAsFunction()
///                 }
///             }
///             .disabled(refresh == nil)
///         }
///     }
///
/// For information about how Swift uses the `callAsFunction()` method to
/// simplify call site syntax, see
/// [Methods with Special Names](https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID622)
/// in *The Swift Programming Language*.
/// For information about asynchronous operations in Swift, see
/// [Concurrency](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html).
public func callAsFunction() async
}
/// An action that activates a standard rename interaction.
///
/// Use the ``View/renameAction(_:)-6lghl`` modifier to configure the rename
/// action in the environment.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct RenameAction {
/// Triggers the standard rename action provided through the environment.
public func callAsFunction()
}
/// A button that triggers a standard rename action.
///
/// A rename button receives its action from the environment. Use the
/// ``View/renameAction(_:)-6lghl`` modifier to set the action. The
/// system disables the button if you don't define an action.
///
///     struct RowView: View {
///         @State private var text = ""
///         @FocusState private var isFocused: Bool
///
///         var body: some View {
///             TextField(text: $item.name) {
///                 Text("Prompt")
///             }
///             .focused($isFocused)
///             .contextMenu {
///                 RenameButton()
///                 // ... your own custom actions
///             }
///             .renameAction { $isFocused = true }
///     }
///
/// When someone taps the rename button in the context menu, the rename
/// action focuses the text field by setting the `isFocused`
/// property to true.
///
/// You can use this button inside of a navigation title menu and the
/// navigation title modifier automatically configures the environment
/// with the appropriate rename action.
///
///     ContentView()
///         .navigationTitle($contentTitle) {
///             // ... your own custom actions
///             RenameButton()
///         }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct RenameButton<Label> : View where Label : View {
/// Creates a rename button.
public init() where Label == Label<Text, Image>
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A gesture that recognizes a rotation motion and tracks the angle of the
/// rotation.
///
/// A rotate gesture tracks how a rotation event sequence changes. To
/// recognize a rotate gesture on a view, create and configure the gesture,
/// and then add it to the view using the ``View/gesture(_:including:)``
/// modifier.
///
/// Add a rotate gesture to a ``Rectangle`` and apply a rotation effect:
///
///     struct RotateGestureView: View {
///         @State private var angle = Angle(degrees: 0.0)
///
///         var rotation: some Gesture {
///             RotateGesture()
///                 .onChanged { value in
///                     angle = value.rotation
///                 }
///         }
///
///         var body: some View {
///             Rectangle()
///                 .frame(width: 200, height: 200, alignment: .center)
///                 .rotationEffect(angle)
///                 .gesture(rotation)
///         }
///     }
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct RotateGesture : Gesture {
/// The type representing the gesture's value.
public struct Value : Equatable, Sendable {
/// The time associated with the gesture's current event.
public var time: Date
/// The relative amount that the gesture has rotated by.
///
/// A value of 30 degrees means that the user has interacted with the
/// gesture to rotate by 30 degrees relative to the amount before the
/// gesture.
public var rotation: Angle
/// The current rotation velocity.
public var velocity: Angle
/// The initial anchor point of the gesture in the modified view's
/// coordinate space.
public var startAnchor: UnitPoint
/// The initial center of the gesture in the modified view's coordinate
/// space.
public var startLocation: CGPoint
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: RotateGesture.Value, b: RotateGesture.Value) -> Bool
}
/// The minimum delta required before the gesture succeeds.
public var minimumAngleDelta: Angle
/// Creates a rotation gesture with a minimum delta for the gesture to
/// start.
///
/// - Parameter minimumAngleDelta: The minimum delta required before the
///   gesture starts. The default value is a one-degree angle.
public init(minimumAngleDelta: Angle = .degrees(1))
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A shape with a rotation transform applied to it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct RotatedShape<Content> : Shape where Content : Shape {
public var shape: Content
public var angle: Angle
public var anchor: UnitPoint
@inlinable public init(shape: Content, angle: Angle, anchor: UnitPoint = .center)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var role: ShapeRole { get }
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, AnimatablePair<Angle.AnimatableData, UnitPoint.AnimatableData>>
/// The data to animate.
public var animatableData: RotatedShape<Content>.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension RotatedShape : InsettableShape where Content : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> RotatedShape<Content.InsetShape>
/// The type of the inset shape.
public typealias InsetShape = RotatedShape<Content.InsetShape>
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "RotateGesture")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "RotateGesture")
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "RotateGesture")
public struct RotationGesture : Gesture {
/// The minimum delta required before the gesture succeeds.
public var minimumAngleDelta: Angle
/// Creates a rotation gesture with a minimum delta for the gesture to
/// start.
///
/// - Parameter minimumAngleDelta: The minimum delta required before the
///   gesture starts. The default value is a one-degree angle.
public init(minimumAngleDelta: Angle = .degrees(1))
/// The type representing the gesture's value.
public typealias Value = Angle
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A text field style with a system-defined rounded border.
///
/// You can also use ``TextFieldStyle/roundedBorder`` to construct this style.
@available(iOS 13.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct RoundedBorderTextFieldStyle : TextFieldStyle {
public init()
}
/// Defines the shape of a rounded rectangle's corners.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum RoundedCornerStyle : Sendable {
/// Quarter-circle rounded rect corners.
case circular
/// Continuous curvature rounded rect corners.
case continuous
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: RoundedCornerStyle, b: RoundedCornerStyle) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension RoundedCornerStyle : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension RoundedCornerStyle : Hashable {
}
/// A rectangular shape with rounded corners, aligned inside the frame of the
/// view containing it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct RoundedRectangle : Shape {
/// The width and height of the rounded rectangle's corners.
public var cornerSize: CGSize
/// The style of corners drawn by the rounded rectangle.
public var style: RoundedCornerStyle
/// Creates a new rounded rectangle shape.
///
/// - Parameters:
///   - cornerSize: the width and height of the rounded corners.
///   - style: the style of corners drawn by the shape.
@inlinable public init(cornerSize: CGSize, style: RoundedCornerStyle = .continuous)
/// Creates a new rounded rectangle shape.
///
/// - Parameters:
///   - cornerRadius: the radius of the rounded corners.
///   - style: the style of corners drawn by the shape.
@inlinable public init(cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The data to animate.
public var animatableData: CGSize.AnimatableData
/// The type defining the data to animate.
public typealias AnimatableData = CGSize.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension RoundedRectangle : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A set of symbolic safe area regions.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public struct SafeAreaRegions : OptionSet {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: UInt
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
@inlinable public init(rawValue: UInt)
/// The safe area defined by the device and containers within the
/// user interface, including elements such as top and bottom bars.
public static let container: SafeAreaRegions
/// The safe area matching the current extent of any software
/// keyboard displayed over the view content.
public static let keyboard: SafeAreaRegions
/// All safe area regions.
public static let all: SafeAreaRegions
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = SafeAreaRegions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = SafeAreaRegions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = UInt
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SafeAreaRegions : Sendable {
}
/// Returns a transition that scales the view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ScaleTransition : Transition {
/// The amount to scale the view by.
public var scale: Double
/// The anchor point to scale the view around.
public var anchor: UnitPoint
/// Creates a transition that scales the view by the specified amount.
public init(_ scale: Double, anchor: UnitPoint = .center)
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: ScaleTransition.Content, phase: TransitionPhase) -> some View
/// The type of view representing the body.
public typealias Body = some View
}
/// A dynamic property that scales a numeric value.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@propertyWrapper public struct ScaledMetric<Value> : DynamicProperty where Value : BinaryFloatingPoint {
/// Creates the scaled metric with an unscaled value and a text style to
/// scale relative to.
public init(wrappedValue: Value, relativeTo textStyle: Font.TextStyle)
/// Creates the scaled metric with an unscaled value using the default
/// scaling.
public init(wrappedValue: Value)
/// The value scaled based on the current environment.
public var wrappedValue: Value { get }
}
/// A shape with a scale transform applied to it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ScaledShape<Content> : Shape where Content : Shape {
public var shape: Content
public var scale: CGSize
public var anchor: UnitPoint
@inlinable public init(shape: Content, scale: CGSize, anchor: UnitPoint = .center)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var role: ShapeRole { get }
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, AnimatablePair<CGSize.AnimatableData, UnitPoint.AnimatableData>>
/// The data to animate.
public var animatableData: ScaledShape<Content>.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
/// A part of an app's user interface with a life cycle managed by the
/// system.
///
/// You create an ``SwiftUI/App`` by combining one or more instances
/// that conform to the `Scene` protocol in the app's
/// ``SwiftUI/App/body-swift.property``. You can use the built-in scenes that
/// SwiftUI provides, like ``SwiftUI/WindowGroup``, along with custom scenes
/// that you compose from other scenes. To create a custom scene, declare a
/// type that conforms to the `Scene` protocol. Implement the required
/// ``SwiftUI/Scene/body-swift.property`` computed property and provide the
/// content for your custom scene:
///
///     struct MyScene: Scene {
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView()
///             }
///         }
///     }
///
/// A scene acts as a container for a view hierarchy that you want to display
/// to the user. The system decides when and how to present the view hierarchy
/// in the user interface in a way that's platform-appropriate and dependent
/// on the current state of the app. For example, for the window group shown
/// above, the system lets the user create or remove windows that contain
/// `MyRootView` on platforms like macOS and iPadOS. On other platforms, the
/// same view hierarchy might consume the entire display when active.
///
/// Read the ``SwiftUI/EnvironmentValues/scenePhase`` environment
/// value from within a scene or one of its views to check whether a scene is
/// active or in some other state. You can create a property that contains the
/// scene phase, which is one of the values in the ``SwiftUI/ScenePhase``
/// enumeration, using the ``SwiftUI/Environment`` attribute:
///
///     struct MyScene: Scene {
///         @Environment(\.scenePhase) private var scenePhase
///
///         // ...
///     }
///
/// The `Scene` protocol provides scene modifiers, defined as protocol methods
/// with default implementations, that you use to configure a scene. For
/// example, you can use the ``SwiftUI/Scene/onChange(of:perform:)`` modifier to
/// trigger an action when a value changes. The following code empties a cache
/// when all of the scenes in the window group have moved to the background:
///
///     struct MyScene: Scene {
///         @Environment(\.scenePhase) private var scenePhase
///         @StateObject private var cache = DataCache()
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView()
///             }
///             .onChange(of: scenePhase) { newScenePhase in
///                 if newScenePhase == .background {
///                     cache.empty()
///                 }
///             }
///         }
///     }
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol Scene {
/// The type of scene that represents the body of this scene.
///
/// When you create a custom scene, Swift infers this type from your
/// implementation of the required ``SwiftUI/Scene/body-swift.property``
/// property.
associatedtype Body : Scene
/// The content and behavior of the scene.
///
/// For any scene that you create, provide a computed `body` property that
/// defines the scene as a composition of other scenes. You can assemble a
/// scene from built-in scenes that SwiftUI provides, as well as other
/// scenes that you've defined.
///
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype``
/// associated type based on the contents of the `body` property.
@SceneBuilder @MainActor var body: Self.Body { get }
}
@available(iOS 17.0, macOS 13.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Scene {
/// Sets the kind of resizability to use for a window.
///
/// Use this scene modifier to apply a value of type ``WindowResizability``
/// to a ``Scene`` that you define in your ``App`` declaration.
/// The value that you specify indicates the strategy the system uses to
/// place minimum and maximum size restrictions on windows that it creates
/// from that scene.
///
/// For example, you can create a window group that people can resize to
/// between 100 and 400 points in both dimensions by applying both a frame
/// with those constraints to the scene's content, and the
/// ``WindowResizability/contentSize`` resizability to the scene:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///                     .frame(
///                         minWidth: 100, maxWidth: 400,
///                         minHeight: 100, maxHeight: 400)
///             }
///             .windowResizability(.contentSize)
///         }
///     }
///
/// The default value for all scenes if you don't apply the modifier is
/// ``WindowResizability/automatic``. With that strategy, ``Settings``
/// windows use the ``WindowResizability/contentSize`` strategy, while
/// all others use ``WindowResizability/contentMinSize``.
///
/// - Parameter resizability: The resizability to use for windows created by
///   this scene.
///
/// - Returns: A scene that uses the specified resizability strategy.
public func windowResizability(_ resizability: WindowResizability) -> some Scene
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Scene {
/// Transforms the environment value of the specified key path with the
/// given function.
public func transformEnvironment<V>(_ keyPath: WritableKeyPath<EnvironmentValues, V>, transform: @escaping (inout V) -> Void) -> some Scene
}
@available(iOS 17.0, macOS 13.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Scene {
/// Sets a default size for a window.
///
/// Use this scene modifier to indicate a default initial size for a new
/// window that the system creates from a ``Scene`` declaration. For
/// example, you can request that new windows that a ``WindowGroup``
/// generates occupy 600 points in the x-dimension and 400 points in
/// the y-dimension:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///             }
///             .defaultSize(CGSize(width: 600, height: 400))
///         }
///     }
///
/// The size that you specify acts only as a default for when the window
/// first appears. People can later resize the window using interface
/// controls that the system provides. Also, during state restoration,
/// the system restores windows to their most recent size rather than
/// the default size.
///
/// If you specify a default size that's outside the range of the window's
/// inherent resizability in one or both dimensions, the system clamps the
/// affected dimension to keep it in range. You can configure the
/// resizability of a scene using the ``Scene/windowResizability(_:)``
/// modifier.
///
/// The default size modifier affects any scene type that creates windows
/// in macOS, namely:
///
///  * ``WindowGroup``
///  * ``Window``
///  * ``DocumentGroup``
///  * ``Settings``
///
/// If you want to specify the input directly in terms of width and height,
/// use ``Scene/defaultSize(width:height:)`` instead.
///
/// - Parameter size: The default size for new windows created from a scene.
///
/// - Returns: A scene that uses a default size for new windows.
public func defaultSize(_ size: CGSize) -> some Scene
/// Sets a default width and height for a window.
///
/// Use this scene modifier to indicate a default initial size for a new
/// window that the system creates from a ``Scene`` declaration. For
/// example, you can request that new windows that a ``WindowGroup``
/// generates occupy 600 points in the x-dimension and 400 points in
/// the y-dimension:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///             }
///             .defaultSize(width: 600, height: 400)
///         }
///     }
///
/// The size that you specify acts only as a default for when the window
/// first appears. People can later resize the window using interface
/// controls that the system provides. Also, during state restoration,
/// the system restores windows to their most recent size rather than
/// the default size.
///
/// If you specify a default size that's outside the range of the window's
/// inherent resizability in one or both dimensions, the system clamps the
/// affected dimension to keep it in range. You can configure the
/// resizability of a scene using the ``Scene/windowResizability(_:)``
/// modifier.
///
/// The default size modifier affects any scene type that creates windows
/// in macOS, namely:
///
///  * ``WindowGroup``
///  * ``Window``
///  * ``DocumentGroup``
///  * ``Settings``
///
/// If you want to specify the size input in terms of size instance,
/// use ``Scene/defaultSize(_:)`` instead.
///
/// - Parameter width: The default width for windows created from a scene.
/// - Parameter height: The default height for windows created from a scene.
///
/// - Returns: A scene that uses a default size for new windows.
public func defaultSize(width: CGFloat, height: CGFloat) -> some Scene
}
extension Scene {
/// Sets the environment value of the specified key path to the given value.
///
/// Use this modifier to set one of the writable properties of the
/// ``EnvironmentValues`` structure, including custom values that you
/// create. For example, you can create a custom environment key
/// `styleOverrides` to set a value that represents style settings that for
/// the entire app:
///
///     WindowGroup {
///         ContentView()
///     }
///     .environment(\.styleOverrides, StyleOverrides())
///
/// You then read the value inside `ContentView` or one of its descendants
/// using the ``Environment`` property wrapper:
///
///     struct MyView: View {
///         @Environment(\.styleOverrides) var styleOverrides: StyleOverrides
///
///         var body: some View { ... }
///     }
///
/// This modifier affects the given scene,
/// as well as that scene's descendant views. It has no effect
/// outside the view hierarchy on which you call it.
///
/// - Parameters:
///   - keyPath: A key path that indicates the property of the
///     ``EnvironmentValues`` structure to update.
///   - value: The new value to set for the item specified by `keyPath`.
///
/// - Returns: A view that has the given value set in its environment.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public func environment<V>(_ keyPath: WritableKeyPath<EnvironmentValues, V>, _ value: V) -> some Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Scene {
/// The default store used by `AppStorage` contained within the scene and
/// its view content.
///
/// If unspecified, the default store for a view hierarchy is
/// `UserDefaults.standard`, but can be set a to a custom one. For example,
/// sharing defaults between an app and an extension can override the
/// default store to one created with `UserDefaults.init(suiteName:_)`.
///
/// - Parameter store: The user defaults to use as the default
///   store for `AppStorage`.
public func defaultAppStorage(_ store: UserDefaults) -> some Scene
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Scene {
/// Specifies a modifier to indicate if this Scene can be used
/// when creating a new Scene for the received External Event.
///
/// This modifier is only supported for WindowGroup Scene types.
///
/// For DocumentGroups, the received External Event must have a URL
/// for the DocumentGroup to be considered. (Either via openURL, or
/// the webPageURL property of an NSUserActivity). The UTI for the URL
/// is implicitly matched against the DocumentGroup's supported types.
///
/// If the modifier evaluates to true, an instance of the
/// Scene will be used.
///
/// If the modifier evaluates to false, on macOS the Scene
/// will not be used even if no other Scenes are available.
/// This case is considered an error. On iOS, the first Scene
/// specified in the body property for the App will be used.
///
/// If no modifier is set, the Scene will be used if all
/// other WindowGroups with a modifier evaluate to false.
///
/// On platforms that only allow a single Window/Scene, this method is
/// ignored.
///
/// - Parameter matching: A Set of Strings that are checked to see
/// if they are contained in the targetContentIdenfifier. The empty Set
/// and empty Strings never match. The String value "*" always matches.
public func handlesExternalEvents(matching conditions: Set<String>) -> some Scene
}
extension Scene {
/// Sets an object of the environment to the given value.
///
/// - Important: This modifier only accepts objects conforming to the
/// `Observable` protocol. For objects conforming to `ObservableObject` see
/// ``Scene/environmentObject(_:)``.
///
/// Use this modifier to set custom objects in a scene's environment. For
/// example, you could set the environment object for a custom `Profile`
/// class:
///
///     @Observable final class Profile { ... }
///
///     @main
///     struct MyApp: App {
///         var body: some View {
///             WindowGroup {
///                 ContentView()
///             }
///             .environment(ProfileService.currentProfile)
///         }
///     }
///
/// You then read the object inside `ContentView` or one of its descendants
/// using the ``Environment`` property wrapper:
///
///     struct ContentView: View {
///         @Environment(Account.self) private var currentAccount: Account
///
///         var body: some View { ... }
///     }
///
/// This modifier affects the given scene, as
/// well as that scene's descendant views. It has no effect outside the view
/// hierarchy on which you call it.
///
/// - Parameter object: The new object to set for this object's type in the
///   environment, or `nil` to clear the object from the environment.
///
/// - Returns: A scene that has the given object set in its environment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func environment<T>(_ object: T?) -> some Scene where T : AnyObject, T : Observable
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Scene {
/// Adds commands to the scene.
///
/// Commands are realized in different ways on different platforms. On
/// macOS, the main menu uses the available command menus and groups to
/// organize its main menu items. Each menu is represented as a top-level
/// menu bar menu, and each command group has a corresponding set of menu
/// items in one of the top-level menus, delimited by separator menu items.
///
/// On iPadOS, commands with keyboard shortcuts are exposed in the shortcut
/// discoverability HUD that users see when they hold down the Command (⌘)
/// key.
public func commands<Content>(@CommandsBuilder content: () -> Content) -> some Scene where Content : Commands
}
extension Scene {
/// Supplies an `ObservableObject` to a view subhierarchy.
///
/// The object can be read by any child by using `EnvironmentObject`:
///
///     final class Profile: ObservableObject { ... }
///
///     @main
///     struct MyApp: App {
///         var body: some View {
///             WindowGroup {
///                 ContentView()
///             }
///             .environment(ProfileService.currentProfile)
///         }
///     }
///
/// You then read the object inside `ContentView` or one of its descendants
/// using the ``EnvironmentObject`` property wrapper:
///
///     struct ContentView: View {
///         @EnvironmentObject private var currentAccount: Account
///
///         var body: some View { ... }
///     }
///
/// - Parameter object: the object to store and make available to
///   the scene's subhierarchy.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func environmentObject<T>(_ object: T) -> some Scene where T : ObservableObject
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Scene {
/// Removes all commands defined by the modified scene.
///
/// `WindowGroup`, `Window`, and other scene types all have an associated
/// set of commands that they include by default. Apply this modifier to a
/// scene to exclude those commands.
///
/// For example, the following code adds a scene for presenting the details
/// of an individual data model in a separate window. To ensure that the
/// window can only appear programmatically, we remove the scene's commands,
/// including File > New Note Window.
///
///     @main
///     struct Example: App {
///         var body: some Scene {
///             ...
///
///             WindowGroup("Note", id: "note", for: Note.ID.self) {
///                 NoteDetailView(id: $0)
///             }
///             .commandsRemoved()
///         }
///     }
///
/// - Returns: A scene that excludes any commands defined by its children.
public func commandsRemoved() -> some Scene
/// Replaces all commands defined by the modified scene with the commands
/// from the builder.
///
/// `WindowGroup`, `Window`, and other scene types all have an associated
/// set of commands that they include by default. Apply this modifier to a
/// scene to replace those commands with the output from the given builder.
///
/// For example, the following code adds a scene for showing the contents of
/// the pasteboard in a dedicated window. We replace the scene's default
/// Window > Clipboard menu command with a custom Edit > Show Clipboard
/// command that we place next to the other pasteboard commands.
///
///     @main
///     struct Example: App {
///         @Environment(\.openWindow) var openWindow
///
///         var body: some Scene {
///             ...
///
///             Window("Clipboard", id: "clipboard") {
///                 ClipboardContentView()
///             }
///             .commandsReplaced {
///                 CommandGroup(after: .pasteboard) {
///                     Section {
///                         Button("Show Clipboard") {
///                             openWindow(id: "clipboard")
///                         }
///                     }
///                 }
///             }
///         }
///     }
///
/// - Parameters:
///   - content: A `Commands` builder whose output will be used to replace
///     the commands normally provided by the modified scene.
///
/// - Returns: A scene that replaces any commands defined by its children
///   with alternative content.
public func commandsReplaced<Content>(@CommandsBuilder content: () -> Content) -> some Scene where Content : Commands
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Scene {
/// Runs the specified action when the system provides a background task.
///
/// When the system wakes your app or extension for one or more background
/// tasks, it will call any actions associated with matching tasks. When
/// your async actions return, the system put your app back into a suspended
/// state. The system considers the task completed when the action closure
/// that you provide returns. If the action closure has not returned when
/// the task runs out of time to complete, the system cancels the task. Use
/// <doc://com.apple.documentation/documentation/Swift/3851300-withtaskcancellationhandler>
/// to observe whether the task is low on runtime.
///
///     /// An example of a Weather Application.
///     struct WeatherApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 Text("Responds to App Refresh")
///             }
///             .backgroundTask(.appRefresh("WEATHER_DATA")) {
///                 await updateWeatherData()
///             }
///         }
///         func updateWeatherData() async {
///             // fetches new weather data and updates app state
///         }
///     }
///
///
/// - Parameters:
///   - task: The type of task with which to associate the provided action.
///   - action: An async closure that the system runs for the specified task
///     type.
public func backgroundTask<D, R>(_ task: BackgroundTask<D, R>, action: @escaping @Sendable (D) async -> R) -> some Scene where D : Sendable, R : Sendable
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Scene {
/// Adds an action to perform when the given value changes.
///
/// Use this modifier to trigger a side effect when a value changes, like
/// the value associated with an ``SwiftUI/Environment`` value or a
/// ``SwiftUI/Binding``. For example, you can clear a cache when you notice
/// that a scene moves to the background:
///
///     struct MyScene: Scene {
///         @Environment(\.scenePhase) private var scenePhase
///         @StateObject private var cache = DataCache()
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView()
///             }
///             .onChange(of: scenePhase) { newScenePhase in
///                 if newScenePhase == .background {
///                     cache.empty()
///                 }
///             }
///         }
///     }
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task:
///
///     .onChange(of: scenePhase) { newScenePhase in
///         if newScenePhase == .background {
///             Task.detached(priority: .background) {
///                 // ...
///             }
///         }
///     }
///
/// The system passes the new value into the closure. If you need the old
/// value, capture it in the closure.
///
/// Important: This modifier is deprecated and has been replaced with new
/// versions that include either zero or two parameters within the closure,
/// unlike this version that includes one parameter. This deprecated version
/// and the new versions behave differently with respect to how they execute
/// the action closure, specifically when the closure captures other values.
/// Using the deprecated API, the closure is run with captured values that
/// represent the "old" state. With the replacement API, the closure is run
/// with captured values that represent the "new" state, which makes it
/// easier to correctly perform updates that rely on supplementary values
/// (that may or may not have changed) in addition to the changed value that
/// triggered the action.
///
/// - Important: This modifier is deprecated and has been replaced with new
///   versions that include either zero or two parameters within the
///   closure, unlike this version that includes one parameter. This
///   deprecated version and the new versions behave differently with
///   respect to how they execute the action closure, specifically when the
///   closure captures other values. Using the deprecated API, the closure
///   is run with captured values that represent the "old" state. With the
///   replacement API, the closure is run with captured values that
///   represent the "new" state, which makes it easier to correctly perform
///   updates that rely on supplementary values (that may or may not have
///   changed) in addition to the changed value that triggered the action.
///
/// - Parameters:
///   - value: The value to check when determining whether to run the
///     closure. The value must conform to the
///     <doc://com.apple.documentation/documentation/Swift/Equatable>
///     protocol.
///   - action: A closure to run when the value changes. The closure
///     provides a single `newValue` parameter that indicates the changed
///     value.
///
/// - Returns: A scene that triggers an action in response to a change.
@available(iOS, deprecated: 17.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(macOS, deprecated: 14.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(tvOS, deprecated: 17.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(watchOS, deprecated: 10.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(visionOS, deprecated: 1.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@inlinable public func onChange<V>(of value: V, perform action: @escaping (_ newValue: V) -> Void) -> some Scene where V : Equatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Scene {
/// Adds an action to perform when the given value changes.
///
/// Use this modifier to trigger a side effect when a value changes, like
/// the value associated with an ``SwiftUI/Environment`` key or a
/// ``SwiftUI/Binding``. For example, you can clear a cache when you notice
/// that a scene moves to the background:
///
///     struct MyScene: Scene {
///         @Environment(\.scenePhase) private var scenePhase
///         @StateObject private var cache = DataCache()
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView(cache: cache)
///             }
///             .onChange(of: scenePhase) { oldScenePhase, newScenePhase in
///                 if newScenePhase == .background {
///                     cache.empty()
///                 }
///             }
///         }
///     }
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task:
///
///     .onChange(of: scenePhase) { oldScenePhase, newScenePhase in
///         if newScenePhase == .background {
///             Task.detached(priority: .background) {
///                 // ...
///             }
///         }
///     }
///
/// When the value changes, the new version of the closure will be called,
/// so any captured values will have their values from the time that the
/// observed value has its new value. The system passes the old and new
/// observed values into the closure.
///
/// - Parameters:
///   - value: The value to check when determining whether to run the
///     closure. The value must conform to the
///     <doc://com.apple.documentation/documentation/Swift/Equatable>
///     protocol.
///   - initial: Whether the action should be run when this scene initially
///     appears.
///   - action: A closure to run when the value changes.
///   - oldValue: The old value that failed the comparison check (or the
///     initial value when requested).
///   - newValue: The new value that failed the comparison check.
///
/// - Returns: A scene that triggers an action in response to a change.
public func onChange<V>(of value: V, initial: Bool = false, _ action: @escaping (_ oldValue: V, _ newValue: V) -> Void) -> some Scene where V : Equatable
/// Adds an action to perform when the given value changes.
///
/// Use this modifier to trigger a side effect when a value changes, like
/// the value associated with an ``SwiftUI/Environment`` key or a
/// ``SwiftUI/Binding``. For example, you can clear a cache when you notice
/// that a scene moves to the background:
///
///     struct MyScene: Scene {
///         @Environment(\.locale) private var locale
///         @StateObject private var cache = LocalizationDataCache()
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView(cache: cache)
///             }
///             .onChange(of: locale) {
///                 cache.empty()
///             }
///         }
///     }
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task:
///
///     .onChange(of: locale) {
///         Task.detached(priority: .background) {
///             // ...
///         }
///     }
///
/// When the value changes, the new version of the closure will be called,
/// so any captured values will have their values from the time that the
/// observed value has its new value.
///
/// - Parameters:
///   - value: The value to check when determining whether to run the
///     closure. The value must conform to the
///     <doc://com.apple.documentation/documentation/Swift/Equatable>
///     protocol.
///   - initial: Whether the action should be run when this scene initially
///     appears.
///   - action: A closure to run when the value changes.
///
/// - Returns: A scene that triggers an action in response to a change.
public func onChange<V>(of value: V, initial: Bool = false, _ action: @escaping () -> Void) -> some Scene where V : Equatable
}
/// A result builder for composing a collection of scenes into a single
/// composite scene.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@resultBuilder public struct SceneBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : Scene
/// Passes a single scene written as a child scene through unmodified.
public static func buildBlock<Content>(_ content: Content) -> Content where Content : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
/// Provides support for "if" statements in multi-statement closures,
/// producing an optional scene that is visible only when the condition
/// evaluates to `true`.
///
/// "if" statements in a ``SceneBuilder`` are limited to only
/// `#available()` clauses.
public static func buildOptional(_ scene: (Scene & _LimitedAvailabilitySceneMarker)?) -> some Scene
/// Provides support for "if" statements with `#available()` clauses in
/// multi-statement closures, producing conditional content for the "then"
/// branch, i.e. the conditionally-available branch.
public static func buildLimitedAvailability(_ scene: some Scene) -> Scene & _LimitedAvailabilitySceneMarker
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Scene where C0 : Scene, C1 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene, C8 : Scene
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene, C8 : Scene, C9 : Scene
}
/// The padding used to space a view from its containing scene.
///
/// Add scene padding to a view using the ``View/scenePadding(_:edges:)``
/// modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ScenePadding : Equatable, Sendable {
/// The minimum scene padding value.
///
/// In macOS, this value represents the recommended spacing for the root
/// view of a window. In watchOS, this represents the horizontal spacing
/// that you use to align your view with the title of a navigation view.
public static let minimum: ScenePadding
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ScenePadding, b: ScenePadding) -> Bool
}
/// An indication of a scene's operational state.
///
/// The system moves your app's ``Scene`` instances through phases that reflect
/// a scene's operational state. You can trigger actions when the phase changes.
/// Read the current phase by observing the ``EnvironmentValues/scenePhase``
/// value in the ``Environment``:
///
///     @Environment(\.scenePhase) private var scenePhase
///
/// How you interpret the value depends on where it's read from.
/// If you read the phase from inside a ``View`` instance, you obtain a value
/// that reflects the phase of the scene that contains the view. The following
/// example uses the ``SwiftUI/View/onChange(of:perform:)`` method to enable
/// a timer whenever the enclosing scene enters the ``ScenePhase/active`` phase
/// and disable the timer when entering any other phase:
///
///     struct MyView: View {
///         @ObservedObject var model: DataModel
///         @Environment(\.scenePhase) private var scenePhase
///
///         var body: some View {
///             TimerView()
///                 .onChange(of: scenePhase) { phase in
///                     model.isTimerRunning = (phase == .active)
///                 }
///         }
///     }
///
/// If you read the phase from within an ``App`` instance, you obtain an
/// aggregate value that reflects the phases of all the scenes in your app. The
/// app reports a value of ``ScenePhase/active`` if any scene is active, or a
/// value of ``ScenePhase/inactive`` when no scenes are active. This includes
/// multiple scene instances created from a single scene declaration; for
/// example, from a ``WindowGroup``. When an app enters the
/// ``ScenePhase/background`` phase, expect the app to terminate soon after.
/// You can use that opportunity to free any resources:
///
///     @main
///     struct MyApp: App {
///         @Environment(\.scenePhase) private var scenePhase
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView()
///             }
///             .onChange(of: scenePhase) { phase in
///                 if phase == .background {
///                     // Perform cleanup when all scenes within
///                     // MyApp go to the background.
///                 }
///             }
///         }
///     }
///
/// If you read the phase from within a custom ``Scene`` instance, the value
/// similarly reflects an aggregation of all the scenes that make up the custom
/// scene:
///
///     struct MyScene: Scene {
///         @Environment(\.scenePhase) private var scenePhase
///
///         var body: some Scene {
///             WindowGroup {
///                 MyRootView()
///             }
///             .onChange(of: scenePhase) { phase in
///                 if phase == .background {
///                     // Perform cleanup when all scenes within
///                     // MyScene go to the background.
///                 }
///             }
///         }
///     }
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public enum ScenePhase : Comparable {
/// The scene isn't currently visible in the UI.
///
/// Do as little as possible in a scene that's in the `background` phase.
/// The `background` phase can precede termination, so do any cleanup work
/// immediately upon entering this state. For example, close any open files
/// and network connections. However, a scene can also return to the
/// ``ScenePhase/active`` phase from the background.
///
/// Expect an app that enters the `background` phase to terminate.
case background
/// The scene is in the foreground but should pause its work.
///
/// A scene in this phase doesn't receive events and should pause
/// timers and free any unnecessary resources. The scene might be completely
/// hidden in the user interface or otherwise unavailable to the user.
/// In macOS, scenes only pass through this phase temporarily on their way
/// to the ``ScenePhase/background`` phase.
///
/// An app or custom scene in this phase contains no scene instances in the
/// ``ScenePhase/active`` phase.
case inactive
/// The scene is in the foreground and interactive.
///
/// An active scene isn't necessarily front-most. For example, a macOS
/// window might be active even if it doesn't currently have focus.
/// Nevertheless, all scenes should operate normally in this phase.
///
/// An app or custom scene in this phase contains at least one active scene
/// instance.
case active
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ScenePhase, b: ScenePhase) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func < (a: ScenePhase, b: ScenePhase) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ScenePhase : Sendable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ScenePhase : Hashable {
}
/// A property wrapper type that reads and writes to persisted, per-scene
/// storage.
///
/// You use `SceneStorage` when you need automatic state restoration of the
/// value.  `SceneStorage` works very similar to `State`, except its initial
/// value is restored by the system if it was previously saved, and the value is
/// shared with other `SceneStorage` variables in the same scene.
///
/// The system manages the saving and restoring of `SceneStorage` on your
/// behalf. The underlying data that backs `SceneStorage` is not available to
/// you, so you must access it via the `SceneStorage` property wrapper. The
/// system makes no guarantees as to when and how often the data will be
/// persisted.
///
/// Each `Scene` has its own notion of `SceneStorage`, so data is not shared
/// between scenes.
///
/// Ensure that the data you use with `SceneStorage` is lightweight. Data of a
/// large size, such as model data, should not be stored in `SceneStorage`, as
/// poor performance may result.
///
/// If the `Scene` is explicitly destroyed (e.g. the switcher snapshot is
/// destroyed on iPadOS or the window is closed on macOS), the data is also
/// destroyed. Do not use `SceneStorage` with sensitive data.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen @propertyWrapper public struct SceneStorage<Value> : DynamicProperty {
/// The underlying value referenced by the state variable.
///
/// This works identically to `State.wrappedValue`.
///
/// - SeeAlso: State.wrappedValue
public var wrappedValue: Value { get nonmutating set }
/// A binding to the state value.
///
/// This works identically to `State.projectedValue`.
///
/// - SeeAlso: State.projectedValue
public var projectedValue: Binding<Value> { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension SceneStorage {
/// Creates a property that can save and restore table column state.
///
/// - Parameter wrappedValue: The default value if table column state is not
///   available for the given key.
/// - Parameter key: a key used to save and restore the value.
public init<RowValue>(wrappedValue: Value = TableColumnCustomization<RowValue>(), _ key: String) where Value == TableColumnCustomization<RowValue>, RowValue : Identifiable
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneStorage {
/// Creates a property that can save and restore a boolean.
///
/// - Parameter wrappedValue: The default value if a boolean is not
///   available for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == Bool
/// Creates a property that can save and restore an integer.
///
/// - Parameter wrappedValue: The default value if an integer is not
///   available for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == Int
/// Creates a property that can save and restore a double.
///
/// - Parameter wrappedValue: The default value if a double is not available
///   for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == Double
/// Creates a property that can save and restore a string.
///
/// - Parameter wrappedValue: The default value if a string is not available
///   for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == String
/// Creates a property that can save and restore a URL.
///
/// - Parameter wrappedValue: The default value if a URL is not available
///   for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == URL
/// Creates a property that can save and restore data.
///
/// Avoid storing large data blobs, such as image data, as it can negatively
/// affect performance of your app.
///
/// - Parameter wrappedValue: The default value if data is not available
///   for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value == Data
/// Creates a property that can save and restore an integer, transforming it
/// to a `RawRepresentable` data type.
///
/// A common usage is with enumerations:
///
///    enum MyEnum: Int {
///        case a
///        case b
///        case c
///    }
///    struct MyView: View {
///        @SceneStorage("MyEnumValue") private var value = MyEnum.a
///        var body: some View { ... }
///    }
///
/// - Parameter wrappedValue: The default value if an integer value is not
///   available for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value : RawRepresentable, Value.RawValue == Int
/// Creates a property that can save and restore a string, transforming it
/// to a `RawRepresentable` data type.
///
/// A common usage is with enumerations:
///
///    enum MyEnum: String {
///        case a
///        case b
///        case c
///    }
///    struct MyView: View {
///        @SceneStorage("MyEnumValue") private var value = MyEnum.a
///        var body: some View { ... }
///    }
///
/// - Parameter wrappedValue: The default value if a String value is not
///   available for the given key.
/// - Parameter key: a key used to save and restore the value.
public init(wrappedValue: Value, _ key: String) where Value : RawRepresentable, Value.RawValue == String
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension SceneStorage where Value : ExpressibleByNilLiteral {
/// Creates a property that can save and restore an Optional boolean.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == Bool?
/// Creates a property that can save and restore an Optional integer.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == Int?
/// Creates a property that can save and restore an Optional double.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == Double?
/// Creates a property that can save and restore an Optional string.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == String?
/// Creates a property that can save and restore an Optional URL.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == URL?
/// Creates a property that can save and restore an Optional data.
///
/// Defaults to nil if there is no restored value
///
/// - Parameter key: a key used to save and restore the value.
public init(_ key: String) where Value == Data?
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SceneStorage {
/// Creates a property that can save and restore an Optional string,
/// transforming it to an Optional `RawRepresentable` data type.
///
/// Defaults to nil if there is no restored value
///
/// A common usage is with enumerations:
///
///     enum MyEnum: String {
///         case a
///         case b
///         case c
///     }
///     struct MyView: View {
///         @SceneStorage("MyEnumValue") private var value: MyEnum?
///         var body: some View { ... }
///     }
///
/// - Parameter key: a key used to save and restore the value.
public init<R>(_ key: String) where Value == R?, R : RawRepresentable, R.RawValue == String
/// Creates a property that can save and restore an Optional integer,
/// transforming it to an Optional `RawRepresentable` data type.
///
/// Defaults to nil if there is no restored value
///
/// A common usage is with enumerations:
///
///     enum MyEnum: Int {
///         case a
///         case b
///         case c
///     }
///     struct MyView: View {
///         @SceneStorage("MyEnumValue") private var value: MyEnum?
///         var body: some View { ... }
///     }
///
/// - Parameter key: a key used to save and restore the value.
public init<R>(_ key: String) where Value == R?, R : RawRepresentable, R.RawValue == Int
}
/// The ways that a scrollable view can bounce when it reaches the end of its
/// content.
///
/// Use the ``View/scrollBounceBehavior(_:axes:)`` view modifier to set a value
/// of this type for a scrollable view, like a ``ScrollView`` or a ``List``.
/// The value configures the bounce behavior when people scroll to the end of
/// the view's content.
///
/// You can configure each scrollable axis to use a different bounce mode.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct ScrollBounceBehavior : Sendable {
/// The automatic behavior.
///
/// The scrollable view automatically chooses whether content bounces when
/// people scroll to the end of the view's content. By default, scrollable
/// views use the ``ScrollBounceBehavior/always`` behavior.
public static var automatic: ScrollBounceBehavior { get }
/// The scrollable view always bounces.
///
/// The scrollable view always bounces along the specified axis,
/// regardless of the size of the content.
public static var always: ScrollBounceBehavior { get }
/// The scrollable view bounces when its content is large enough to require
/// scrolling.
///
/// The scrollable view bounces along the specified axis if the size of
/// the content exceeeds the size of the scrollable view in that axis.
public static var basedOnSize: ScrollBounceBehavior { get }
}
/// The ways that scrollable content can interact with the software keyboard.
///
/// Use this type in a call to the ``View/scrollDismissesKeyboard(_:)``
/// modifier to specify the dismissal behavior of scrollable views.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@available(visionOS, unavailable)
public struct ScrollDismissesKeyboardMode : Sendable {
/// Determine the mode automatically based on the surrounding context.
///
/// By default, a ``TextEditor`` is interactive while a ``List``
/// of scrollable content always dismiss the keyboard on a scroll,
/// when linked against iOS 16 or later.
public static var automatic: ScrollDismissesKeyboardMode { get }
/// Dismiss the keyboard as soon as scrolling starts.
public static var immediately: ScrollDismissesKeyboardMode { get }
/// Enable people to interactively dismiss the keyboard as part of the
/// scroll operation.
///
/// The software keyboard's position tracks the gesture that drives the
/// scroll operation if the gesture crosses into the keyboard's area of the
/// display. People can dismiss the keyboard by scrolling it off the
/// display, or reverse the direction of the scroll to cancel the dismissal.
public static var interactively: ScrollDismissesKeyboardMode { get }
/// Never dismiss the keyboard automatically as a result of scrolling.
public static var never: ScrollDismissesKeyboardMode { get }
}
/// The visibility of scroll indicators of a UI element.
///
/// Pass a value of this type to the ``View/scrollIndicators(_:axes:)`` method
/// to specify the preferred scroll indicator visibility of a view hierarchy.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ScrollIndicatorVisibility {
/// Scroll indicator visibility depends on the
/// policies of the component accepting the visibility configuration.
public static var automatic: ScrollIndicatorVisibility { get }
/// Show the scroll indicators.
///
/// The actual visibility of the indicators depends on platform
/// conventions like auto-hiding behaviors in iOS or user preference
/// behaviors in macOS.
public static var visible: ScrollIndicatorVisibility { get }
/// Hide the scroll indicators.
///
/// By default, scroll views in macOS show indicators when a
/// mouse is connected. Use ``never`` to indicate
/// a stronger preference that can override this behavior.
public static var hidden: ScrollIndicatorVisibility { get }
/// Scroll indicators should never be visible.
///
/// This value behaves like ``hidden``, but
/// overrides scrollable views that choose
/// to keep their indidicators visible. When using this value,
/// provide an alternative method of scrolling. The typical
/// horizontal swipe gesture might not be available, depending on
/// the current input device.
public static var never: ScrollIndicatorVisibility { get }
}
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
extension ScrollIndicatorVisibility : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ScrollIndicatorVisibility, b: ScrollIndicatorVisibility) -> Bool
}
/// A type defining the target in which a scroll view should try and scroll to.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ScrollTarget {
/// The rect that a scrollable view should try and have contained.
public var rect: CGRect
/// The anchor to which the rect should be aligned within the visible
/// region of the scrollable view.
public var anchor: UnitPoint?
}
/// A type that defines the scroll behavior of a scrollable view.
///
/// A scrollable view calculates where scroll gestures should end using its
/// deceleration rate and the state of its scroll gesture by default. A scroll
/// behavior allows for customizing this logic.
///
/// You define a scroll behavior using the
/// ``ScrollTargetBehavior/updateTarget(_:context:)`` method.
///
/// Using this method, you can control where someone can scroll in a scrollable
/// view. For example, you can create a custom scroll behavior
/// that aligns to every 10 points by doing the following:
///
///     struct BasicScrollTargetBehavior: ScrollTargetBehavior {
///         func updateTarget(_ target: inout Target, context: TargetContext) {
///             // Align to every 1/10 the size of the scroll view.
///             target.rect.x.round(
///                 toMultipleOf: round(context.containerSize.width / 10.0))
///         }
///     }
///
/// ### Paging Behavior
///
/// SwiftUI offers built in scroll behaviors. One such behavior
/// is the ``PagingScrollTargetBehavior`` which uses the geometry of the scroll
/// view to decide where to allow scrolls to end.
///
/// In the following example, every view in the lazy stack is flexible
/// in both directions and the scroll view will settle to container aligned
/// boundaries.
///
///     ScrollView {
///         LazyVStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 FullScreenItem(item)
///             }
///         }
///     }
///     .scrollTargetBehavior(.paging)
///
/// ### View Aligned Behavior
///
/// SwiftUI also offers a ``ViewAlignedScrollTargetBehavior`` scroll behavior
/// that will always settle on the geometry of individual views.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///     .safeAreaPadding(.horizontal, 20.0)
///
/// You configure which views should be used for settling using the
/// ``View/scrollTargetLayout(isEnabled:)`` modifier. Apply this modifier to a
/// layout container like ``LazyVStack`` or ``HStack`` and each individual
/// view in that layout will be considered for alignment.
///
/// Use types conforming to this protocol with the
/// ``View/scrollTargetBehavior(_:)`` modifier.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol ScrollTargetBehavior {
/// Updates the proposed target that a scrollable view should scroll to.
///
/// The system calls this method in two main cases:
/// - When a scroll gesture ends, it calculates where it would naturally
///   scroll to using its deceleration rate. The system
///   provides this calculated value as the target of this method.
/// - When a scrollable view's size changes, it calculates where it should
///   be scrolled given the new size and provides this calculates value
///   as the target of this method.
///
/// You can implement this method to override the calculated target
/// which will have the scrollable view scroll to a different position
/// than it would otherwise.
func updateTarget(_ target: inout ScrollTarget, context: Self.TargetContext)
/// The context in which a scroll behavior updates the scroll target.
typealias TargetContext = ScrollTargetBehaviorContext
}
extension ScrollTargetBehavior where Self == PagingScrollTargetBehavior {
/// The scroll behavior that aligns scroll targets to container-based
/// geometry.
///
/// In the following example, every view in the lazy stack is flexible
/// in both directions and the scroll view settles to container-aligned
/// boundaries.
///
///     ScrollView {
///         LazyVStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 FullScreenItem(item)
///             }
///         }
///     }
///     .scrollTargetBehavior(.paging)
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static var paging: PagingScrollTargetBehavior { get }
}
extension ScrollTargetBehavior where Self == ViewAlignedScrollTargetBehavior {
/// The scroll behavior that aligns scroll targets to view-based geometry.
///
/// You use this behavior when a scroll view should always align its
/// scroll targets to a rectangle that's aligned to the geometry of a view. In
/// the following example, the scroll view always picks an item view
/// to settle on.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///     .padding(.horizontal, 20.0)
///
/// You configure which views should be used for settling using the
/// ``View/scrollTargetLayout()`` modifier. Apply this modifier to a
/// layout container like ``LazyVStack`` or ``HStack`` and each individual
/// view in that layout will be considered for alignment.
///
/// You can customize whether the view aligned behavior limits the
/// number of views that can be scrolled at a time by using the
/// ``ViewAlignedScrollTargetBehavior.LimitBehavior`` type. Provide a value
/// of ``ViewAlignedScrollTargetBehavior.LimitBehavior/always`` to always
/// have the behavior only allow a few views to be scrolled at a time.
///
/// By default, the view aligned behavior limits the number of views
/// it scrolls when in a compact horizontal size class when scrollable
/// in the horizontal axis, when in a compact vertical size class when
/// scrollable in the vertical axis, and otherwise doesn't impose any
/// limit on the number of views that can be scrolled.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static var viewAligned: ViewAlignedScrollTargetBehavior { get }
/// The scroll behavior that aligns scroll targets to view-based geometry.
///
/// You use this behavior when a scroll view should always align its
/// scroll targets to a rectangle that's aligned to the geometry of a view. In
/// the following example, the scroll view always picks an item view
/// to settle on.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///     .padding(.horizontal, 20.0)
///
/// You configure which views should be used for settling using the
/// ``View/scrollTargetLayout()`` modifier. Apply this modifier to a
/// layout container like ``LazyVStack`` or ``HStack`` and each individual
/// view in that layout will be considered for alignment.
///
/// You can customize whether the view aligned behavior limits the
/// number of views that can be scrolled at a time by using the
/// ``ViewAlignedScrollTargetBehavior.LimitBehavior`` type. Provide a value
/// of ``ViewAlignedScrollTargetBehavior.LimitBehavior/always`` to always
/// have the behavior only allow a few views to be scrolled at a time.
///
/// By default, the view aligned behavior limits the number of views
/// it scrolls when in a compact horizontal size class when scrollable
/// in the horizontal axis, when in a compact vertical size class when
/// scrollable in the vertical axis, and otherwise doesn't impose any
/// limit on the number of views that can be scrolled.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public static func viewAligned(limitBehavior: ViewAlignedScrollTargetBehavior.LimitBehavior) -> Self
}
/// The context in which a scroll target behavior updates its scroll target.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@dynamicMemberLookup public struct ScrollTargetBehaviorContext {
/// The original target when the scroll gesture began.
public var originalTarget: ScrollTarget { get }
/// The current velocity of the scrollable view's scroll gesture.
public var velocity: CGVector { get }
/// The size of the content of the scrollable view.
public var contentSize: CGSize { get }
/// The size of the container of the scrollable view.
///
/// This is the size of the bounds of the scroll view subtracting any
/// insets applied to the scroll view (like the safe area).
public var containerSize: CGSize { get }
/// The axes in which the scrollable view is scrollable.
public var axes: Axis.Set { get }
public subscript<T>(dynamicMember keyPath: KeyPath<EnvironmentValues, T>) -> T { get }
}
/// The configuration of a scroll transition that controls how a transition
/// is applied as a view is scrolled through the visible region of a containing
/// scroll view or other container.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ScrollTransitionConfiguration {
/// Creates a new configuration that discretely animates the transition
/// when the view becomes visible.
///
/// Unlike the interactive configuration, the transition isn't
/// interpolated as the scroll view is scrolled. Instead, the transition
/// phase only changes once the threshold has been reached, at which
/// time the given animation is used to animate to the new phase.
///
/// - Parameters:
///   - animation: The animation to use when transitioning between states.
///
/// - Returns: A configuration that discretely animates between
///   transition phases.
public static func animated(_ animation: Animation = .default) -> ScrollTransitionConfiguration
/// Creates a new configuration that discretely animates the transition
/// when the view becomes visible.
public static let animated: ScrollTransitionConfiguration
/// Creates a new configuration that interactively interpolates the
/// transition's effect as the view is scrolled into the visible region
/// of the container.
///
/// - Parameters:
///   - timingCurve: The curve that adjusts the pace at which the effect
///     is interpolated between phases of the transition. For example, an
///     `.easeIn` curve causes interpolation to begin slowly as the view
///     reaches the edge of the scroll view, then speed up as it reaches
///     the visible threshold. The curve is applied 'forward' while the
///     view is appearing, meaning that time zero corresponds to the
///     view being just hidden, and time 1.0 corresponds to the pont at
///     which the view reaches the configuration threshold. This also means
///     that the timing curve is applied in reversed while the view
///     is moving away from the center of the scroll view.
///
/// - Returns: A configuration that interactively interpolates between
///   transition phases based on the current scroll position.
public static func interactive(timingCurve: UnitCurve = .easeInOut) -> ScrollTransitionConfiguration
/// Creates a new configuration that interactively interpolates the
/// transition's effect as the view is scrolled into the visible region
/// of the container.
public static let interactive: ScrollTransitionConfiguration
/// Creates a new configuration that does not change the appearance of the view.
public static let identity: ScrollTransitionConfiguration
/// Sets the animation with which the transition will be applied.
///
/// If the transition is interactive, the given animation will be used
/// to animate the effect toward the current interpolated value, causing
/// the effect to lag behind the current scroll position.
///
/// - Parameter animation: An animation that will be used to apply the
///   transition to the view.
///
/// - Returns: A copy of this configuration with the animation set to the
///   given value.
public func animation(_ animation: Animation) -> ScrollTransitionConfiguration
/// Sets the threshold at which the view will be considered fully visible.
///
/// - Parameters:
///   - threshold: The threshold specifying how much of the view must
///     intersect with the container before it is treated as visible.
///
/// - Returns: A copy of this configuration with the threshold set to the
///   given value.
public func threshold(_ threshold: ScrollTransitionConfiguration.Threshold) -> ScrollTransitionConfiguration
}
extension ScrollTransitionConfiguration {
/// Describes a specific point in the progression of a target view within a container
/// from hidden (fully outside the container) to visible.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct Threshold {
public static let visible: ScrollTransitionConfiguration.Threshold
public static let hidden: ScrollTransitionConfiguration.Threshold
/// The target view is centered within the container
public static var centered: ScrollTransitionConfiguration.Threshold { get }
/// The target view is visible by the given amount, where zero is fully
/// hidden, and one is fully visible.
///
/// Values less than zero or greater than one are clamped.
public static func visible(_ amount: Double) -> ScrollTransitionConfiguration.Threshold
/// Creates a new threshold that combines this threshold value with
/// another threshold, interpolated by the given amount.
///
/// - Parameters:
///   - other: The second threshold value.
///   - amount: The ratio with which this threshold is combined with
///     the given threshold, where zero is equal to this threshold,
///     1.0 is equal to `other`, and values in between combine the two
///     thresholds.
public func interpolated(towards other: ScrollTransitionConfiguration.Threshold, amount: Double) -> ScrollTransitionConfiguration.Threshold
/// Returns a threshold that is met when the target view is closer to the
/// center of the container by `distance`. Use negative values to move
/// the threshold away from the center.
public func inset(by distance: Double) -> ScrollTransitionConfiguration.Threshold
}
}
/// The phases that a view transitions between when it scrolls among other views.
///
/// When a view with a scroll transition modifier applied is approaching
/// the visible region of the containing scroll view or other container,
/// the effect  will first be applied with the `topLeading` or `bottomTrailing`
/// phase (depending on which edge the view is approaching), then will be
/// moved to the `identity` phase as the view moves into the visible area. The
/// timing and behavior that determines when a view is visible within the
/// container is controlled by the configuration that is provided to the
/// `scrollTransition` modifier.
///
/// In the `identity` phase, scroll transitions should generally not make any
/// visual change to the view they are applied to, since the transition's view
/// modifications in the `identity` phase will be applied to the view as long
/// as it is visible. In the `topLeading` and `bottomTrailing` phases,
/// transitions should apply a change that will be animated to create the
/// transition.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public enum ScrollTransitionPhase {
/// The scroll transition is being applied to a view that is about to
/// move into the visible area at the top edge of a vertical scroll view,
/// or the leading edge of a horizont scroll view.
case topLeading
/// The scroll transition is being applied to a view that is in the
/// visible area.
///
/// In this phase, a transition should show its steady state appearance,
/// which will generally not make any visual change to the view.
case identity
/// The scroll transition is being applied to a view that is about to
/// move into the visible area at the bottom edge of a vertical scroll
/// view, or the trailing edge of a horizontal scroll view.
case bottomTrailing
public var isIdentity: Bool { get }
/// A phase-derived value that can be used to scale or otherwise modify
/// effects.
///
/// Returns -1.0 when in the topLeading phase, zero when in the identity
/// phase, and 1.0 when in the bottomTrailing phase.
public var value: Double { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ScrollTransitionPhase, b: ScrollTransitionPhase) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ScrollTransitionPhase : Equatable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ScrollTransitionPhase : Hashable {
}
/// A scrollable view.
///
/// The scroll view displays its content within the scrollable content region.
/// As the user performs platform-appropriate scroll gestures, the scroll view
/// adjusts what portion of the underlying content is visible. `ScrollView` can
/// scroll horizontally, vertically, or both, but does not provide zooming
/// functionality.
///
/// In the following example, a `ScrollView` allows the user to scroll through
/// a ``VStack`` containing 100 ``Text`` views. The image after the listing
/// shows the scroll view's temporarily visible scrollbar at the right; you can
/// disable it with the `showsIndicators` parameter of the `ScrollView`
/// initializer.
///
///     var body: some View {
///         ScrollView {
///             VStack(alignment: .leading) {
///                 ForEach(0..<100) {
///                     Text("Row \($0)")
///                 }
///             }
///         }
///     }
/// ![A scroll view with a series of vertically arranged rows, reading
/// Row 1, Row 2, and so on. At the right, a scrollbar indicates that
/// this is the top of the scrollable
/// area.](SwiftUI-ScrollView-rows-with-indicator.png)
///
/// ### Controlling Scroll Position
///
/// You can influence where a scroll view is initially scrolled
/// by using the ``View/defaultScrollAnchor(_:)`` view modifier.
///
/// Provide a value of `UnitPoint/center`` to have the scroll
/// view start in the center of its content when a scroll view
/// is scrollable in both axes.
///
///     ScrollView([.horizontal, .vertical]) {
///         // initially centered content
///     }
///     .defaultScrollAnchor(.center)
///
/// Or provide an alignment of `UnitPoint/bottom`` to have the
/// scroll view start at the bottom of its content when a scroll
/// view is scrollable in its vertical axes.
///
///     ScrollView {
///         // initially bottom aligned content
///     }
///     .defaultScrollAnchor(.bottom)
///
/// After the scroll view initially renders, the user may scroll
/// the content of the scroll view.
///
/// To perform programmatic scrolling, wrap one or more scroll views with a
/// ``ScrollViewReader``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct ScrollView<Content> : View where Content : View {
/// The scroll view's content.
public var content: Content
/// The scrollable axes of the scroll view.
///
/// The default value is ``Axis/vertical``.
public var axes: Axis.Set
/// A value that indicates whether the scroll view displays the scrollable
/// component of the content offset, in a way that's suitable for the
/// platform.
///
/// The default is `true`.
public var showsIndicators: Bool
/// Creates a new instance that's scrollable in the direction of the given
/// axis and can show indicators while scrolling.
///
/// - Parameters:
///   - axes: The scroll view's scrollable axis. The default axis is the
///     vertical axis.
///   - showsIndicators: A Boolean value that indicates whether the scroll
///     view displays the scrollable component of the content offset, in a way
///     suitable for the platform. The default value for this parameter is
///     `true`.
///   - content: The view builder that creates the scrollable view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use the ScrollView(_:content:) initializer and the scrollIndicators(:_) modifier")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use the ScrollView(_:content:) initializer and the scrollIndicators(:_) modifier")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use the ScrollView(_:content:) initializer and the scrollIndicators(:_) modifier")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use the ScrollView(_:content:) initializer and the scrollIndicators(:_) modifier")
public init(_ axes: Axis.Set = .vertical, showsIndicators: Bool = true, @ViewBuilder content: () -> Content)
/// The content and behavior of the scroll view.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
extension ScrollView {
/// Creates a new instance that's scrollable in the direction of the given
/// axis and can show indicators while scrolling.
///
/// - Parameters:
///   - axes: The scroll view's scrollable axis. The default axis is the
///     vertical axis.
///   - content: The view builder that creates the scrollable view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init(_ axes: Axis.Set = .vertical, @ViewBuilder content: () -> Content)
}
/// A proxy value that supports programmatic scrolling of the scrollable
/// views within a view hierarchy.
///
/// You don't create instances of `ScrollViewProxy` directly. Instead, your
/// ``ScrollViewReader`` receives an instance of `ScrollViewProxy` in its
/// `content` view builder. You use actions within this view builder, such
/// as button and gesture handlers or the ``View/onChange(of:perform:)``
/// method, to call the proxy's ``ScrollViewProxy/scrollTo(_:anchor:)`` method.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ScrollViewProxy {
/// Scans all scroll views contained by the proxy for the first
/// with a child view with identifier `id`, and then scrolls to
/// that view.
///
/// If `anchor` is `nil`, this method finds the container of the identified
/// view, and scrolls the minimum amount to make the identified view
/// wholly visible.
///
/// If `anchor` is non-`nil`, it defines the points in the identified
/// view and the scroll view to align. For example, setting `anchor` to
/// ``UnitPoint/top`` aligns the top of the identified view to the top of
/// the scroll view. Similarly, setting `anchor` to ``UnitPoint/bottom``
/// aligns the bottom of the identified view to the bottom of the scroll
/// view, and so on.
///
/// - Parameters:
///   - id: The identifier of a child view to scroll to.
///   - anchor: The alignment behavior of the scroll action.
public func scrollTo<ID>(_ id: ID, anchor: UnitPoint? = nil) where ID : Hashable
}
/// A view that provides programmatic scrolling, by working with a proxy
/// to scroll to known child views.
///
/// The scroll view reader's content view builder receives a ``ScrollViewProxy``
/// instance; you use the proxy's ``ScrollViewProxy/scrollTo(_:anchor:)`` to
/// perform scrolling.
///
/// The following example creates a ``ScrollView`` containing 100 views that
/// together display a color gradient. It also contains two buttons, one each
/// at the top and bottom. The top button tells the ``ScrollViewProxy`` to
/// scroll to the bottom button, and vice versa.
///
///     @Namespace var topID
///     @Namespace var bottomID
///
///     var body: some View {
///         ScrollViewReader { proxy in
///             ScrollView {
///                 Button("Scroll to Bottom") {
///                     withAnimation {
///                         proxy.scrollTo(bottomID)
///                     }
///                 }
///                 .id(topID)
///
///                 VStack(spacing: 0) {
///                     ForEach(0..<100) { i in
///                         color(fraction: Double(i) / 100)
///                             .frame(height: 32)
///                     }
///                 }
///
///                 Button("Top") {
///                     withAnimation {
///                         proxy.scrollTo(topID)
///                     }
///                 }
///                 .id(bottomID)
///             }
///         }
///     }
///
///     func color(fraction: Double) -> Color {
///         Color(red: fraction, green: 1 - fraction, blue: 0.5)
///     }
///
/// ![A scroll view, with a button labeled "Scroll to Bottom" at top.
/// Below this, a series of vertically aligned rows, each filled with a
/// color, that are progressing from green to
/// red.](SwiftUI-ScrollViewReader-scroll-to-bottom-button.png)
///
/// > Important: You may not use the ``ScrollViewProxy``
/// during execution of the `content` view builder; doing so results in a
/// runtime error. Instead, only actions created within `content` can call
/// the proxy, such as gesture handlers or a view's `onChange(of:perform:)`
/// method.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen public struct ScrollViewReader<Content> : View where Content : View {
/// The view builder that creates the reader's content.
public var content: (ScrollViewProxy) -> Content
/// Creates an instance that can perform programmatic scrolling of its
/// child scroll views.
///
/// - Parameter content: The reader's content, containing one or more
/// scroll views. This view builder receives a ``ScrollViewProxy``
/// instance that you use to perform scrolling.
@inlinable public init(@ViewBuilder content: @escaping (ScrollViewProxy) -> Content)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// The placement of a search field in a view hierarchy.
///
/// You can give a preferred placement to any of the searchable modifiers, like
/// ``View/searchable(text:placement:prompt:)-co5e``:
///
///     var body: some View {
///         NavigationView {
///             PrimaryView()
///             SecondaryView()
///             Text("Select a primary and secondary item")
///         }
///         .searchable(text: $text, placement: .sidebar)
///     }
///
/// Depending on the containing view hierachy, SwiftUI might not be able to
/// fulfill your request.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SearchFieldPlacement : Sendable {
/// SwiftUI places the search field automatically.
///
/// Placement of the search field depends on the platform:
/// * In iOS, iPadOS, and macOS, the search field appears in the toolbar.
/// * In tvOS and watchOS, the search field appears inline with its
///   content.
public static let automatic: SearchFieldPlacement
/// The search field appears in the toolbar.
///
/// The precise placement depends on the platform:
/// * In iOS and watchOS, the search field appears below the
///   navigation bar and is revealed by scrolling.
/// * In iPadOS, the search field appears in the trailing
///   navigation bar.
/// * In macOS, the search field appears in the trailing toolbar.
@available(tvOS, unavailable)
public static let toolbar: SearchFieldPlacement
/// The search field appears in the sidebar of a navigation view.
///
/// The precise placement depends on the platform:
/// * In iOS and iPadOS the search field appears in the section of
///   the navigation bar associated with the sidebar.
/// * In macOS, the search field appears inline with the sidebar's content.
///
/// If a sidebar isn't available, like when you apply the searchable
/// modifier to a view other than a navigation split view, SwiftUI uses
/// automatic placement instead.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static let sidebar: SearchFieldPlacement
/// The search field appears in the navigation bar.
///
/// The field appears below any navigation bar title and uses the
/// ``NavigationBarDrawerDisplayMode/automatic`` display mode to configure
/// when to hide the search field. To choose a different display mode,
/// use ``navigationBarDrawer(displayMode:)`` instead.
@available(iOS 15.0, watchOS 8.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public static let navigationBarDrawer: SearchFieldPlacement
/// The search field appears in the navigation bar using the specified
/// display mode.
///
/// The field appears below any navigation bar title. The system can
/// hide the field in response to scrolling, depending on the `displayMode`
/// that you set.
///
/// - Parameter displayMode: A control that indicates whether to hide
///   the search field in response to scrolling.
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static func navigationBarDrawer(displayMode: SearchFieldPlacement.NavigationBarDrawerDisplayMode) -> SearchFieldPlacement
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SearchFieldPlacement {
/// A mode that determines when to display a search field that appears in a
/// navigation bar.
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct NavigationBarDrawerDisplayMode : Sendable {
/// Enable hiding the search field in response to scrolling.
public static let automatic: SearchFieldPlacement.NavigationBarDrawerDisplayMode
/// Always display the search field regardless of the scroll activity.
public static let always: SearchFieldPlacement.NavigationBarDrawerDisplayMode
}
}
/// The ways that searchable modifiers can show or hide search scopes.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public struct SearchScopeActivation {
/// The automatic activation of the scope bar.
///
/// By default, this is ``SearchScopeActivation/onTextEntry``
/// in iOS and ``SearchScopeActivation/onSearchPresentation``
/// in macOS.
public static var automatic: SearchScopeActivation { get }
/// An activation where the system shows search scopes
/// when typing begins in the search field and hides
/// search scopes after search cancellation.
@available(tvOS, unavailable)
public static var onTextEntry: SearchScopeActivation { get }
/// An activation where the system shows search scopes after
/// presenting search and hides search scopes after search
/// cancellation.
@available(tvOS, unavailable)
public static var onSearchPresentation: SearchScopeActivation { get }
}
/// The ways that SwiftUI displays search suggestions.
///
/// You can influence which modes SwiftUI displays search suggestions for by
/// using the ``View/searchSuggestions(_:for:)`` modifier:
///
///     enum FruitSuggestion: String, Identifiable {
///         case apple, banana, orange
///         var id: Self { self }
///     }
///
///     @State private var text = ""
///     @State private var suggestions: [FruitSuggestion] = []
///
///     var body: some View {
///         MainContent()
///             .searchable(text: $text) {
///                 ForEach(suggestions) { suggestion in
///                     Text(suggestion.rawValue)
///                         .searchCompletion(suggestion.rawValue)
///                 }
///                 .searchSuggestions(.hidden, for: .content)
///             }
///     }
///
/// In the above example, SwiftUI only displays search suggestions in
/// a suggestions menu. You might want to do this when you want to
/// render search suggestions in a container, like inline with
/// your own set of search results.
///
/// You can get the current search suggestion placement by querying the
/// ``EnvironmentValues/searchSuggestionsPlacement`` environment value in your
/// search suggestions.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct SearchSuggestionsPlacement : Equatable, Sendable {
/// Search suggestions render automatically based on the surrounding
/// context.
///
/// The behavior varies by platform:
/// * In iOS and iPadOS, suggestions render as a list overlaying the main
///   content of the app.
/// * In macOS, suggestions render in a menu.
/// * In tvOS, suggestions render as a row underneath the search field.
/// * In watchOS, suggestions render in a list pushed onto the containing
///   navigation stack.
public static var automatic: SearchSuggestionsPlacement { get }
/// Search suggestions render inside of a menu attached to the search field.
public static var menu: SearchSuggestionsPlacement { get }
/// Search suggestions render in the main content of the app.
public static var content: SearchSuggestionsPlacement { get }
/// An efficient set of search suggestion display modes.
public struct Set : OptionSet, Sendable {
/// A type for the elements of the set.
public typealias Element = SearchSuggestionsPlacement.Set
/// The raw value that records the search suggestion display modes.
public var rawValue: Int
/// A set containing the menu display mode.
public static var menu: SearchSuggestionsPlacement.Set { get }
/// A set containing placements with the apps main content, excluding
/// the menu placement.
public static var content: SearchSuggestionsPlacement.Set { get }
/// Creates a set of search suggestions from an integer.
public init(rawValue: Int)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = SearchSuggestionsPlacement.Set.Element
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SearchSuggestionsPlacement, b: SearchSuggestionsPlacement) -> Bool
}
/// A structure that represents the body of a static placeholder search view.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a search``ContentUnavailableView``.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct SearchUnavailableContent {
/// A view that represents the label of a static placeholder search view.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a search``ContentUnavailableView``.
public struct Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A view that represents the description of a static `ContentUnavailableView.search` view.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a search``ContentUnavailableView`.
public struct Description : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A view that represents the actions of a static `ContentUnavailableView.search` view.
///
/// You don't create this type directly. SwiftUI creates it when you build
/// a search``ContentUnavailableView``.
public struct Actions : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
}
/// A container view that you can use to add hierarchy to certain collection views.
///
/// Use `Section` instances in views like ``List``, ``Picker``, and
/// ``Form`` to organize content into separate sections. Each section has
/// custom content that you provide on a per-instance basis. You can also
/// provide headers and footers for each section.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Section<Parent, Content, Footer> {
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Section : TableRowContent where Parent : TableRowContent, Content : TableRowContent, Footer : TableRowContent {
/// The type of value represented by this table row content.
public typealias TableRowValue = Content.TableRowValue
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// Creates a section with a header and the provided section content.
/// - Parameters:
///   - content: The section's content.
///   - header: A view to use as the section's header.
public init<V, H>(@TableRowBuilder<V> content: () -> Content, @ViewBuilder header: () -> H) where Parent == TableHeaderRowContent<V, H>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue, H : View
/// Creates a section with the provided section content.
/// - Parameters:
///   - titleKey: The key for the section's localized title, which describes
///     the contents of the section.
///   - content: The section's content.
public init<V>(_ titleKey: LocalizedStringKey, @TableRowBuilder<V> content: () -> Content) where Parent == TableHeaderRowContent<V, Text>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue
/// Creates a section with the provided section content.
/// - Parameters:
///   - title: A string that describes the contents of the section.
///   - content: The section's content.
public init<V, S>(_ title: S, @TableRowBuilder<V> content: () -> Content) where Parent == TableHeaderRowContent<V, Text>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue, S : StringProtocol
/// Creates a section with the provided section content.
/// - Parameters:
///   - content: The section's content.
public init<V>(@TableRowBuilder<V> content: () -> Content) where Parent == EmptyTableRowContent<V>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Section where Parent : TableRowContent, Content : TableRowContent {
/// Creates a section with a header and the provided section content.
/// - Parameters:
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
///   - header: A view to use as the section's header.
public init<V, H>(isExpanded: Binding<Bool>, @TableRowBuilder<V> content: () -> Content, @ViewBuilder header: () -> H) where Parent == TableHeaderRowContent<V, H>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue, H : View
/// Creates a section with the provided section content.
/// - Parameters:
///   - titleKey: The key for the section's localized title, which describes
///     the contents of the section.
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
public init<V>(_ titleKey: LocalizedStringKey, isExpanded: Binding<Bool>, @TableRowBuilder<V> content: () -> Content) where Parent == TableHeaderRowContent<V, Text>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue
/// Creates a section with the provided section content.
/// - Parameters:
///   - title: A string that describes the contents of the section.
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
public init<V, S>(_ title: S, isExpanded: Binding<Bool>, @TableRowBuilder<V> content: () -> Content) where Parent == TableHeaderRowContent<V, Text>, Footer == EmptyTableRowContent<V>, V == Content.TableRowValue, S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section : View where Parent : View, Content : View, Footer : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent : View, Content : View, Footer : View {
/// Creates a section with a header, footer, and the provided section
/// content.
///
/// - Parameters:
///   - content: The section's content.
///   - header: A view to use as the section's header.
///   - footer: A view to use as the section's footer.
public init(@ViewBuilder content: () -> Content, @ViewBuilder header: () -> Parent, @ViewBuilder footer: () -> Footer)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent == EmptyView, Content : View, Footer : View {
/// Creates a section with a footer and the provided section content.
/// - Parameters:
///   - content: The section's content.
///   - footer: A view to use as the section's footer.
public init(@ViewBuilder content: () -> Content, @ViewBuilder footer: () -> Footer)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent : View, Content : View, Footer == EmptyView {
/// Creates a section with a header and the provided section content.
/// - Parameters:
///   - content: The section's content.
///   - header: A view to use as the section's header.
public init(@ViewBuilder content: () -> Content, @ViewBuilder header: () -> Parent)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent == EmptyView, Content : View, Footer == EmptyView {
/// Creates a section with the provided section content.
/// - Parameters:
///   - content: The section's content.
public init(@ViewBuilder content: () -> Content)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Section where Parent == Text, Content : View, Footer == EmptyView {
/// Creates a section with the provided section content.
/// - Parameters:
///   - titleKey: The key for the section's localized title, which describes
///     the contents of the section.
///   - content: The section's content.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content)
/// Creates a section with the provided section content.
/// - Parameters:
///   - title: A string that describes the contents of the section.
///   - content: The section's content.
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, visionOS 1.0, *)
extension Section where Parent == Text, Content : View, Footer == EmptyView {
/// Creates a section with the provided section content.
/// - Parameters:
///   - titleKey: The key for the section's localized title, which describes
///     the contents of the section.
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
public init(_ titleKey: LocalizedStringKey, isExpanded: Binding<Bool>, @ViewBuilder content: () -> Content)
/// Creates a section with the provided section content.
/// - Parameters:
///   - title: A string that describes the contents of the section.
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
public init<S>(_ title: S, isExpanded: Binding<Bool>, @ViewBuilder content: () -> Content) where S : StringProtocol
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, visionOS 1.0, *)
extension Section where Parent : View, Content : View, Footer == EmptyView {
/// Creates a section with a header, the provided section content, and a binding
/// representing the section's expansion state.
///
/// - Parameters:
///   - isExpanded: A binding to a Boolean value that determines the section's
///    expansion state (expanded or collapsed).
///   - content: The section's content.
///   - header: A view to use as the section's header.
public init(isExpanded: Binding<Bool>, @ViewBuilder content: () -> Content, @ViewBuilder header: () -> Parent)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent : View, Content : View, Footer : View {
/// Creates a section with a header, footer, and the provided section content.
/// - Parameters:
///   - header: A view to use as the section's header.
///   - footer: A view to use as the section's footer.
///   - content: The section's content.
@available(iOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)")
@available(macOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)")
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)")
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)")
@available(visionOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)")
public init(header: Parent, footer: Footer, @ViewBuilder content: () -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent == EmptyView, Content : View, Footer : View {
/// Creates a section with a footer and the provided section content.
/// - Parameters:
///   - footer: A view to use as the section's footer.
///   - content: The section's content.
@available(iOS, deprecated: 100000.0, renamed: "Section(content:footer:)")
@available(macOS, deprecated: 100000.0, renamed: "Section(content:footer:)")
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:footer:)")
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:footer:)")
@available(visionOS, deprecated: 100000.0, renamed: "Section(content:footer:)")
public init(footer: Footer, @ViewBuilder content: () -> Content)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Section where Parent : View, Content : View, Footer == EmptyView {
/// Creates a section with a header and the provided section content.
/// - Parameters:
///   - header: A view to use as the section's header.
///   - content: The section's content.
@available(iOS, deprecated: 100000.0, renamed: "Section(content:header:)")
@available(macOS, deprecated: 100000.0, renamed: "Section(content:header:)")
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:header:)")
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:header:)")
@available(visionOS, deprecated: 100000.0, renamed: "Section(content:header:)")
public init(header: Parent, @ViewBuilder content: () -> Content)
}
/// A property wrapper type that retrieves entities, grouped into sections,
/// from a Core Data persistent store.
///
/// Use a `SectionedFetchRequest` property wrapper to declare a
/// ``SectionedFetchResults`` property that provides a grouped collection of
/// Core Data managed objects to a SwiftUI view. If you don't need sectioning,
/// use ``FetchRequest`` instead.
///
/// Configure a sectioned fetch request with an optional predicate and sort
/// descriptors, and include a `sectionIdentifier` parameter to indicate how
/// to group the fetched results. Be sure that you choose sorting and sectioning
/// that work together to avoid discontiguous sections. For example, you can
/// request a list of earthquakes, composed of `Quake` managed objects that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data, sorted by time and
/// grouped by date:
///
///     @SectionedFetchRequest<String, Quake>(
///         sectionIdentifier: \.day,
///         sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
///     )
///     private var quakes: SectionedFetchResults<String, Quake>
///
/// Always declare properties that have a sectioned fetch request wrapper as
/// private. This lets the compiler help you avoid accidentally setting
/// the property from the memberwise initializer of the enclosing view.
///
/// The request infers the entity type from the `Result` type that you specify,
/// which is `Quake` in the example above. Indicate a `SectionIdentifier` type
/// to declare the type found at the fetched object's `sectionIdentifier`
/// key path. The section identifier type must conform to the
/// <doc://com.apple.documentation/documentation/Swift/Hashable> protocol.
///
/// The example above depends on the `Quake` type having a `day` property that's
/// either a stored or computed string. Be sure to mark any computed property
/// with the `@objc` attribute for it to function as a section identifier.
/// For best performance with large data sets, use stored properties.
///
/// The sectioned fetch request and its results use the managed object context
/// stored in the environment, which you can access using the
/// ``EnvironmentValues/managedObjectContext`` environment value. To
/// support user interface activity, you typically rely on the
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer/1640622-viewContext>
/// property of a shared
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer>
/// instance. For example, you can set a context on your top-level content
/// view using a shared container that you define as part of your model:
///
///     ContentView()
///         .environment(
///             \.managedObjectContext,
///             QuakesProvider.shared.container.viewContext)
///
/// When you need to dynamically change the section identifier, predicate,
/// or sort descriptors, access the request's
/// ``SectionedFetchRequest/Configuration`` structure, either directly or with
/// a binding.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@MainActor @propertyWrapper public struct SectionedFetchRequest<SectionIdentifier, Result> where SectionIdentifier : Hashable, Result : NSFetchRequestResult {
/// The fetched results of the fetch request.
///
/// This property behaves like the ``FetchRequest/wrappedValue`` of a
/// ``FetchRequest``. In particular, SwiftUI returns the value associated
/// with this property when you use ``SectionedFetchRequest`` as a property
/// wrapper and then access the wrapped property by name. For example,
/// consider the following `quakes` property declaration that fetches a
/// `Quake` type that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines:
///
///     @SectionedFetchRequest<String, Quake>(
///         sectionIdentifier: \.day,
///         sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
///     )
///     private var quakes: SectionedFetchResults<String, Quake>
///
/// You access the request's `wrappedValue`, which contains a
/// ``SectionedFetchResults`` instance, by referring to the `quakes`
/// property by name. That value is a collection
/// of sections, each of which contains a group of managed objects:
///
///     Text("Found \(quakes.count) days of earthquakes")
///
/// If you need to separate the request and the result
/// entities, you can declare `quakes` in two steps by
/// using the request's `wrappedValue` to obtain the results:
///
///     var fetchRequest = SectionedFetchRequest<String, Quake>(
///         fetchRequest: request,
///         sectionIdentifier: \.day)
///     var quakes: SectionedFetchedResults<String, Quake> { fetchRequest.wrappedValue }
///
/// The `wrappedValue` property returns an empty array when there are no
/// fetched results; for example, because no entities satisfy the
/// predicate, or because the data store is empty.
@MainActor public var wrappedValue: SectionedFetchResults<SectionIdentifier, Result> { get }
/// The request's configurable properties.
///
/// You initialize a ``SectionedFetchRequest`` with a section identifier,
/// an optional predicate, and sort descriptors, either explicitly or with
/// a configured
/// <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>.
/// Later, you can dynamically update the identifier, predicate, and sort
/// parameters using the request's configuration structure.
///
/// You access or bind to a request's configuration components through
/// properties on the associated ``SectionedFetchResults`` instance,
/// just like you do for a ``FetchRequest`` using
/// ``FetchRequest/Configuration``.
///
/// When configuring a sectioned fetch request, ensure that the
/// combination of the section identifier and the primary sort descriptor
/// doesn't create discontiguous sections.
public struct Configuration {
/// The request's section identifier key path.
///
/// Set this configuration value to cause a ``SectionedFetchRequest``
/// to execute a fetch with a new section identifier. You can't change
/// the section identifier type without creating a new fetch request.
/// Use care to coordinate section and sort updates, as described
/// in ``SectionedFetchRequest/Configuration``.
///
/// Access this value for a given request by using the
/// ``SectionedFetchResults/sectionIdentifier`` property on the
/// associated ``SectionedFetchResults`` instance, either directly or
/// with a ``Binding``.
public var sectionIdentifier: KeyPath<Result, SectionIdentifier>
/// The request's sort descriptors, accessed as reference types.
///
/// Set this configuration value to cause a ``SectionedFetchRequest``
/// to execute a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances. If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances, set ``SectionedFetchRequest/Configuration/sortDescriptors``
/// instead. Use care to coordinate section and sort updates, as
/// described in ``SectionedFetchRequest/Configuration``.
///
/// Access this value for a given request by using the
/// ``SectionedFetchResults/nsSortDescriptors`` property on the
/// associated ``SectionedFetchResults`` instance, either directly or
/// with a ``Binding``.
public var nsSortDescriptors: [NSSortDescriptor]
/// The request's predicate.
///
/// Set this configuration value to cause a ``SectionedFetchRequest``
/// to execute a fetch with a new predicate.
///
/// Access this value for a given request by using the
/// ``SectionedFetchResults/nsPredicate`` property on the associated
/// ``SectionedFetchResults`` instance, either directly or with a
/// ``Binding``.
public var nsPredicate: NSPredicate?
}
/// A binding to the request's mutable configuration properties.
///
/// This property behaves like the ``FetchRequest/projectedValue``
/// of a ``FetchRequest``. In particular,
/// SwiftUI returns the value associated with this property when you use
/// ``SectionedFetchRequest`` as a property wrapper on a
/// ``SectionedFetchResults`` instance and then access the results with
/// a dollar sign (`$`) prefix. The value that SwiftUI returns is a
/// ``Binding`` to the request's ``SectionedFetchRequest/Configuration``
/// structure, which dynamically configures the request.
@MainActor public var projectedValue: Binding<SectionedFetchRequest<SectionIdentifier, Result>.Configuration> { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SectionedFetchRequest : DynamicProperty {
/// Updates the fetched results.
///
/// SwiftUI calls this function before rendering a view's
/// ``View/body-swift.property`` to ensure the view has the most recent
/// fetched results.
@MainActor public func update()
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SectionedFetchRequest {
/// Creates a sectioned fetch request for a specified entity description,
/// based on a section identifier, a predicate, and sort parameters.
///
/// Use this initializer if you need to explicitly specify the entity type
/// for the request. If you specify a placeholder `Result` type in the
/// request declaration, use the
/// ``init(sectionIdentifier:sortDescriptors:predicate:animation:)-5lpfo``
/// initializer to let the request infer the entity type. If you need more
/// control over the fetch request configuration, use
/// ``init(fetchRequest:sectionIdentifier:animation:)``.
///
/// - Parameters:
///   - entity: The description of the Core Data entity to fetch.
///   - sectionIdentifier: A key path that SwiftUI applies to the `Result`
///     type to get an object's section identifier.
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(entity: NSEntityDescription, sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil)
/// Creates a fully configured sectioned fetch request that uses the
/// specified animation when updating results.
///
/// Use this initializer when you want to configure a fetch
/// request with more than a predicate and sort descriptors.
/// For example, you can vend a request from a `Quake` managed object
/// that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data.
/// Limit the number of results to `1000` by setting a
/// <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest/1506622-fetchLimit>
/// for the request:
///
///     extension Quake {
///         var request: NSFetchRequest<Quake> {
///             let request = NSFetchRequest<Quake>(entityName: "Quake")
///             request.sortDescriptors = [
///                 NSSortDescriptor(
///                     keyPath: \Quake.time,
///                     ascending: true)]
///             request.fetchLimit = 1000
///             return request
///         }
///     }
///
/// Use the request to define a ``SectionedFetchedResults`` property:
///
///     @SectionedFetchRequest<String, Quake>(
///         fetchRequest: Quake.request,
///         sectionIdentifier: \.day)
///     private var quakes: FetchedResults<String, Quake>
///
/// If you only need to configure the request's section identifier,
/// predicate, and sort descriptors, use
/// ``init(sectionIdentifier:sortDescriptors:predicate:animation:)-5lpfo``
/// instead. If you need to specify a ``Transaction`` rather than an
/// optional ``Animation``, use
/// ``init(fetchRequest:sectionIdentifier:transaction:)``.
///
/// - Parameters:
///   - fetchRequest: An
///     <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
///     instance that describes the search criteria for retrieving data
///     from the persistent store.
///   - sectionIdentifier: A key path that SwiftUI applies to the `Result`
///     type to get an object's section identifier.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(fetchRequest: NSFetchRequest<Result>, sectionIdentifier: KeyPath<Result, SectionIdentifier>, animation: Animation? = nil)
/// Creates a fully configured sectioned fetch request that uses the
/// specified transaction when updating results.
///
/// Use this initializer if you need a fetch request with updates that
/// affect the user interface based on a ``Transaction``. Otherwise, use
/// ``init(fetchRequest:sectionIdentifier:animation:)``.
///
/// - Parameters:
///   - fetchRequest: An
///     <doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
///     instance that describes the search criteria for retrieving data
///     from the persistent store.
///   - sectionIdentifier: A key path that SwiftUI applies to the `Result`
///     type to get an object's section identifier.
///   - transaction: A transaction to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(fetchRequest: NSFetchRequest<Result>, sectionIdentifier: KeyPath<Result, SectionIdentifier>, transaction: Transaction)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SectionedFetchRequest where Result : NSManagedObject {
/// Creates a sectioned fetch request based on a section identifier, a
/// predicate, and reference type sort parameters.
///
/// The request gets the entity type from the `Result` instance by calling
/// that managed object's
/// <doc://com.apple.documentation/documentation/CoreData/NSManagedObject/1640588-entity>
/// type method. If you need to specify the entity type explicitly, use the
/// ``init(entity:sectionIdentifier:sortDescriptors:predicate:animation:)``
/// initializer instead. If you need more control over the fetch request
/// configuration, use ``init(fetchRequest:sectionIdentifier:animation:)``.
/// For value type sort descriptors, use
/// ``init(sectionIdentifier:sortDescriptors:predicate:animation:)-5l7hu``.
///
/// - Parameters:
///   - sectionIdentifier: A key path that SwiftUI applies to the `Result`
///     type to get an object's section identifier.
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil)
/// Creates a sectioned fetch request based on a section identifier,
/// a predicate, and value type sort parameters.
///
/// The request gets the entity type from the `Result` instance by calling
/// that managed object's
/// <doc://com.apple.documentation/documentation/CoreData/NSManagedObject/1640588-entity>
/// type method. If you need to specify the entity type explicitly, use the
/// ``init(entity:sectionIdentifier:sortDescriptors:predicate:animation:)``
/// initializer instead. If you need more control over the fetch request
/// configuration, use ``init(fetchRequest:sectionIdentifier:animation:)``.
/// For reference type sort descriptors, use
/// ``init(sectionIdentifier:sortDescriptors:predicate:animation:)-5lpfo``.
///
/// - Parameters:
///   - sectionIdentifier: A key path that SwiftUI applies to the `Result`
///     type to get an object's section identifier.
///   - sortDescriptors: An array of sort descriptors that define the sort
///     order of the fetched results.
///   - predicate: An
///     <doc://com.apple.documentation/documentation/Foundation/NSPredicate>
///     instance that defines logical conditions used to filter the fetched
///     results.
///   - animation: The animation to use for user interface changes that
///     result from changes to the fetched results.
@MainActor public init(sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [SortDescriptor<Result>], predicate: NSPredicate? = nil, animation: Animation? = nil)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SectionedFetchRequest.Configuration where Result : NSManagedObject {
/// The request's sort descriptors, accessed as value types.
///
/// Set this configuration value to cause a ``SectionedFetchRequest`` to
/// execute a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances. If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances, set ``SectionedFetchRequest/Configuration/nsSortDescriptors``
/// instead. Use care to coordinate section and sort updates, as described
/// in ``SectionedFetchRequest/Configuration``.
///
/// Access this value for a given request by using the
/// ``SectionedFetchResults/sortDescriptors`` property on the associated
/// ``SectionedFetchResults`` instance, either directly or with a
/// ``Binding``.
public var sortDescriptors: [SortDescriptor<Result>]
}
/// A collection of results retrieved from a Core Data persistent store,
/// grouped into sections.
///
/// Use a `SectionedFetchResults` instance to show or edit Core Data managed
/// objects, grouped into sections, in your app's user interface. If you
/// don't need sectioning, use ``FetchedResults`` instead.
///
/// You request a particular set of results by annotating the fetched results
/// property declaration with a ``SectionedFetchRequest`` property wrapper.
/// Indicate the type of the fetched entities with a `Results` type,
/// and the type of the identifier that distinguishes the sections with
/// a `SectionIdentifier` type. For example, you can create a request to list
/// all `Quake` managed objects that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data, sorted by their `time`
/// property and grouped by a string that represents the days when earthquakes
/// occurred:
///
///     @SectionedFetchRequest<String, Quake>(
///         sectionIdentifier: \.day,
///         sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
///     )
///     private var quakes: SectionedFetchResults<String, Quake>
///
/// The `quakes` property acts as a collection of ``Section`` instances, each
/// containing a collection of `Quake` instances. The example above depends
/// on the `Quake` model object declaring both `time` and `day`
/// properties, either stored or computed. For best performance with large
/// data sets, use stored properties.
///
/// The collection of sections, as well as the collection of managed objects in
/// each section, conforms to the
/// <doc://com.apple.documentation/documentation/Swift/RandomAccessCollection>
/// protocol, so you can access them as you would any other collection. For
/// example, you can create nested ``ForEach`` loops inside a ``List`` to
/// iterate over the results:
///
///     List {
///         ForEach(quakes) { section in
///             Section(header: Text(section.id)) {
///                 ForEach(section) { quake in
///                     QuakeRow(quake: quake) // Displays information about a quake.
///                 }
///             }
///         }
///     }
///
/// Don't confuse the ``SwiftUI/Section`` view that you use to create a
/// hierarchical display with the ``SectionedFetchResults/Section``
/// instances that hold the fetched results.
///
/// When you need to dynamically change the request's section identifier,
/// predicate, or sort descriptors, set the result instance's
/// ``sectionIdentifier``, ``nsPredicate``, and ``sortDescriptors`` or
/// ``nsSortDescriptors`` properties, respectively. Be sure that the sorting
/// and sectioning work together to avoid discontinguous sections.
///
/// The fetch request and its results use the managed object context stored
/// in the environment, which you can access using the
/// ``EnvironmentValues/managedObjectContext`` environment value. To
/// support user interface activity, you typically rely on the
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer/1640622-viewContext>
/// property of a shared
/// <doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer>
/// instance. For example, you can set a context on your top-level content
/// view using a container that you define as part of your model:
///
///     ContentView()
///         .environment(
///             \.managedObjectContext,
///             QuakesProvider.shared.container.viewContext)
///
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SectionedFetchResults<SectionIdentifier, Result> : RandomAccessCollection where SectionIdentifier : Hashable, Result : NSFetchRequestResult {
/// A collection of fetched results that share a specified identifier.
///
/// Examine a `Section` instance to find the entities that satisfy a
/// ``SectionedFetchRequest`` predicate, and that have a particular property
/// with the value stored in the section's ``id-swift.property-1h7qm``
/// parameter. You specify which property by setting the fetch request's
/// `sectionIdentifier` parameter during initialization, or by modifying
/// the corresponding ``SectionedFetchResults`` instance's
/// ``SectionedFetchResults/sectionIdentifier`` property.
///
/// Obtain specific sections by treating the fetch results as a collection.
/// For example, consider the following property declaration
/// that fetches `Quake` managed objects that the
/// <doc://com.apple.documentation/documentation/CoreData/loading_and_displaying_a_large_data_feed>
/// sample code project defines to store earthquake data:
///
///     @SectionedFetchRequest<String, Quake>(
///         sectionIdentifier: \.day,
///         sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
///     )
///     private var quakes: SectionedFetchResults<String, Quake>
///
/// Get the first section using a subscript:
///
///     let firstSection = quakes[0]
///
/// Alternatively, you can loop over the sections to create a list of
/// sections.
///
///     ForEach(quakes) { section in
///         Text("Section \(section.id) has \(section.count) elements")
///     }
///
/// The sections also act as collections, which means
/// you can use elements like the
/// <doc://com.apple.documentation/documentation/Swift/Collection/count-4l4qk>
/// property in the example above.
public struct Section : Identifiable, RandomAccessCollection {
/// The index of the first entity in the section.
public var startIndex: Int { get }
/// The index that's one greater than that of the last entity in the
/// section.
public var endIndex: Int { get }
/// Gets the entity at the specified index within the section.
public subscript(position: Int) -> Result { get }
/// The value that all entities in the section share for a specified
/// key path.
///
/// Specify the key path that the entities share this value with
/// by setting the ``SectionedFetchRequest``
/// instance's `sectionIdentifier` parameter during initialization,
/// or by modifying the corresponding ``SectionedFetchResults``
/// instance's ``SectionedFetchResults/sectionIdentifier`` property.
public let id: SectionIdentifier
/// A type representing the sequence's elements.
public typealias Element = Result
/// A type representing the stable identity of the entity associated with
/// an instance.
public typealias ID = SectionIdentifier
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public typealias Index = Int
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = Range<Int>
/// A type that provides the collection's iteration interface and
/// encapsulates its iteration state.
///
/// By default, a collection conforms to the `Sequence` protocol by
/// supplying `IndexingIterator` as its associated `Iterator`
/// type.
public typealias Iterator = IndexingIterator<SectionedFetchResults<SectionIdentifier, Result>.Section>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<SectionedFetchResults<SectionIdentifier, Result>.Section>
}
/// The request's sort descriptors, accessed as reference types.
///
/// Set this value to cause the associated ``SectionedFetchRequest`` to
/// execute a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances.
/// The order of managed objects stored in the results collection may change
/// as a result. Use care to coordinate section and sort updates, as
/// described in ``SectionedFetchRequest/Configuration``.
///
/// If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances, set ``SectionedFetchResults/sortDescriptors`` instead.
public var nsSortDescriptors: [NSSortDescriptor] { get nonmutating set }
/// The request's predicate.
///
/// Set this value to cause the associated ``SectionedFetchRequest`` to
/// execute a fetch with a new predicate, producing an updated collection
/// of results.
public var nsPredicate: NSPredicate? { get nonmutating set }
/// The key path that the system uses to group fetched results into sections.
///
/// Set this value to cause the associated ``SectionedFetchRequest`` to
/// execute a fetch with a new section identifier, producing an updated
/// collection of results. Changing this value produces a new set of
/// sections. Use care to coordinate section and sort updates, as described
/// in ``SectionedFetchRequest/Configuration``.
public var sectionIdentifier: KeyPath<Result, SectionIdentifier> { get nonmutating set }
/// The index of the first section in the results collection.
public var startIndex: Int { get }
/// The index that's one greater than that of the last section.
public var endIndex: Int { get }
/// Gets the section at the specified index.
public subscript(position: Int) -> SectionedFetchResults<SectionIdentifier, Result>.Section { get }
/// A type representing the sequence's elements.
public typealias Element = SectionedFetchResults<SectionIdentifier, Result>.Section
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public typealias Index = Int
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = Range<Int>
/// A type that provides the collection's iteration interface and
/// encapsulates its iteration state.
///
/// By default, a collection conforms to the `Sequence` protocol by
/// supplying `IndexingIterator` as its associated `Iterator`
/// type.
public typealias Iterator = IndexingIterator<SectionedFetchResults<SectionIdentifier, Result>>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<SectionedFetchResults<SectionIdentifier, Result>>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension SectionedFetchResults where Result : NSManagedObject {
/// The request's sort descriptors, accessed as value types.
///
/// Set this value to cause the associated ``SectionedFetchRequest`` to
/// execute a fetch with a new collection of
/// <doc://com.apple.documentation/documentation/Foundation/SortDescriptor>
/// instances. The order of entities stored in the results collection may
/// change as a result. Use care to coordinate section and sort updates, as
/// described in ``SectionedFetchRequest/Configuration``.
///
/// If you want to use
/// <doc://com.apple.documentation/documentation/Foundation/NSSortDescriptor>
/// instances, set ``SectionedFetchResults/nsSortDescriptors`` instead.
public var sortDescriptors: [SortDescriptor<Result>] { get nonmutating set }
}
/// A control into which the user securely enters private text.
///
/// Use a `SecureField` when you want behavior similar to a ``TextField``, but
/// you don't want the user's text to be visible. Typically, you use this for
/// entering passwords and other sensitive information.
///
/// A `SecureField` uses a binding to a string value, and a closure that
/// executes when the user commits their edits, such as by pressing the
/// Return key. The field updates the bound string on every keystroke or
/// other edit, so you can read its value at any time from another control,
/// such as a Done button.
///
/// The following example shows a `SecureField` bound to the string `password`.
/// If the user commits their edit in the secure field, the `onCommit` closure
/// sends the password string to a `handleLogin()` method.
///
///     @State private var username: String = ""
///     @State private var password: String = ""
///
///     var body: some View {
///         TextField(
///             "User name (email address)",
///             text: $username)
///             .autocapitalization(.none)
///             .disableAutocorrection(true)
///             .border(Color(UIColor.separator))
///         SecureField(
///             "Password",
///             text: $password
///         ) {
///             handleLogin(username: username, password: password)
///         }
///         .border(Color(UIColor.separator))
///     }
///
/// ![Two vertically arranged views, the first a text field that displays the
/// email address mruiz2@icloud.com, the second view uses bullets in place of
/// the characters entered by the user for their password
/// password.](SwiftUI-SecureField-withTextField.png)
///
/// ### SecureField prompts
///
/// A secure field may be provided an explicit prompt to guide users on what
/// text they should provide. The context in which a secure field appears
/// determines where and when a prompt and label may be used. For example, a
/// form on macOS will always place the label alongside the leading edge of
/// the field and will use a prompt, when available, as placeholder text within
/// the field itself. In the same context on iOS, the prompt or label will
/// be used as placeholder text depending on whether a prompt is provided.
///
///     Form {
///         TextField(text: $username, prompt: Text("Required")) {
///             Text("Username")
///         }
///         SecureField(text: $username, prompt: Text("Required")) {
///             Text("Password")
///        }
///     }
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct SecureField<Label> : View where Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
extension SecureField where Label == Text {
/// Creates a secure field with a prompt generated from a `Text`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this secure field.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - text: The text to display and edit
///   - prompt: A `Text` representing the prompt of the secure field
///     which provides users with guidance on what to type into the secure
///     field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, prompt: Text?)
/// Creates a secure field with a prompt generated from a `Text`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this secure field.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the secure field
///     which provides users with guidance on what to type into the secure
///     field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<S>(_ title: S, text: Binding<String>, prompt: Text?) where S : StringProtocol
}
extension SecureField {
/// Creates a secure field with a prompt generated from a `Text`.
///
/// - Parameters:
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the secure field
///     which provides users with guidance on what to type into the secure
///     field.
///   - label: A view that describes the purpose of the secure field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init(text: Binding<String>, prompt: Text? = nil, @ViewBuilder label: () -> Label)
}
extension SecureField where Label == Text {
/// Creates a secure field with a prompt generated from a `Text`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this secure field.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - text: The text to display and edit
///   - prompt: A `Text` representing the prompt of the secure field
///     which provides users with guidance on what to type into the secure
///     field.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>)
/// Creates a secure field with a prompt generated from a `Text`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this secure field.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the secure field
///     which provides users with guidance on what to type into the secure
///     field.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init<S>(_ title: S, text: Binding<String>) where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SecureField where Label == Text {
/// Creates an instance.
///
/// - Parameters:
///   - titleKey: The key for the localized title of `self`, describing
///     its purpose.
///   - text: The text to display and edit.
///   - onCommit: The action to perform when the user performs an action
///     (usually pressing the Return key) while the secure field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onCommit: @escaping () -> Void)
/// Creates an instance.
///
/// - Parameters:
///   - title: The title of `self`, describing its purpose.
///   - text: The text to display and edit.
///   - onCommit: The action to perform when the user performs an action
///     (usually pressing the Return key) while the secure field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.")
public init<S>(_ title: S, text: Binding<String>, onCommit: @escaping () -> Void) where S : StringProtocol
}
/// A picker style that presents the options in a segmented control.
///
/// You can also use ``PickerStyle/segmented`` to construct this style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
@available(watchOS, unavailable)
public struct SegmentedPickerStyle : PickerStyle {
/// Creates a segmented picker style.
public init()
}
/// A style used to visually indicate selection following platform conventional
/// colors and behaviors.
///
/// You can also use ``ShapeStyle/selection`` to construct this style.
@available(iOS 15.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct SelectionShapeStyle : ShapeStyle {
/// Creates a selection shape style.
@available(macOS 12.0, *)
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// Represents a type of haptic and/or audio feedback that can be played.
///
/// This feedback can be passed to `View.sensoryFeedback` to play it.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@available(visionOS, unavailable)
public struct SensoryFeedback : Equatable, Sendable {
/// Indicates that a task or action has completed.
///
/// Only plays feedback on iOS and watchOS.
public static let success: SensoryFeedback
/// Indicates that a task or action has produced a warning of some kind.
///
/// Only plays feedback on iOS and watchOS.
public static let warning: SensoryFeedback
/// Indicates that an error has occurred.
///
/// Only plays feedback on iOS and watchOS.
public static let error: SensoryFeedback
/// Indicates that a UI element’s values are changing.
///
/// Only plays feedback on iOS and watchOS.
public static let selection: SensoryFeedback
/// Indicates that an important value increased above a significant
/// threshold.
///
/// Only plays feedback on watchOS.
public static let increase: SensoryFeedback
/// Indicates that an important value decreased below a significant
/// threshold.
///
/// Only plays feedback on watchOS.
public static let decrease: SensoryFeedback
/// Indicates that an activity started.
///
/// Use this haptic when starting a timer or any other activity that can be
/// explicitly started and stopped.
///
/// Only plays feedback on watchOS.
public static let start: SensoryFeedback
/// Indicates that an activity stopped.
///
/// Use this haptic when stopping a timer or other activity that was
/// previously started.
///
/// Only plays feedback on watchOS.
public static let stop: SensoryFeedback
/// Indicates the alignment of a dragged item.
///
/// For example, use this pattern in a drawing app when the user drags a
/// shape into alignment with another shape.
///
/// Only plays feedback on macOS.
public static let alignment: SensoryFeedback
/// Indicates movement between discrete levels of pressure.
///
/// For example, as the user presses a fast-forward button on a video
/// player, playback could increase or decrease and haptic feedback could be
/// provided as different levels of pressure are reached.
///
/// Only plays feedback on macOS.
public static let levelChange: SensoryFeedback
/// Provides a physical metaphor you can use to complement a visual
/// experience.
///
/// Use this to provide feedback for UI elements colliding. It should
/// supplement the user experience, since only some platforms will play
/// feedback in response to it.
///
/// Only plays feedback on iOS and watchOS.
public static let impact: SensoryFeedback
/// Provides a physical metaphor you can use to complement a visual
/// experience.
///
/// Use this to provide feedback for UI elements colliding. It should
/// supplement the user experience, since only some platforms will play
/// feedback in response to it.
///
/// Not all platforms will play different feedback for different weights and
/// intensities of impact.
///
/// Only plays feedback on iOS and watchOS.
public static func impact(weight: SensoryFeedback.Weight = .medium, intensity: Double = 1.0) -> SensoryFeedback
/// Provides a physical metaphor you can use to complement a visual
/// experience.
///
/// Use this to provide feedback for UI elements colliding. It should
/// supplement the user experience, since only some platforms will play
/// feedback in response to it.
///
/// Not all platforms will play different feedback for different
/// flexibilities and intensities of impact.
///
/// Only plays feedback on iOS and watchOS.
public static func impact(flexibility: SensoryFeedback.Flexibility, intensity: Double = 1.0) -> SensoryFeedback
/// The weight to be represented by a type of feedback.
///
/// `Weight` values can be passed to
/// `SensoryFeedback.impact(weight:intensity:)`.
public struct Weight : Equatable, Sendable {
/// Indicates a collision between small or lightweight UI objects.
public static let light: SensoryFeedback.Weight
/// Indicates a collision between medium-sized or medium-weight UI
/// objects.
public static let medium: SensoryFeedback.Weight
/// Indicates a collision between large or heavyweight UI objects.
public static let heavy: SensoryFeedback.Weight
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SensoryFeedback.Weight, b: SensoryFeedback.Weight) -> Bool
}
/// The flexibility to be represented by a type of feedback.
///
/// `Flexibility` values can be passed to
/// `SensoryFeedback.impact(flexibility:intensity:)`.
public struct Flexibility : Equatable, Sendable {
/// Indicates a collision between hard or inflexible UI objects.
public static let rigid: SensoryFeedback.Flexibility
/// Indicates a collision between solid UI objects of medium
/// flexibility.
public static let solid: SensoryFeedback.Flexibility
/// Indicates a collision between soft or flexible UI objects.
public static let soft: SensoryFeedback.Flexibility
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SensoryFeedback.Flexibility, b: SensoryFeedback.Flexibility) -> Bool
}
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SensoryFeedback, b: SensoryFeedback) -> Bool
}
/// A style appropriate for foreground separator or border lines.
///
/// You can also use ``ShapeStyle/separator`` to construct this style.
@available(iOS 17.0, macOS 10.15, tvOS 17.0, watchOS 10.0, *)
public struct SeparatorShapeStyle : ShapeStyle {
/// Creates a new separator shape style instance.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A gesture that's a sequence of two gestures.
///
/// Read <doc:Composing-SwiftUI-Gestures> to learn how you can create a sequence
/// of two gestures.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct SequenceGesture<First, Second> : Gesture where First : Gesture, Second : Gesture {
/// The value of a sequence gesture that helps to detect whether the first
/// gesture succeeded, so the second gesture can start.
@frozen public enum Value {
/// The first gesture hasn't ended.
case first(First.Value)
/// The first gesture has ended.
case second(First.Value, Second.Value?)
}
/// The first gesture in a sequence of two gestures.
public var first: First
/// The second gesture in a sequence of two gestures.
public var second: Second
/// Creates a sequence gesture with two gestures.
///
/// - Parameters:
///   - first: The first gesture of the sequence.
///   - second: The second gesture of the sequence.
@inlinable public init(_ first: First, _ second: Second)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SequenceGesture.Value : Sendable where First.Value : Sendable, Second.Value : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SequenceGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SequenceGesture<First, Second>.Value, b: SequenceGesture<First, Second>.Value) -> Bool
}
/// A reference to a function in a Metal shader library, along with its
/// bound uniform argument values.
///
/// Shader values can be used as filter effects on views, see the
/// ``View/colorEffect(_:isEnabled:)``,
/// ``View/distortionEffect(_:maxSampleOffset:isEnabled:)``,
/// and ``View/layerEffect(_:maxSampleOffset:isEnabled:)`` functions.
///
/// Shaders also conform to the ``ShapeStyle`` protocol, letting their
/// MSL shader function provide per-pixel color to fill any shape or
/// text view. For a shader function to act as a fill pattern it must
/// have a function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position, args...)
///
/// where `position` is the user-space coordinates of the pixel applied
/// to the shader, and `args...` should be compatible with the uniform
/// arguments bound to `shader`. The function should return the
/// premultiplied color value in the color space of the destination
/// (typically extended sRGB).
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public struct Shader : Equatable, Sendable {
/// A single uniform argument value to a shader function.
public struct Argument : Equatable, Sendable {
/// Returns an argument value representing the MSL value
/// `float(x)`.
public static func float<T>(_ x: T) -> Shader.Argument where T : BinaryFloatingPoint
/// Returns an argument value representing the MSL value
/// `float2(x, y)`.
public static func float2<T>(_ x: T, _ y: T) -> Shader.Argument where T : BinaryFloatingPoint
/// Returns an argument value representing the MSL value
/// `float3(x, y, z)`.
public static func float3<T>(_ x: T, _ y: T, _ z: T) -> Shader.Argument where T : BinaryFloatingPoint
/// Returns an argument value representing the MSL value
/// `float4(x, y, z, w)`.
public static func float4<T>(_ x: T, _ y: T, _ z: T, _ w: T) -> Shader.Argument where T : BinaryFloatingPoint
/// Returns an argument value representing the MSL value
/// `float2(point.x, point.y)`.
public static func float2(_ point: CGPoint) -> Shader.Argument
/// Returns an argument value representing the MSL value
/// `float2(size.width, size.height)`.
public static func float2(_ size: CGSize) -> Shader.Argument
/// Returns an argument value representing the MSL value
/// `float2(vector.dx, vector.dy)`.
public static func float2(_ vector: CGVector) -> Shader.Argument
/// Returns an argument value defined by the provided array of
/// floating point numbers. When passed to an MSL function it
/// will convert to a `device const float *ptr, int count` pair
/// of parameters.
public static func floatArray(_ array: [Float]) -> Shader.Argument
/// Returns an argument value representing the bounding rect of
/// the shape or view that the shader is attached to, as
/// `float4(x, y, width, height)`. This value is undefined for
/// shaders that do not have a natural bounding rect (e.g.
/// filter effects drawn into `GraphicsContext`).
public static var boundingRect: Shader.Argument { get }
/// Returns an argument value representing `color`. When passed
/// to a MSL function it will convert to a `half4` value, as a
/// premultiplied color in the target color space.
public static func color(_ color: Color) -> Shader.Argument
/// Returns an argument value defined by the provided array of
/// color values. When passed to an MSL function it will convert
/// to a `device const half4 *ptr, int count` pair of
/// parameters.
public static func colorArray(_ array: [Color]) -> Shader.Argument
/// Returns an argument value defined by the provided image.
/// When passed to an MSL function it will convert to a
/// `texture2d<half>` value. Currently only one image parameter
/// is supported per `Shader` instance.
public static func image(_ image: Image) -> Shader.Argument
/// Returns an argument value defined by the provided data
/// value. When passed to an MSL function it will convert to a
/// `device const void *ptr, int size_in_bytes` pair of
/// parameters.
public static func data(_ data: Data) -> Shader.Argument
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Shader.Argument, b: Shader.Argument) -> Bool
}
/// The shader function called by the shader.
public var function: ShaderFunction
/// The uniform argument values passed to the shader function.
public var arguments: [Shader.Argument]
/// For shader functions that return color values, whether the
/// returned color has dither noise added to it, or is simply
/// rounded to the output bit-depth. For shaders generating smooth
/// gradients, dithering is usually necessary to prevent visible
/// banding in the result.
public var dithersColor: Bool
/// Creates a new shader from a function and the uniform argument
/// values to bind to the function.
public init(function: ShaderFunction, arguments: [Shader.Argument])
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Shader, b: Shader) -> Bool
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Shader {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension Shader : ShapeStyle {
}
/// A reference to a function in a Metal shader library.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
@dynamicCallable public struct ShaderFunction : Equatable, Sendable {
/// The shader library storing the function.
public var library: ShaderLibrary
/// The name of the shader function in the library.
public var name: String
/// Creates a new function reference from the provided shader
/// library and function name string.
public init(library: ShaderLibrary, name: String)
/// Returns a new shader by applying the provided argument values
/// to the referenced function.
///
/// Typically this subscript is used implicitly via function-call
/// syntax, for example:
///
///    let shader = ShaderLibrary.default.myFunction(.float(42))
///
/// which creates a shader passing the value `42` to the first
/// unbound parameter of `myFunction()`.
public func dynamicallyCall(withArguments args: [Shader.Argument]) -> Shader
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ShaderFunction, b: ShaderFunction) -> Bool
}
/// A Metal shader library.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
@dynamicMemberLookup public struct ShaderLibrary : Equatable, @unchecked Sendable {
/// The default shader library of the main (i.e. app) bundle.
public static let `default`: ShaderLibrary
/// Returns the default shader library of the specified bundle.
public static func bundle(_ bundle: Bundle) -> ShaderLibrary
/// Creates a new Metal shader library from `data`, which must be
/// the contents of precompiled Metal library. Functions compiled
/// from the returned library will only be cached as long as the
/// returned library exists.
public init(data: Data)
/// Creates a new Metal shader library from the contents of `url`,
/// which must be the location  of precompiled Metal library.
/// Functions compiled from the returned library will only be
/// cached as long as the returned library exists.
public init(url: URL)
/// Returns a new shader function representing the stitchable MSL
/// function called `name` in the default shader library.
///
/// Typically this subscript is used implicitly via the dynamic
/// member syntax, for example:
///
///    let fn = ShaderLibrary.myFunction
///
/// which creates a reference to the MSL function called
/// `myFunction()`.
public static subscript(dynamicMember name: String) -> ShaderFunction { get }
/// Returns a new shader function representing the stitchable MSL
/// function in the library called `name`.
///
/// Typically this subscript is used implicitly via the dynamic
/// member syntax, for example:
///
///    let fn = ShaderLibrary.default.myFunction
///
/// which creates a reference to the MSL function called
/// `myFunction()`.
public subscript(dynamicMember name: String) -> ShaderFunction { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: ShaderLibrary, rhs: ShaderLibrary) -> Bool
}
/// A style to use when rendering shadows.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ShadowStyle : Equatable, Sendable {
/// Creates a custom drop shadow style.
///
/// Drop shadows draw behind the source content by blurring,
/// tinting and offsetting its per-pixel alpha values.
///
/// - Parameters:
///   - color: The shadow's color.
///   - radius: The shadow's size.
///   - x: A horizontal offset you use to position the shadow
///     relative to this view.
///   - y: A vertical offset you use to position the shadow
///     relative to this view.
///
/// - Returns: A new shadow style.
public static func drop(color: Color = .init(.sRGBLinear, white: 0, opacity: 0.33), radius: CGFloat, x: CGFloat = 0, y: CGFloat = 0) -> ShadowStyle
/// Creates a custom inner shadow style.
///
/// Inner shadows draw on top of the source content by blurring,
/// tinting, inverting and offsetting its per-pixel alpha values.
///
/// - Parameters:
///   - color: The shadow's color.
///   - radius: The shadow's size.
///   - x: A horizontal offset you use to position the shadow
///     relative to this view.
///   - y: A vertical offset you use to position the shadow
///     relative to this view.
///
/// - Returns: A new shadow style.
public static func inner(color: Color = .init(.sRGBLinear, white: 0, opacity: 0.55), radius: CGFloat, x: CGFloat = 0, y: CGFloat = 0) -> ShadowStyle
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ShadowStyle, b: ShadowStyle) -> Bool
}
/// A 2D shape that you can use when drawing a view.
///
/// Shapes without an explicit fill or stroke get a default fill based on the
/// foreground color.
///
/// You can define shapes in relation to an implicit frame of reference, such as
/// the natural size of the view that contains it. Alternatively, you can define
/// shapes in terms of absolute coordinates.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol Shape : Sendable, Animatable, View {
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
func path(in rect: CGRect) -> Path
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
static var role: ShapeRole { get }
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// Returns the size of the view that will render the shape, given
/// a proposed size.
///
/// Implement this method to tell the container of the shape how
/// much space the shape needs to render itself, given a size
/// proposal.
///
/// See ``Layout/sizeThatFits(proposal:subviews:cache:)``
/// for more details about how the layout system chooses the size of
/// views.
///
/// - Parameters:
///   - proposal: A size proposal for the container.
///
/// - Returns: A size that indicates how much space the shape needs.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// Changes the relative position of this shape using the specified size.
///
/// The following example renders two circles. It places one circle at its
/// default position. The second circle is outlined with a stroke,
/// positioned on top of the first circle and offset by 100 points to the
/// left and 50 points below.
///
///     Circle()
///     .overlay(
///         Circle()
///         .offset(CGSize(width: -100, height: 50))
///         .stroke()
///     )
///
/// - Parameter offset: The amount, in points, by which you offset the
///   shape. Negative numbers are to the left and up; positive numbers are
///   to the right and down.
///
/// - Returns: A shape offset by the specified amount.
@inlinable public func offset(_ offset: CGSize) -> OffsetShape<Self>
/// Changes the relative position of this shape using the specified point.
///
/// The following example renders two circles. It places one circle at its
/// default position. The second circle is outlined with a stroke,
/// positioned on top of the first circle and offset by 100 points to the
/// left and 50 points below.
///
///     Circle()
///     .overlay(
///         Circle()
///         .offset(CGPoint(x: -100, y: 50))
///         .stroke()
///     )
///
/// - Parameter offset: The amount, in points, by which you offset the
///   shape. Negative numbers are to the left and up; positive numbers are
///   to the right and down.
///
/// - Returns: A shape offset by the specified amount.
@inlinable public func offset(_ offset: CGPoint) -> OffsetShape<Self>
/// Changes the relative position of this shape using the specified point.
///
/// The following example renders two circles. It places one circle at its
/// default position. The second circle is outlined with a stroke,
/// positioned on top of the first circle and offset by 100 points to the
/// left and 50 points below.
///
///     Circle()
///     .overlay(
///         Circle()
///         .offset(x: -100, y: 50)
///         .stroke()
///     )
///
/// - Parameters:
///   - x: The horizontal amount, in points, by which you offset the shape.
///     Negative numbers are to the left and positive numbers are to the
///     right.
///   - y: The vertical amount, in points, by which you offset the shape.
///     Negative numbers are up and positive numbers are down.
///
/// - Returns: A shape offset by the specified amount.
@inlinable public func offset(x: CGFloat = 0, y: CGFloat = 0) -> OffsetShape<Self>
/// Scales this shape without changing its bounding frame.
///
/// Both the `x` and `y` multiplication factors halve their respective
/// dimension's size when set to `0.5`, maintain their existing size when
/// set to `1`, double their size when set to `2`, and so forth.
///
/// - Parameters:
///   - x: The multiplication factor used to resize this shape along its
///     x-axis.
///   - y: The multiplication factor used to resize this shape along its
///     y-axis.
///
/// - Returns: A scaled form of this shape.
@inlinable public func scale(x: CGFloat = 1, y: CGFloat = 1, anchor: UnitPoint = .center) -> ScaledShape<Self>
/// Scales this shape without changing its bounding frame.
///
/// - Parameter scale: The multiplication factor used to resize this shape.
///   A value of `0` scales the shape to have no size, `0.5` scales to half
///   size in both dimensions, `2` scales to twice the regular size, and so
///   on.
///
/// - Returns: A scaled form of this shape.
@inlinable public func scale(_ scale: CGFloat, anchor: UnitPoint = .center) -> ScaledShape<Self>
/// Rotates this shape around an anchor point at the angle you specify.
///
/// The following example rotates a square by 45 degrees to the right to
/// create a diamond shape:
///
///     RoundedRectangle(cornerRadius: 10)
///     .rotation(Angle(degrees: 45))
///     .aspectRatio(1.0, contentMode: .fit)
///
/// - Parameters:
///   - angle: The angle of rotation to apply. Positive angles rotate
///     clockwise; negative angles rotate counterclockwise.
///   - anchor: The point to rotate the shape around.
///
/// - Returns: A rotated shape.
@inlinable public func rotation(_ angle: Angle, anchor: UnitPoint = .center) -> RotatedShape<Self>
/// Applies an affine transform to this shape.
///
/// Affine transforms present a mathematical approach to applying
/// combinations of rotation, scaling, translation, and skew to shapes.
///
/// - Parameter transform: The affine transformation matrix to apply to this
///   shape.
///
/// - Returns: A transformed shape, based on its matrix values.
@inlinable public func transform(_ transform: CGAffineTransform) -> TransformedShape<Self>
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Shape {
/// Returns a new shape with filled regions common to both shapes.
///
/// - Parameters:
///   - other: The shape to intersect.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The filled region of the resulting shape is the overlapping area
/// of the filled region of both shapes.  This can be used to clip
/// the fill of a shape to a mask.
///
/// Any unclosed subpaths in either shape are assumed to be closed.
/// The result of filling this shape using either even-odd or
/// non-zero fill rules is identical.
public func intersection<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
/// Returns a new shape with filled regions in either this shape or
/// the given shape.
///
/// - Parameters:
///   - other: The shape to union.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The filled region of resulting shape is the combination of the
/// filled region of both shapes added together.
///
/// Any unclosed subpaths in either shape are assumed to be closed.
/// The result of filling this shape using either even-odd or
/// non-zero fill rules is identical.
public func union<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
/// Returns a new shape with filled regions from this shape that are
/// not in the given shape.
///
/// - Parameters:
///   - other: The shape to subtract.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The filled region of the resulting shape is the filled region of
/// this shape with the filled  region `other` removed from it.
///
/// Any unclosed subpaths in either shape are assumed to be closed.
/// The result of filling this shape using either even-odd or
/// non-zero fill rules is identical.
public func subtracting<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
/// Returns a new shape with filled regions either from this shape or
/// the given shape, but not in both.
///
/// - Parameters:
///   - other: The shape to difference.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The filled region of the resulting shape is the filled region
/// contained in either this shape or `other`, but not both.
///
/// Any unclosed subpaths in either shape are assumed to be closed.
/// The result of filling this shape using either even-odd or
/// non-zero fill rules is identical.
public func symmetricDifference<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
/// Returns a new shape with a line from this shape that overlaps the
/// filled regions of the given shape.
///
/// - Parameters:
///   - other: The shape to intersect.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The line of the resulting shape is the line of this shape that
/// overlaps the filled region of `other`.
///
/// Intersected subpaths that are clipped create open subpaths.
/// Closed subpaths that do not intersect `other` remain closed.
public func lineIntersection<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
/// Returns a new shape with a line from this shape that does not
/// overlap the filled region of the given shape.
///
/// - Parameters:
///   - other: The shape to subtract.
///   - eoFill: Whether to use the even-odd rule for determining
///       which areas to treat as the interior of the shapes (if true),
///       or the non-zero rule (if false).
/// - Returns: A new shape.
///
/// The line of the resulting shape is the line of this shape that
/// does not overlap the filled region of `other`.
///
/// Intersected subpaths that are clipped create open subpaths.
/// Closed subpaths that do not intersect `other` remain closed.
public func lineSubtraction<T>(_ other: T, eoFill: Bool = false) -> some Shape where T : Shape
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape where Self == Rectangle {
/// A rectangular shape aligned inside the frame of the view containing it.
public static var rect: Rectangle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape where Self == RoundedRectangle {
/// A rectangular shape with rounded corners, aligned inside the frame of
/// the view containing it.
public static func rect(cornerSize: CGSize, style: RoundedCornerStyle = .continuous) -> Self
/// A rectangular shape with rounded corners, aligned inside the frame of
/// the view containing it.
public static func rect(cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous) -> Self
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Shape where Self == UnevenRoundedRectangle {
/// A rectangular shape with rounded corners with different values, aligned
/// inside the frame of the view containing it.
public static func rect(cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous) -> Self
/// A rectangular shape with rounded corners with different values, aligned
/// inside the frame of the view containing it.
public static func rect(topLeadingRadius: CGFloat = 0, bottomLeadingRadius: CGFloat = 0, bottomTrailingRadius: CGFloat = 0, topTrailingRadius: CGFloat = 0, style: RoundedCornerStyle = .continuous) -> Self
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape where Self == Capsule {
/// A capsule shape aligned inside the frame of the view containing it.
///
/// A capsule shape is equivalent to a rounded rectangle where the corner
/// radius is chosen as half the length of the rectangle's smallest edge.
public static var capsule: Capsule { get }
/// A capsule shape aligned inside the frame of the view containing it.
///
/// A capsule shape is equivalent to a rounded rectangle where the corner
/// radius is chosen as half the length of the rectangle's smallest edge.
public static func capsule(style: RoundedCornerStyle) -> Self
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape where Self == Ellipse {
/// An ellipse aligned inside the frame of the view containing it.
public static var ellipse: Ellipse { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape where Self == Circle {
/// A circle centered on the frame of the view containing it.
///
/// The circle's radius equals half the length of the frame rectangle's
/// smallest edge.
public static var circle: Circle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// Returns a new version of self representing the same shape, but
/// that will ask it to create its path from a rect of `size`. This
/// does not affect the layout properties of any views created from
/// the shape (e.g. by filling it).
@inlinable public func size(_ size: CGSize) -> some Shape
/// Returns a new version of self representing the same shape, but
/// that will ask it to create its path from a rect of size
/// `(width, height)`. This does not affect the layout properties
/// of any views created from the shape (e.g. by filling it).
@inlinable public func size(width: CGFloat, height: CGFloat) -> some Shape
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Shape where Self == ContainerRelativeShape {
/// A shape that is replaced by an inset version of the current
/// container shape. If no container shape was defined, is replaced by
/// a rectangle.
public static var containerRelative: ContainerRelativeShape { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Shape {
/// Fills this shape with a color or gradient.
///
/// - Parameters:
///   - content: The color or gradient to use when filling this shape.
///   - style: The style options that determine how the fill renders.
/// - Returns: A shape filled with the color or gradient you supply.
public func fill<S>(_ content: S = .foreground, style: FillStyle = FillStyle()) -> _ShapeView<Self, S> where S : ShapeStyle
/// Traces the outline of this shape with a color or gradient.
///
/// The following example adds a dashed purple stroke to a `Capsule`:
///
///     Capsule()
///     .stroke(
///         Color.purple,
///         style: StrokeStyle(
///             lineWidth: 5,
///             lineCap: .round,
///             lineJoin: .miter,
///             miterLimit: 0,
///             dash: [5, 10],
///             dashPhase: 0
///         )
///     )
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - style: The stroke characteristics --- such as the line's width and
///     whether the stroke is dashed --- that determine how to render this
///     shape.
/// - Returns: A stroked shape.
public func stroke<S>(_ content: S, style: StrokeStyle, antialiased: Bool = true) -> StrokeShapeView<Self, S, EmptyView> where S : ShapeStyle
/// Traces the outline of this shape with a color or gradient.
///
/// The following example draws a circle with a purple stroke:
///
///     Circle().stroke(Color.purple, lineWidth: 5)
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - lineWidth: The width of the stroke that outlines this shape.
/// - Returns: A stroked shape.
public func stroke<S>(_ content: S, lineWidth: CGFloat = 1, antialiased: Bool = true) -> StrokeShapeView<Self, S, EmptyView> where S : ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Shape {
/// Returns the original proposal, with nil components replaced by
/// a small positive value.
public func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
}
extension Shape {
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var role: ShapeRole { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Shape {
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Shape where Self == ButtonBorderShape {
/// A shape that defers to the environment to determine the resolved button border shape.
///
/// You can override the resolved shape in a given view hierarchy by using
/// the ``View/buttonBorderShape(_:)`` modifier. If no button border shape
/// is specified, it is resolved automatically for the given context and platform.
public static var buttonBorder: ButtonBorderShape { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// Returns a new shape that is a stroked copy of `self`, using the
/// contents of `style` to define the stroke characteristics.
@inlinable public func stroke(style: StrokeStyle) -> some Shape
/// Returns a new shape that is a stroked copy of `self` with
/// line-width defined by `lineWidth` and all other properties of
/// `StrokeStyle` having their default values.
@inlinable public func stroke(lineWidth: CGFloat = 1) -> some Shape
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// Fills this shape with a color or gradient.
///
/// - Parameters:
///   - content: The color or gradient to use when filling this shape.
///   - style: The style options that determine how the fill renders.
/// - Returns: A shape filled with the color or gradient you supply.
@inlinable public func fill<S>(_ content: S, style: FillStyle = FillStyle()) -> some View where S : ShapeStyle
/// Fills this shape with the foreground color.
///
/// - Parameter style: The style options that determine how the fill
///   renders.
/// - Returns: A shape filled with the foreground color.
@inlinable public func fill(style: FillStyle = FillStyle()) -> some View
/// Traces the outline of this shape with a color or gradient.
///
/// The following example adds a dashed purple stroke to a `Capsule`:
///
///     Capsule()
///     .stroke(
///         Color.purple,
///         style: StrokeStyle(
///             lineWidth: 5,
///             lineCap: .round,
///             lineJoin: .miter,
///             miterLimit: 0,
///             dash: [5, 10],
///             dashPhase: 0
///         )
///     )
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - style: The stroke characteristics --- such as the line's width and
///     whether the stroke is dashed --- that determine how to render this
///     shape.
/// - Returns: A stroked shape.
@inlinable public func stroke<S>(_ content: S, style: StrokeStyle) -> some View where S : ShapeStyle
/// Traces the outline of this shape with a color or gradient.
///
/// The following example draws a circle with a purple stroke:
///
///     Circle().stroke(Color.purple, lineWidth: 5)
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - lineWidth: The width of the stroke that outlines this shape.
/// - Returns: A stroked shape.
@inlinable public func stroke<S>(_ content: S, lineWidth: CGFloat = 1) -> some View where S : ShapeStyle
}
/// A shape acts as view by filling itself with the foreground color and
/// default fill style.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
public var body: _ShapeView<Self, ForegroundStyle> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Shape {
/// Trims this shape by a fractional amount based on its representation as a
/// path.
///
/// To create a `Shape` instance, you define the shape's path using lines and
/// curves. Use the `trim(from:to:)` method to draw a portion of a shape by
/// ignoring portions of the beginning and ending of the shape's path.
///
/// For example, if you're drawing a figure eight or infinity symbol (∞)
/// starting from its center, setting the `startFraction` and `endFraction`
/// to different values determines the parts of the overall shape.
///
/// The following example shows a simplified infinity symbol that draws
/// only three quarters of the full shape. That is, of the two lobes of the
/// symbol, one lobe is complete and the other is half complete.
///
///     Path { path in
///         path.addLines([
///             .init(x: 2, y: 1),
///             .init(x: 1, y: 0),
///             .init(x: 0, y: 1),
///             .init(x: 1, y: 2),
///             .init(x: 3, y: 0),
///             .init(x: 4, y: 1),
///             .init(x: 3, y: 2),
///             .init(x: 2, y: 1)
///         ])
///     }
///     .trim(from: 0.25, to: 1.0)
///     .scale(50, anchor: .topLeading)
///     .stroke(Color.black, lineWidth: 3)
///
/// Changing the parameters of `trim(from:to:)` to
/// `.trim(from: 0, to: 1)` draws the full infinity symbol, while
/// `.trim(from: 0, to: 0.5)` draws only the left lobe of the symbol.
///
/// - Parameters:
///   - startFraction: The fraction of the way through drawing this shape
///     where drawing starts.
///   - endFraction: The fraction of the way through drawing this shape
///     where drawing ends.
/// - Returns: A shape built by capturing a portion of this shape's path.
@inlinable public func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape
}
/// Ways of styling a shape.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public enum ShapeRole : Sendable {
/// Indicates to the shape's style that SwiftUI fills the shape.
case fill
/// Indicates to the shape's style that SwiftUI applies a stroke to
/// the shape's path.
case stroke
/// Indicates to the shape's style that SwiftUI uses the shape as a
/// separator.
case separator
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: ShapeRole, b: ShapeRole) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeRole : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeRole : Hashable {
}
/// A color or pattern to use when rendering a shape.
///
/// You create custom shape styles by declaring a type that conforms to the
/// `ShapeStyle` protocol and implementing the required `resolve` function to
/// return a shape style that represents the desired appearance based on the
/// current environment.
///
/// For example this shape style reads the current color scheme from the
/// environment to choose the blend mode its color will be composited with:
///
///     struct MyShapeStyle: ShapeStyle {
///         func resolve(in environment: EnvironmentValues) -> some ShapeStyle {
///             if environment.colorScheme == .light {
///                 return Color.red.blendMode(.lighten)
///             } else {
///                 return Color.red.blendMode(.darken)
///             }
///         }
///     }
///
/// In addition to creating a custom shape style, you can also use one of the
/// concrete styles that SwiftUI defines. To indicate a specific color or
/// pattern, you can use ``Color`` or the style returned by
/// ``ShapeStyle/image(_:sourceRect:scale:)``, or one of the gradient
/// types, like the one returned by
/// ``ShapeStyle/radialGradient(_:center:startRadius:endRadius:)-49kel``.
/// To set a color that's appropriate for a given context on a given
/// platform, use one of the semantic styles, like ``ShapeStyle/background`` or
/// ``ShapeStyle/primary``.
///
/// You can use a shape style by:
/// * Filling a shape with a style with the ``Shape/fill(_:style:)-5fwbj``
///   modifier:
///
///     ```
///     Path { path in
///         path.move(to: .zero)
///         path.addLine(to: CGPoint(x: 50, y: 0))
///         path.addArc(
///             center: .zero,
///             radius: 50,
///             startAngle: .zero,
///             endAngle: .degrees(90),
///             clockwise: false)
///     }
///     .fill(.radial(
///         Gradient(colors: [.yellow, .red]),
///         center: .topLeading,
///         startRadius: 15,
///         endRadius: 80))
///     ```
///
///     ![A screenshot of a quarter of a circle filled with
///     a radial gradient.](ShapeStyle-1)
///
/// * Tracing the outline of a shape with a style with either the
///   ``Shape/stroke(_:lineWidth:)`` or the ``Shape/stroke(_:style:)`` modifier:
///
///     ```
///     RoundedRectangle(cornerRadius: 10)
///         .stroke(.mint, lineWidth: 10)
///         .frame(width: 200, height: 50)
///     ```
///
///     ![A screenshot of a rounded rectangle, outlined in mint.](ShapeStyle-2)
///
/// * Styling the foreground elements in a view with the
///   ``View/foregroundStyle(_:)`` modifier:
///
///     ```
///     VStack(alignment: .leading) {
///         Text("Primary")
///             .font(.title)
///         Text("Secondary")
///             .font(.caption)
///             .foregroundStyle(.secondary)
///     }
///     ```
///
///     ![A screenshot of a title in the primary content color above a
///     subtitle in the secondary content color.](ShapeStyle-3)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ShapeStyle : Sendable {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
associatedtype Resolved : ShapeStyle = Never
/// Evaluate to a resolved shape style given the current `environment`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
func resolve(in environment: EnvironmentValues) -> Self.Resolved
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle {
/// Maps a shape style's unit-space coordinates to the absolute coordinates
/// of a given rectangle.
///
/// Some shape styles have colors or patterns that vary
/// with position based on ``UnitPoint`` coordinates. For example, you
/// can create a ``LinearGradient`` using ``UnitPoint/top`` and
/// ``UnitPoint/bottom`` as the start and end points:
///
///     let gradient = LinearGradient(
///         colors: [.red, .yellow],
///         startPoint: .top,
///         endPoint: .bottom)
///
/// When rendering such styles, SwiftUI maps the unit space coordinates to
/// the absolute coordinates of the filled shape. However, you can tell
/// SwiftUI to use a different set of coordinates by supplying a rectangle
/// to the `in(_:)` method. Consider two resizable rectangles using the
/// gradient defined above:
///
///     HStack {
///         Rectangle()
///             .fill(gradient)
///         Rectangle()
///             .fill(gradient.in(CGRect(x: 0, y: 0, width: 0, height: 300)))
///     }
///     .onTapGesture { isBig.toggle() }
///     .frame(height: isBig ? 300 : 50)
///     .animation(.easeInOut)
///
/// When `isBig` is true — defined elsewhere as a private ``State``
/// variable — the rectangles look the same, because their heights
/// match that of the modified gradient:
///
/// ![Two identical, tall rectangles, with a gradient that starts red at
/// the top and transitions to yellow at the bottom.](ShapeStyle-in-1)
///
/// When the user toggles `isBig` by tapping the ``HStack``, the
/// rectangles shrink, but the gradients each react in a different way:
///
/// ![Two short rectangles with different coloration. The first has a
/// gradient that transitions top to bottom from full red to full yellow.
/// The second starts as red at the top and then begins to transition
/// to yellow toward the bottom.](ShapeStyle-in-2)
///
/// SwiftUI remaps the gradient of the first rectangle to the new frame
/// height, so that you continue to see the full range of colors in a
/// smaller area. For the second rectangle, the modified gradient retains
/// a mapping to the full height, so you instead see only a small part of
/// the overall gradient. Animation helps to visualize the difference.
///
/// - Parameter rect: A rectangle that gives the absolute coordinates over
///   which to map the shape style.
/// - Returns: A new shape style mapped to the coordinates given by `rect`.
@inlinable public func `in`(_ rect: CGRect) -> some ShapeStyle
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self == FillShapeStyle {
/// An overlay fill style for filling shapes.
///
/// This shape style is appropriate for items situated on top of an existing
/// background color. It incorporates transparency to allow the background
/// color to show through.
///
/// Use the primary version of this style to fill thin or small shapes, such
/// as the track of a slider on iOS.
/// Use the secondary version of this style to fill medium-size shapes, such
/// as the background of a switch on iOS.
/// Use the tertiary version of this style to fill large shapes, such as
/// input fields, search bars, or buttons on iOS.
/// Use the quaternary version of this style to fill large areas that
/// contain complex content, such as an expanded table cell on iOS.
public static var fill: FillShapeStyle { get }
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ShapeStyle where Self == BackgroundStyle {
/// The background style in the current context.
///
/// Access this value to get the style SwiftUI uses for the background
/// in the current context. The specific color that SwiftUI renders depends
/// on factors like the platform and whether the user has turned on Dark
/// Mode.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var background: BackgroundStyle { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeStyle where Self == TintShapeStyle {
/// A style that reflects the current tint color.
///
/// You can set the tint color with the `tint(_:)` modifier. If no explicit
/// tint is set, the tint is derived from the app's accent color.
public static var tint: TintShapeStyle { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self == PlaceholderTextShapeStyle {
/// A style appropriate for placeholder text.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var placeholder: PlaceholderTextShapeStyle { get }
}
@available(iOS 17.0, macOS 10.15, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self == SeparatorShapeStyle {
/// A style appropriate for foreground separator or border lines.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var separator: SeparatorShapeStyle { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self == LinkShapeStyle {
/// A style appropriate for links.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var link: LinkShapeStyle { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeStyle {
/// Returns a new style based on `self` that multiplies by the
/// specified opacity when drawing.
@inlinable public func opacity(_ opacity: Double) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == AnyShapeStyle {
/// Returns a new style based on the current style that multiplies
/// by `opacity` when drawing.
///
/// In most contexts the current style is the foreground but e.g.
/// when setting the value of the background style, that becomes
/// the current implicit style.
///
/// For example, a circle filled with the current foreground
/// style at fifty-percent opacity:
///
///     Circle().fill(.opacity(0.5))
///
public static func opacity(_ opacity: Double) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == LinearGradient {
/// A linear gradient.
///
/// The gradient applies the color function along an axis, as
/// defined by its start and end points. The gradient maps the unit
/// space points into the bounding rectangle of each shape filled
/// with the gradient.
///
/// For example, a linear gradient used as a background:
///
///     ContentView()
///         .background(.linearGradient(.red.gradient,
///             startPoint: .top, endPoint: .bottom))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func linearGradient(_ gradient: AnyGradient, startPoint: UnitPoint, endPoint: UnitPoint) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == RadialGradient {
/// A radial gradient.
///
/// The gradient applies the color function as the distance from a
/// center point, scaled to fit within the defined start and end
/// radii. The gradient maps the unit space center point into the
/// bounding rectangle of each shape filled with the gradient.
///
/// For example, a radial gradient used as a background:
///
///     ContentView()
///         .background(.radialGradient(.red.gradient, endRadius: 100))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func radialGradient(_ gradient: AnyGradient, center: UnitPoint = .center, startRadius: CGFloat = 0, endRadius: CGFloat) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == EllipticalGradient {
/// A radial gradient that draws an ellipse.
///
/// The gradient maps its coordinate space to the unit space square
/// in which its center and radii are defined, then stretches that
/// square to fill its bounding rect, possibly also stretching the
/// circular gradient to have elliptical contours.
///
/// For example, an elliptical gradient used as a background:
///
///     ContentView()
///         .background(.ellipticalGradient(.red.gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func ellipticalGradient(_ gradient: AnyGradient, center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == AngularGradient {
/// An angular gradient, which applies the color function as the
/// angle changes between the start and end angles, and anchored to
/// a relative center point within the filled shape.
///
/// An angular gradient is also known as a "conic" gradient. If
/// `endAngle - startAngle > 2π`, the gradient only draws the last complete
/// turn. If `endAngle - startAngle < 2π`, the gradient fills the missing
/// area with the colors defined by gradient stop locations at `0` and `1`,
/// transitioning between the two halfway across the missing area.
///
/// For example, an angular gradient used as a background:
///
///     ContentView()
///         .background(.angularGradient(.red.gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
///
/// - Parameters:
///   - gradient: The gradient to use for filling the shape, providing the
///     colors and their relative stop locations.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - startAngle: The angle that marks the beginning of the gradient.
///   - endAngle: The angle that marks the end of the gradient.
public static func angularGradient(_ gradient: AnyGradient, center: UnitPoint = .center, startAngle: Angle, endAngle: Angle) -> some ShapeStyle
/// A conic gradient that completes a full turn, optionally starting from
/// a given angle and anchored to a relative center point within the filled
/// shape.
///
/// For example, a conic gradient used as a background:
///
///     let gradient = Gradient(colors: [.red, .yellow])
///
///     ContentView()
///         .background(.conicGradient(gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
///
/// - Parameters:
///   - gradient: The gradient to use for filling the shape, providing the
///     colors and their relative stop locations.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - angle: The angle to offset the beginning of the gradient's full
///     turn.
public static func conicGradient(_ gradient: AnyGradient, center: UnitPoint = .center, angle: Angle = .zero) -> some ShapeStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeStyle {
/// Returns a new style based on `self` that applies the specified
/// blend mode when drawing.
@inlinable public func blendMode(_ mode: BlendMode) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == AnyShapeStyle {
/// Returns a new style based on the current style that uses
/// `mode` as its blend mode when drawing.
///
/// In most contexts the current style is the foreground but e.g.
/// when setting the value of the background style, that becomes
/// the current implicit style.
///
/// For example, a circle filled with the current foreground
/// style and the overlay blend mode:
///
///     Circle().fill(.blendMode(.overlay))
///
public static func blendMode(_ mode: BlendMode) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle {
/// Applies the specified shadow effect to the shape style.
///
/// For example, you can create a rectangle that adds a drop shadow to
/// the ``ShapeStyle/red`` shape style.
///
///     Rectangle().fill(.red.shadow(.drop(radius: 2, y: 3)))
///
/// - Parameter style: The shadow style to apply.
///
/// - Returns: A new shape style that uses the specified shadow style.
@inlinable public func shadow(_ style: ShadowStyle) -> some ShapeStyle
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ShapeStyle where Self == AnyShapeStyle {
/// Returns a shape style that applies the specified shadow style to the
/// current style.
///
/// In most contexts the current style is the foreground, but not always.
/// For example, when setting the value of the background style, that
/// becomes the current implicit style.
///
/// The following example creates a circle filled with the current
/// foreground style that uses an inner shadow:
///
///     Circle().fill(.shadow(.inner(radius: 1, y: 1)))
///
/// - Parameter style: The shadow style to apply.
///
/// - Returns: A new shape style based on the current style that uses the
///   specified shadow style.
public static func shadow(_ style: ShadowStyle) -> some ShapeStyle
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ShapeStyle where Self == SelectionShapeStyle {
/// A style used to visually indicate selection following platform conventional
/// colors and behaviors.
///
/// For example:
///
///     ForEach(items) {
///        ItemView(value: item, isSelected: item.id == selectedID)
///     }
///
///     struct ItemView {
///         var value: item
///         var isSelected: Bool
///
///         var body: some View {
///             // construct the actual cell content
///                 .background(isSelected
///                     ? AnyShapeStyle(.selection)
///                         : AnyShapeStyle(.fill.quaternary),
///                     in: .rect(cornerRadius: 6))
///         }
///     }
///
/// On macOS and iPadOS this automatically reflects window key state and focus
/// state, where the emphasized appearance will be used only when the window is
/// key and the nearest focusable element is actually focused. On iPhone, this
/// will always fill with the environment's accent color.
///
/// When applied as a background of another view, it will automatically
/// set the `EnvironmentValues.backgroundProminence` for the environment
/// of that view to match the current prominence of the selection.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var selection: SelectionShapeStyle { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self.Resolved == Never {
/// Evaluate to a resolved shape style given the current `environment`.
public func resolve(in environment: EnvironmentValues) -> Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == LinearGradient {
/// A linear gradient.
///
/// The gradient applies the color function along an axis, as defined by its
/// start and end points. The gradient maps the unit space points into the
/// bounding rectangle of each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func linearGradient(_ gradient: Gradient, startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient
/// A linear gradient defined by a collection of colors.
///
/// The gradient applies the color function along an axis, as defined by its
/// start and end points. The gradient maps the unit space points into the
/// bounding rectangle of each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func linearGradient(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient
/// A linear gradient defined by a collection of color stops.
///
/// The gradient applies the color function along an axis, as defined by its
/// start and end points. The gradient maps the unit space points into the
/// bounding rectangle of each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func linearGradient(stops: [Gradient.Stop], startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == RadialGradient {
/// A radial gradient.
///
/// The gradient applies the color function as the distance from a center
/// point, scaled to fit within the defined start and end radii. The
/// gradient maps the unit space center point into the bounding rectangle of
/// each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func radialGradient(_ gradient: Gradient, center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient
/// A radial gradient defined by a collection of colors.
///
/// The gradient applies the color function as the distance from a center
/// point, scaled to fit within the defined start and end radii. The
/// gradient maps the unit space center point into the bounding rectangle of
/// each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func radialGradient(colors: [Color], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient
/// A radial gradient defined by a collection of color stops.
///
/// The gradient applies the color function as the distance from a center
/// point, scaled to fit within the defined start and end radii. The
/// gradient maps the unit space center point into the bounding rectangle of
/// each shape filled with the gradient.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func radialGradient(stops: [Gradient.Stop], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeStyle where Self == EllipticalGradient {
/// A radial gradient that draws an ellipse.
///
/// The gradient maps its coordinate space to the unit space square
/// in which its center and radii are defined, then stretches that
/// square to fill its bounding rect, possibly also stretching the
/// circular gradient to have elliptical contours.
///
/// For example, an elliptical gradient used as a background:
///
///     let gradient = Gradient(colors: [.red, .yellow])
///
///     ContentView()
///         .background(.ellipticalGradient(gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func ellipticalGradient(_ gradient: Gradient, center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient
/// A radial gradient that draws an ellipse defined by a collection of
/// colors.
///
/// The gradient maps its coordinate space to the unit space square
/// in which its center and radii are defined, then stretches that
/// square to fill its bounding rect, possibly also stretching the
/// circular gradient to have elliptical contours.
///
/// For example, an elliptical gradient used as a background:
///
///     .background(.elliptical(colors: [.red, .yellow]))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func ellipticalGradient(colors: [Color], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient
/// A radial gradient that draws an ellipse defined by a collection of
/// color stops.
///
/// The gradient maps its coordinate space to the unit space square
/// in which its center and radii are defined, then stretches that
/// square to fill its bounding rect, possibly also stretching the
/// circular gradient to have elliptical contours.
///
/// For example, an elliptical gradient used as a background:
///
///     .background(.ellipticalGradient(stops: [
///         .init(color: .red, location: 0.0),
///         .init(color: .yellow, location: 0.9),
///         .init(color: .yellow, location: 1.0),
///     ]))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static func ellipticalGradient(stops: [Gradient.Stop], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == AngularGradient {
/// An angular gradient, which applies the color function as the angle
/// changes between the start and end angles, and anchored to a relative
/// center point within the filled shape.
///
/// An angular gradient is also known as a "conic" gradient. If
/// `endAngle - startAngle > 2π`, the gradient only draws the last complete
/// turn. If `endAngle - startAngle < 2π`, the gradient fills the missing
/// area with the colors defined by gradient stop locations at `0` and `1`,
/// transitioning between the two halfway across the missing area.
///
/// For example, an angular gradient used as a background:
///
///     let gradient = Gradient(colors: [.red, .yellow])
///
///     ContentView()
///         .background(.angularGradient(gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
///
/// - Parameters:
///   - gradient: The gradient to use for filling the shape, providing the
///     colors and their relative stop locations.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - startAngle: The angle that marks the beginning of the gradient.
///   - endAngle: The angle that marks the end of the gradient.
public static func angularGradient(_ gradient: Gradient, center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient
/// An angular gradient defined by a collection of colors.
///
/// For more information on how to use angular gradients, see
/// ``ShapeStyle/angularGradient(_:center:startAngle:endAngle:)-378tu``.
///
/// - Parameters:
///   - colors: The colors of the gradient, evenly spaced along its full
///     length.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - startAngle: The angle that marks the beginning of the gradient.
///   - endAngle: The angle that marks the end of the gradient.
public static func angularGradient(colors: [Color], center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient
/// An angular gradient defined by a collection of color stops.
///
/// For more information on how to use angular gradients, see
/// ``ShapeStyle/angularGradient(_:center:startAngle:endAngle:)-378tu``.
///
/// - Parameters:
///   - stops: The color stops of the gradient, defining each component
///     color and their relative location along the gradient's full length.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - startAngle: The angle that marks the beginning of the gradient.
///   - endAngle: The angle that marks the end of the gradient.
public static func angularGradient(stops: [Gradient.Stop], center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == AngularGradient {
/// A conic gradient that completes a full turn, optionally starting from
/// a given angle and anchored to a relative center point within the filled
/// shape.
///
/// For example, a conic gradient used as a background:
///
///     let gradient = Gradient(colors: [.red, .yellow])
///
///     ContentView()
///         .background(.conicGradient(gradient))
///
/// For information about how to use shape styles, see ``ShapeStyle``.
///
/// - Parameters:
///   - gradient: The gradient to use for filling the shape, providing the
///     colors and their relative stop locations.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - angle: The angle to offset the beginning of the gradient's full
///     turn.
public static func conicGradient(_ gradient: Gradient, center: UnitPoint, angle: Angle = .zero) -> AngularGradient
/// A conic gradient defined by a collection of colors that completes a full
/// turn.
///
/// For more information on how to use conic gradients, see
/// ``ShapeStyle/conicGradient(_:center:angle:)-e0rd``.
///
/// - Parameters:
///   - colors: The colors of the gradient, evenly spaced along its full
///     length.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - angle: The angle to offset the beginning of the gradient's full
///     turn.
public static func conicGradient(colors: [Color], center: UnitPoint, angle: Angle = .zero) -> AngularGradient
/// A conic gradient defined by a collection of color stops that completes a
/// full turn.
///
/// For more information on how to use conic gradients, see
/// ``ShapeStyle/conicGradient(_:center:angle:)-e0rd``.
///
/// - Parameters:
///   - stops: The color stops of the gradient, defining each component
///     color and their relative location along the gradient's full length.
///   - center: The relative center of the gradient, mapped from the unit
///     space into the bounding rectangle of the filled shape.
///   - angle: The angle to offset the beginning of the gradient's full
///     turn.
public static func conicGradient(stops: [Gradient.Stop], center: UnitPoint, angle: Angle = .zero) -> AngularGradient
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension ShapeStyle where Self == HierarchicalShapeStyle {
/// A shape style that maps to the first level of the current content style.
///
/// This hierarchical style maps to the first level of the current
/// foreground style, or to the first level of the default foreground style
/// if you haven't set a foreground style in the view's environment. You
/// typically set a foreground style by supplying a non-hierarchical style
/// to the ``View/foregroundStyle(_:)`` modifier.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var primary: HierarchicalShapeStyle { get }
/// A shape style that maps to the second level of the current content style.
///
/// This hierarchical style maps to the second level of the current
/// foreground style, or to the second level of the default foreground style
/// if you haven't set a foreground style in the view's environment. You
/// typically set a foreground style by supplying a non-hierarchical style
/// to the ``View/foregroundStyle(_:)`` modifier.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var secondary: HierarchicalShapeStyle { get }
/// A shape style that maps to the third level of the current content
/// style.
///
/// This hierarchical style maps to the third level of the current
/// foreground style, or to the third level of the default foreground style
/// if you haven't set a foreground style in the view's environment. You
/// typically set a foreground style by supplying a non-hierarchical style
/// to the ``View/foregroundStyle(_:)`` modifier.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var tertiary: HierarchicalShapeStyle { get }
/// A shape style that maps to the fourth level of the current content
/// style.
///
/// This hierarchical style maps to the fourth level of the current
/// foreground style, or to the fourth level of the default foreground style
/// if you haven't set a foreground style in the view's environment. You
/// typically set a foreground style by supplying a non-hierarchical style
/// to the ``View/foregroundStyle(_:)`` modifier.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var quaternary: HierarchicalShapeStyle { get }
}
@available(iOS 16.0, macOS 12.0, macCatalyst 15.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle where Self == HierarchicalShapeStyle {
/// A shape style that maps to the fifth level of the current content
/// style.
///
/// This hierarchical style maps to the fifth level of the current
/// foreground style, or to the fifth level of the default foreground style
/// if you haven't set a foreground style in the view's environment. You
/// typically set a foreground style by supplying a non-hierarchical style
/// to the ``View/foregroundStyle(_:)`` modifier.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var quinary: HierarchicalShapeStyle { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeStyle {
/// Returns the second level of this shape style.
public var secondary: some ShapeStyle { get }
/// Returns the third level of this shape style.
public var tertiary: some ShapeStyle { get }
/// Returns the fourth level of this shape style.
public var quaternary: some ShapeStyle { get }
/// Returns the fifth level of this shape style.
public var quinary: some ShapeStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == ForegroundStyle {
/// The foreground style in the current context.
///
/// Access this value to get the style SwiftUI uses for foreground elements,
/// like text, symbols, and shapes, in the current context. Use the
/// ``View/foregroundStyle(_:)`` modifier to set a new foreground style for
/// a given view and its child views.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var foreground: ForegroundStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == Color {
/// A context-dependent red color suitable for use in UI elements.
public static var red: Color { get }
/// A context-dependent orange color suitable for use in UI elements.
public static var orange: Color { get }
/// A context-dependent yellow color suitable for use in UI elements.
public static var yellow: Color { get }
/// A context-dependent green color suitable for use in UI elements.
public static var green: Color { get }
/// A context-dependent mint color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var mint: Color { get }
/// A context-dependent teal color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var teal: Color { get }
/// A context-dependent cyan color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var cyan: Color { get }
/// A context-dependent blue color suitable for use in UI elements.
public static var blue: Color { get }
/// A context-dependent indigo color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var indigo: Color { get }
/// A context-dependent purple color suitable for use in UI elements.
public static var purple: Color { get }
/// A context-dependent pink color suitable for use in UI elements.
public static var pink: Color { get }
/// A context-dependent brown color suitable for use in UI elements.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var brown: Color { get }
/// A white color suitable for use in UI elements.
public static var white: Color { get }
/// A context-dependent gray color suitable for use in UI elements.
public static var gray: Color { get }
/// A black color suitable for use in UI elements.
public static var black: Color { get }
/// A clear color suitable for use in UI elements.
public static var clear: Color { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self : View, Self.Body == _ShapeView<Rectangle, Self> {
/// A rectangular view that's filled with the shape style.
///
/// For a ``ShapeStyle`` that also conforms to the ``View`` protocol, like
/// ``Color`` or ``LinearGradient``, this default implementation of the
/// ``View/body-swift.property`` property provides a visual representation
/// for the shape style. As a result, you can use the shape style in a view
/// hierarchy like any other view:
///
///     ZStack {
///         Color.cyan
///         Text("Hello!")
///     }
///     .frame(width: 200, height: 50)
///
/// ![A screenshot of a cyan rectangle with the text hello appearing
/// in the middle of the rectangle.](ShapeStyle-body-1)
public var body: _ShapeView<Rectangle, Self> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self == ImagePaint {
/// A shape style that fills a shape by repeating a region of an image.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
///
/// - Parameters:
///   - image: The image to be drawn.
///   - sourceRect: A unit-space rectangle defining how much of the source
///     image to draw. The results are undefined if `sourceRect` selects
///     areas outside the `[0, 1]` range in either axis.
///   - scale: A scale factor applied to the image during rendering.
public static func image(_ image: Image, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1) -> ImagePaint
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 10.0, *)
extension ShapeStyle where Self == Material {
/// A material that's somewhat translucent.
public static var regularMaterial: Material { get }
/// A material that's more opaque than translucent.
public static var thickMaterial: Material { get }
/// A material that's more translucent than opaque.
public static var thinMaterial: Material { get }
/// A mostly translucent material.
public static var ultraThinMaterial: Material { get }
/// A mostly opaque material.
public static var ultraThickMaterial: Material { get }
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension ShapeStyle where Self == Material {
/// A material matching the style of system toolbars.
public static var bar: Material { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@available(visionOS, unavailable)
extension ShapeStyle where Self == WindowBackgroundShapeStyle {
/// A style appropriate for elements that should match the background
/// of their containing window.
///
/// On macOS, this has a unique appearance compared to the default
/// `ShapeStyle.background`. It matches the default background of a
/// window: a wallpaper-tinted light gray in the light appearance and a
/// wallpaper-tinted dark gray in the dark appearance.
///
/// On visionOS, the default glass window background can only be created
/// using `glassBackgroundEffect`.
///
/// For information about how to use shape styles, see ``ShapeStyle``.
public static var windowBackground: WindowBackgroundShapeStyle { get }
}
/// A view that provides a shape that you can use for drawing operations.
///
/// Use this type with the drawing methods on ``Shape`` to apply multiple fills
/// and/or strokes to a shape. For example, the following code applies a fill
/// and stroke to a capsule shape:
///
///     Capsule()
///         .fill(.yellow)
///         .stroke(.blue, lineWidth: 8)
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol ShapeView<Content> : View {
/// The type of shape this can provide.
associatedtype Content : Shape
/// The shape that this type draws and provides for other drawing
/// operations.
var shape: Self.Content { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeView {
/// Fills this shape with a color or gradient.
///
/// - Parameters:
///   - content: The color or gradient to use when filling this shape.
///   - style: The style options that determine how the fill renders.
/// - Returns: A shape filled with the color or gradient you supply.
public func fill<S>(_ content: S = .foreground, style: FillStyle = FillStyle()) -> FillShapeView<Self.Content, S, Self> where S : ShapeStyle
/// Traces the outline of this shape with a color or gradient.
///
/// The following example adds a dashed purple stroke to a `Capsule`:
///
///     Capsule()
///     .stroke(
///         Color.purple,
///         style: StrokeStyle(
///             lineWidth: 5,
///             lineCap: .round,
///             lineJoin: .miter,
///             miterLimit: 0,
///             dash: [5, 10],
///             dashPhase: 0
///         )
///     )
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - style: The stroke characteristics --- such as the line's width and
///     whether the stroke is dashed --- that determine how to render this
///     shape.
/// - Returns: A stroked shape.
public func stroke<S>(_ content: S, style: StrokeStyle, antialiased: Bool = true) -> StrokeShapeView<Self.Content, S, Self> where S : ShapeStyle
/// Traces the outline of this shape with a color or gradient.
///
/// The following example draws a circle with a purple stroke:
///
///     Circle().stroke(Color.purple, lineWidth: 5)
///
/// - Parameters:
///   - content: The color or gradient with which to stroke this shape.
///   - lineWidth: The width of the stroke that outlines this shape.
/// - Returns: A stroked shape.
public func stroke<S>(_ content: S, lineWidth: CGFloat = 1, antialiased: Bool = true) -> StrokeShapeView<Self.Content, S, Self> where S : ShapeStyle
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension ShapeView where Self.Content : InsettableShape {
/// Returns a view that's the result of insetting this view by half of its style's line width.
///
/// This method strokes the resulting shape with
/// `style` and fills it with `content`.
public func strokeBorder<S>(_ content: S = .foreground, style: StrokeStyle, antialiased: Bool = true) -> StrokeBorderShapeView<Self.Content, S, Self> where S : ShapeStyle
/// Returns a view that's the result of filling an inner stroke of this view with the content you supply.
///
/// This is equivalent to insetting `self` by `lineWidth / 2` and stroking the
/// resulting shape with `lineWidth` as the line-width.
public func strokeBorder<S>(_ content: S = .foreground, lineWidth: CGFloat = 1, antialiased: Bool = true) -> StrokeBorderShapeView<Self.Content, S, Self> where S : ShapeStyle
}
/// A view that controls a sharing presentation.
///
/// People tap or click on a share link to present a share interface. The link
/// typically uses a system-standard appearance; you only need to supply the
/// content to share:
///
///     ShareLink(item: URL(string: "https://developer.apple.com/xcode/swiftui/")!)
///
/// You can control the appearance of the link by providing view content.
/// For example, you can use a ``Label`` to display a
/// link with a custom icon:
///
///     ShareLink(item: URL(string: "https://developer.apple.com/xcode/swiftui/")!) {
///         Label("Share", image: "MyCustomShareIcon")
///     }
///
/// If you only wish to customize the link's title, you can use one of the
/// convenience initializers that takes a string and creates a `Label` for you:
///
///     ShareLink("Share URL", item: URL(string: "https://developer.apple.com/xcode/swiftui/")!)
///
/// The link can share any content that is
/// <doc://com.apple.documentation/documentation/coretransferable/transferable>.
/// Many framework types, like
/// <doc://com.apple.documentation/documentation/Foundation/URL>,
/// already conform to this protocol. You can also make your own types
/// transferable.
///
/// For example, you can use
/// <doc://com.apple.documentation/documentation/coretransferable/proxyrepresentation>
/// to resolve your own type to a framework type:
///
///     struct Photo: Transferable {
///         static var transferRepresentation: some TransferRepresentation {
///             ProxyRepresentation(\.image)
///         }
///
///         public var image: Image
///         public var caption: String
///     }
///
///     struct PhotoView: View {
///         let photo: Photo
///
///         var body: View {
///             photo.image
///                 .toolbar {
///                     ShareLink(
///                         item: photo,
///                         preview: SharePreview(
///                             photo.caption,
///                             image: photo.image))
///                 }
///         }
///     }
///
/// Sometimes the content that your app shares isn't immediately available. You
/// can use
/// <doc://com.apple.documentation/documentation/coretransferable/filerepresentation>
/// or
/// <doc://com.apple.documentation/documentation/coretransferable/datarepresentation>
/// when you need an asynchronous operation, like a network request, to
/// retrieve and prepare the content.
///
/// A `Transferable` type also lets you provide multiple content types for a
/// single shareable item. The share interface shows relevant sharing services
/// based on the types that you provide.
///
/// The previous example also shows how you provide a preview of your content
/// to show in the share interface.
///
/// A preview isn't required when sharing URLs or non-attributed strings. When
/// sharing these types of content, the system can automatically determine a
/// preview.
///
/// You can provide a preview even when it's optional. For instance, when
/// sharing URLs, the automatic preview first shows a placeholder link icon
/// alongside the base URL while fetching the link's metadata over the network.
/// The preview updates once the link's icon and title become available. If you
/// provide a preview instead, the preview appears immediately
/// without fetching data over the network.
///
/// Some share activities support subject and message fields. You can
/// pre-populate these fields with the `subject` and `message` parameters:
///
///     ShareLink(
///         item: photo,
///         subject: Text("Cool Photo"),
///         message: Text("Check it out!")
///         preview: SharePreview(
///             photo.caption,
///             image: photo.image))
///
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct ShareLink<Data, PreviewImage, PreviewIcon, Label> : View where Data : RandomAccessCollection, PreviewImage : Transferable, PreviewIcon : Transferable, Label : View, Data.Element : Transferable {
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A closure that returns a representation of each item to
///     render in a preview.
///     - label: A view builder that produces a label that describes the
///     share action.
public init(items: Data, subject: Text? = nil, message: Text? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>, @ViewBuilder label: () -> Label)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink {
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A representation of the item to render in a preview.
///     - label: A view builder that produces a label that describes the
///     share action.
public init<I>(item: I, subject: Text? = nil, message: Text? = nil, preview: SharePreview<PreviewImage, PreviewIcon>, @ViewBuilder label: () -> Label) where Data == CollectionOfOne<I>, I : Transferable
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never, Data.Element == URL {
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - label: A view builder that produces a label that describes the
///     share action.
public init(items: Data, subject: Text? = nil, message: Text? = nil, @ViewBuilder label: () -> Label)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never, Data.Element == String {
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - label: A view builder that produces a label that describes the
///     share action.
public init(items: Data, subject: Text? = nil, message: Text? = nil, @ViewBuilder label: () -> Label)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never {
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - label: A view builder that produces a label that describes the
///     share action.
public init(item: URL, subject: Text? = nil, message: Text? = nil, @ViewBuilder label: () -> Label) where Data == CollectionOfOne<URL>
/// Creates an instance that presents the share interface.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - label: A view builder that produces a label that describes the
///     share action.
public init(item: String, subject: Text? = nil, message: Text? = nil, @ViewBuilder label: () -> Label) where Data == CollectionOfOne<String>
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where Label == DefaultShareLinkLabel {
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A closure that returns a representation of each item to
///     render in a preview.
public init(items: Data, subject: Text? = nil, message: Text? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A closure that returns a representation of each item to
///     render in a preview.
public init(_ titleKey: LocalizedStringKey, items: Data, subject: Text? = nil, message: Text? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The item to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A closure that returns a representation of each item to
///     render in a preview.
public init<S>(_ title: S, items: Data, subject: Text? = nil, message: Text? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>) where S : StringProtocol
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A closure that returns a representation of each item to
///     render in a preview.
public init(_ title: Text, items: Data, subject: Text? = nil, message: Text? = nil, preview: @escaping (Data.Element) -> SharePreview<PreviewImage, PreviewIcon>)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where Label == DefaultShareLinkLabel {
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A representation of the item to render in a preview.
public init<I>(item: I, subject: Text? = nil, message: Text? = nil, preview: SharePreview<PreviewImage, PreviewIcon>) where Data == CollectionOfOne<I>, I : Transferable
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A representation of the item to render in a preview.
public init<I>(_ titleKey: LocalizedStringKey, item: I, subject: Text? = nil, message: Text? = nil, preview: SharePreview<PreviewImage, PreviewIcon>) where Data == CollectionOfOne<I>, I : Transferable
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A representation of the item to render in a preview.
public init<S, I>(_ title: S, item: I, subject: Text? = nil, message: Text? = nil, preview: SharePreview<PreviewImage, PreviewIcon>) where Data == CollectionOfOne<I>, S : StringProtocol, I : Transferable
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
///     - preview: A representation of the item to render in a preview.
public init<I>(_ title: Text, item: I, subject: Text? = nil, message: Text? = nil, preview: SharePreview<PreviewImage, PreviewIcon>) where Data == CollectionOfOne<I>, I : Transferable
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never, Label == DefaultShareLinkLabel, Data.Element == URL {
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(items: Data, subject: Text? = nil, message: Text? = nil)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ titleKey: LocalizedStringKey, items: Data, subject: Text? = nil, message: Text? = nil)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The item to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init<S>(_ title: S, items: Data, subject: Text? = nil, message: Text? = nil) where S : StringProtocol
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ title: Text, items: Data, subject: Text? = nil, message: Text? = nil)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never, Label == DefaultShareLinkLabel, Data.Element == String {
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(items: Data, subject: Text? = nil, message: Text? = nil)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ titleKey: LocalizedStringKey, items: Data, subject: Text? = nil, message: Text? = nil)
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The item to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init<S>(_ title: S, items: Data, subject: Text? = nil, message: Text? = nil) where S : StringProtocol
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - items: The items to share.
///     - subject: A title for the items to show when sharing to activities
///     that support a subject field.
///     - message: A description of the items to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ title: Text, items: Data, subject: Text? = nil, message: Text? = nil)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ShareLink where PreviewImage == Never, PreviewIcon == Never, Label == DefaultShareLinkLabel {
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(item: URL, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<URL>
/// Creates an instance that presents the share interface.
///
/// Use this initializer when you want the system-standard appearance for
/// `ShareLink`.
///
/// - Parameters:
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(item: String, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<String>
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ titleKey: LocalizedStringKey, item: URL, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<URL>
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - titleKey: A key identifying the title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ titleKey: LocalizedStringKey, item: String, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<String>
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init<S>(_ title: S, item: URL, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<URL>, S : StringProtocol
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init<S>(_ title: S, item: String, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<String>, S : StringProtocol
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ title: Text, item: URL, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<URL>
/// Creates an instance, with a custom label, that presents the share
/// interface.
///
/// - Parameters:
///     - title: The title of the share action.
///     - item: The item to share.
///     - subject: A title for the item to show when sharing to activities
///     that support a subject field.
///     - message: A description of the item to show when sharing to
///     activities that support a message field. Activities may
///     support attributed text or HTML strings.
public init(_ title: Text, item: String, subject: Text? = nil, message: Text? = nil) where Data == CollectionOfOne<String>
}
/// A representation of a type to display in a share preview.
///
/// Use this type when sharing content that the system can't preview automatically:
///
///     struct Photo: Transferable {
///         static var transferRepresentation: some TransferRepresentation {
///             ProxyRepresentation(\.image)
///         }
///
///         public var image: Image
///         public var caption: String
///     }
///
///     struct PhotoView: View {
///         let photo: Photo
///
///         var body: View {
///             photo.image
///                 .toolbar {
///                     ShareLink(
///                         item: photo,
///                         preview: SharePreview(
///                             photo.caption,
///                             image: photo.image))
///                 }
///         }
///     }
///
/// You can also provide a preview to speed up the sharing process. In the
/// following example the preview appears immediately; if you omit the preview instead,
/// the system fetches the link's metadata over the network:
///
///     ShareLink(
///         item: URL(string: "https://developer.apple.com/xcode/swiftui/")!,
///         preview: SharePreview(
///             "SwiftUI",
///             image: Image("SwiftUI"))
///
/// You can provide unique previews for each item in a collection of items
/// that a `ShareLink` links to:
///
///     ShareLink(items: photos) { photo in
///         SharePreview(photo.caption, image: photo.image)
///     }
///
/// The share interface decides how to combine those previews.
///
/// Each preview specifies text and images that describe an item of the type.
/// The preview's `image` parameter is typically a full-size representation of the item.
/// For instance, if the system prepares a preview for a link to a webpage,
/// the image might be the hero image on that webpage.
///
/// The preview's `icon` parameter is typically a thumbnail-sized representation
/// of the source of the item. For instance, if the system prepares a preview
/// for a link to a webpage, the icon might be an image that represents
/// the website overall.
///
/// The system may reuse a single preview representation for multiple previews,
/// and show different images in each context. For more information and
/// recommended sizes for each image, see
/// [TN2444: Best Practices for Link Previews in Messages](https://developer.apple.com/library/archive/technotes/tn2444/_index.html).
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct SharePreview<Image, Icon> where Image : Transferable, Icon : Transferable {
/// Creates a preview representation.
///
/// - Parameters:
///     - titleKey: A key identifying a title to show in a preview.
///     - image: An image to show in a preview.
///     - icon: An icon to show in a preview.
public init(_ titleKey: LocalizedStringKey, image: Image, icon: Icon)
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - image: An image to show in a preview.
///     - icon: An icon to show in a preview.
public init<S>(_ title: S, image: Image, icon: Icon) where S : StringProtocol
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - image: An image to show in a preview.
///     - icon: An icon to show in a preview.
public init(_ title: Text, image: Image, icon: Icon)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension SharePreview where Image == Never {
/// Creates a preview representation.
///
/// - Parameters:
///     - titleKey: A key identifying a title to show in a preview.
///     - icon: An icon to show in a preview.
public init(_ titleKey: LocalizedStringKey, icon: Icon)
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - icon: An icon to show in a preview.
public init<S>(_ title: S, icon: Icon) where S : StringProtocol
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - icon: An icon to show in a preview.
public init(_ title: Text, icon: Icon)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension SharePreview where Icon == Never {
/// Creates a preview representation.
///
/// - Parameters:
///     - titleKey: A key identifying a title to show in a preview.
///     - image: An image to show in a preview.
public init(_ titleKey: LocalizedStringKey, image: Image)
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - image: An image to show in a preview.
public init<S>(_ title: S, image: Image) where S : StringProtocol
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
///     - image: An image to show in a preview.
public init(_ title: Text, image: Image)
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension SharePreview where Image == Never, Icon == Never {
/// Creates a preview representation.
///
/// - Parameters:
///     - titleKey: A key identifying a title to show in a preview.
public init(_ titleKey: LocalizedStringKey)
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
public init<S>(_ title: S) where S : StringProtocol
/// Creates a preview representation.
///
/// - Parameters:
///     - title: A title to show in a preview.
public init(_ title: Text)
}
/// A built-in set of commands for manipulating window sidebars.
///
/// These commands are optional and can be explicitly requested by passing a
/// value of this type to the ``Scene/commands(content:)`` modifier.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct SidebarCommands : Commands {
/// A new value describing the built-in sidebar-related commands.
public init()
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// The list style that describes the behavior and appearance of a
/// sidebar list.
///
/// You can also use ``ListStyle/sidebar`` to construct this style.
@available(iOS 14.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct SidebarListStyle : ListStyle {
/// Creates a sidebar list style.
public init()
}
/// The standard sizes of sidebar rows.
///
/// On macOS, sidebar rows have three different sizes: small, medium, and large.
/// The size is primarily controlled by the current users' "Sidebar Icon Size"
/// in Appearance settings, and applies to all applications.
///
/// On all other platforms, the only supported sidebar size is `.medium`.
///
/// This size can be read or written in the environment using
/// `EnvironmentValues.sidebarRowSize`.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public enum SidebarRowSize : Sendable {
/// The standard "small" row size
case small
/// The standard "medium" row size
case medium
/// The standard "large" row size
case large
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SidebarRowSize, b: SidebarRowSize) -> Bool
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension SidebarRowSize : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A gesture containing two gestures that can happen at the same time with
/// neither of them preceding the other.
///
/// A simultaneous gesture is a container-event handler that evaluates its two
/// child gestures at the same time. Its value is a struct with two optional
/// values, each representing the phases of one of the two gestures.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct SimultaneousGesture<First, Second> : Gesture where First : Gesture, Second : Gesture {
/// The value of a simultaneous gesture that indicates which of its two
/// gestures receives events.
@frozen public struct Value {
/// The value of the first gesture.
public var first: First.Value?
/// The value of the second gesture.
public var second: Second.Value?
}
/// The first of two gestures that can happen simultaneously.
public var first: First
/// The second of two gestures that can happen simultaneously.
public var second: Second
/// Creates a gesture with two gestures that can receive updates or succeed
/// independently of each other.
///
/// - Parameters:
///   - first: The first of two gestures that can happen simultaneously.
///   - second: The second of two gestures that can happen simultaneously.
@inlinable public init(_ first: First, _ second: Second)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SimultaneousGesture.Value : Sendable where First.Value : Sendable, Second.Value : Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SimultaneousGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SimultaneousGesture<First, Second>.Value, b: SimultaneousGesture<First, Second>.Value) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension SimultaneousGesture.Value : Hashable where First.Value : Hashable, Second.Value : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A transition that inserts by moving in from the leading edge, and
/// removes by moving out towards the trailing edge.
///
/// - SeeAlso: `MoveTransition`
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct SlideTransition : Transition {
public init()
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: SlideTransition.Content, phase: TransitionPhase) -> some View
/// The type of view representing the body.
public typealias Body = some View
}
/// A control for selecting a value from a bounded linear range of values.
///
/// A slider consists of a "thumb" image that the user moves between two
/// extremes of a linear "track". The ends of the track represent the minimum
/// and maximum possible values. As the user moves the thumb, the slider
/// updates its bound value.
///
/// The following example shows a slider bound to the value `speed`. As the
/// slider updates this value, a bound ``Text`` view shows the value updating.
/// The `onEditingChanged` closure passed to the slider receives callbacks when
/// the user drags the slider. The example uses this to change the
/// color of the value text.
///
///     @State private var speed = 50.0
///     @State private var isEditing = false
///
///     var body: some View {
///         VStack {
///             Slider(
///                 value: $speed,
///                 in: 0...100,
///                 onEditingChanged: { editing in
///                     isEditing = editing
///                 }
///             )
///             Text("\(speed)")
///                 .foregroundColor(isEditing ? .red : .blue)
///         }
///     }
///
/// ![An unlabeled slider, with its thumb about one third of the way from the
/// minimum extreme. Below, a blue label displays the value
/// 33.045977.](SwiftUI-Slider-simple.png)
///
/// You can also use a `step` parameter to provide incremental steps along the
/// path of the slider. For example, if you have a slider with a range of `0` to
/// `100`, and you set the `step` value to `5`, the slider's increments would be
/// `0`, `5`, `10`, and so on. The following example shows this approach, and
/// also adds optional minimum and maximum value labels.
///
///     @State private var speed = 50.0
///     @State private var isEditing = false
///
///     var body: some View {
///         Slider(
///             value: $speed,
///             in: 0...100,
///             step: 5
///         ) {
///             Text("Speed")
///         } minimumValueLabel: {
///             Text("0")
///         } maximumValueLabel: {
///             Text("100")
///         } onEditingChanged: { editing in
///             isEditing = editing
///         }
///         Text("\(speed)")
///             .foregroundColor(isEditing ? .red : .blue)
///     }
///
/// ![A slider with labels show minimum and maximum values of 0 and 100,
/// respectively, with its thumb most of the way to the maximum extreme. Below,
/// a blue label displays the value
/// 85.000000.](SwiftUI-Slider-withStepAndLabels.png)
///
/// The slider also uses the `step` to increase or decrease the value when a
/// VoiceOver user adjusts the slider with voice commands.
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
public struct Slider<Label, ValueLabel> : View where Label : View, ValueLabel : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension Slider {
/// Creates a slider to select a value from a given range, which displays
/// the provided labels.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///   - minimumValueLabel: A view that describes `bounds.lowerBound`.
///   - maximumValueLabel: A view that describes `bounds.lowerBound`.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder minimumValueLabel: () -> ValueLabel, @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
/// Creates a slider to select a value from a given range, subject to a
/// step increment, which displays the provided labels.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - step: The distance between each valid value.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///   - minimumValueLabel: A view that describes `bounds.lowerBound`.
///   - maximumValueLabel: A view that describes `bounds.lowerBound`.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, @ViewBuilder minimumValueLabel: () -> ValueLabel, @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension Slider where ValueLabel == EmptyView {
/// Creates a slider to select a value from a given range, which displays
/// the provided label.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
/// Creates a slider to select a value from a given range, subject to a
/// step increment, which displays the provided label.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - step: The distance between each valid value.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension Slider where Label == EmptyView, ValueLabel == EmptyView {
/// Creates a slider to select a value from a given range.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
/// Creates a slider to select a value from a given range, subject to a
/// step increment.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - step: The distance between each valid value.
///   - onEditingChanged: A callback for when editing begins and ends.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension Slider {
/// Creates a slider to select a value from a given range, which displays
/// the provided labels.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - onEditingChanged: A callback for when editing begins and ends.
///   - minimumValueLabel: A view that describes `bounds.lowerBound`.
///   - maximumValueLabel: A view that describes `bounds.lowerBound`.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, minimumValueLabel: ValueLabel, maximumValueLabel: ValueLabel, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
/// Creates a slider to select a value from a given range, subject to a
/// step increment, which displays the provided labels.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - step: The distance between each valid value.
///   - onEditingChanged: A callback for when editing begins and ends.
///   - minimumValueLabel: A view that describes `bounds.lowerBound`.
///   - maximumValueLabel: A view that describes `bounds.lowerBound`.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)")
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, minimumValueLabel: ValueLabel, maximumValueLabel: ValueLabel, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension Slider where ValueLabel == EmptyView {
/// Creates a slider to select a value from a given range, which displays
/// the provided label.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - onEditingChanged: A callback for when editing begins and ends.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)")
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
/// Creates a slider to select a value from a given range, subject to a
/// step increment, which displays the provided label.
///
/// - Parameters:
///   - value: The selected value within `bounds`.
///   - bounds: The range of the valid values. Defaults to `0...1`.
///   - step: The distance between each valid value.
///   - onEditingChanged: A callback for when editing begins and ends.
///   - label: A `View` that describes the purpose of the instance. Not all
///     slider styles show the label, but even in those cases, SwiftUI
///     uses the label for accessibility. For example, VoiceOver uses the
///     label to identify the purpose of the slider.
///
/// The `value` of the created instance is equal to the position of
/// the given value within `bounds`, mapped into `0...1`.
///
/// The slider calls `onEditingChanged` when editing begins and ends. For
/// example, on iOS, editing begins when the user starts to drag the thumb
/// along the slider's track.
@available(tvOS, unavailable)
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)")
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint
}
/// A flexible space that expands along the major axis of its containing stack
/// layout, or on both axes if not contained in a stack.
///
/// A spacer creates an adaptive view with no content that expands as much as
/// it can. For example, when placed within an ``HStack``, a spacer expands
/// horizontally as much as the stack allows, moving sibling views out of the
/// way, within the limits of the stack's size.
/// SwiftUI sizes a stack that doesn't contain a spacer up to the combined
/// ideal widths of the content of the stack's child views.
///
/// The following example provides a simple checklist row to illustrate how you
/// can use a spacer:
///
///     struct ChecklistRow: View {
///         let name: String
///
///         var body: some View {
///             HStack {
///                 Image(systemName: "checkmark")
///                 Text(name)
///             }
///             .border(Color.blue)
///         }
///     }
///
/// ![A figure of a blue rectangular border that marks the boundary of an
/// HStack, wrapping a checkmark image to the left of the name Megan. The
/// checkmark and name are centered vertically and separated by system
/// standard-spacing within the stack.](Spacer-1.png)
///
/// Adding a spacer before the image creates an adaptive view with no content
/// that expands to push the image and text to the right side of the stack.
/// The stack also now expands to take as much space as the parent view allows,
/// shown by the blue border that indicates the boundary of the stack:
///
///     struct ChecklistRow: View {
///         let name: String
///
///         var body: some View {
///             HStack {
///                 Spacer()
///                 Image(systemName: "checkmark")
///                 Text(name)
///             }
///             .border(Color.blue)
///         }
///     }
///
/// ![A figure of a blue rectangular border that marks the boundary of an
/// HStack, wrapping a checkmark image to the left of the name Megan. The
/// checkmark and name are centered vertically, separated by system-standard
/// spacing, and pushed to the right side of the stack.](Spacer-2.png)
///
/// Moving the spacer between the image and the name pushes those elements to
/// the left and right sides of the ``HStack``, respectively. Because the stack
/// contains the spacer, it expands to take as much horizontal space as the
/// parent view allows; the blue border indicates its size:
///
///     struct ChecklistRow: View {
///         let name: String
///
///         var body: some View {
///             HStack {
///                 Image(systemName: "checkmark")
///                 Spacer()
///                 Text(name)
///             }
///             .border(Color.blue)
///         }
///     }
///
/// ![A figure of a blue rectangular border that marks the boundary of an
/// HStack, wrapping a checkmark image to the left of the name Megan. The
/// checkmark and name are centered vertically, with the checkmark on the
/// left edge of the stack, and the text on the right side of the
/// stack.](Spacer-3.png)
///
/// Adding two spacer views on the outside of the stack leaves the image and
/// text together, while the stack expands to take as much horizontal space
/// as the parent view allows:
///
///     struct ChecklistRow: View {
///         let name: String
///
///         var body: some View {
///             HStack {
///                 Spacer()
///                 Image(systemName: "checkmark")
///                 Text(name)
///                 Spacer()
///             }
///             .border(Color.blue)
///         }
///     }
///
/// ![A figure of a blue rectangular border marks the boundary of an HStack,
/// wrapping a checkmark image to the left of text spelling the name Megan.
/// The checkmark and name are centered vertically, separated by
/// system-standard spacing, and centered horizontally
/// in the stack.](Spacer-4.png)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Spacer {
/// The minimum length this spacer can be shrunk to, along the axis or axes
/// of expansion.
///
/// If `nil`, the system default spacing between views is used.
public var minLength: CGFloat?
@inlinable public init(minLength: CGFloat? = nil)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Spacer : View {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Spacer : Sendable {
}
/// A collection of events that target a specific view.
///
/// You can look up a specific event using its `ID`
/// or iterate over all touches in the collection to apply logic depending
/// on the touch's states.
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct SpatialEventCollection : Collection {
/// A spatial event generated from a finger, pointing device, or other input mechanism
/// that can drive gestures in the system.
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct Event : Identifiable {
/// A value that uniquely identifies an event over the course of its lifetime.
public struct ID : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpatialEventCollection.Event.ID, b: SpatialEventCollection.Event.ID) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A kind of spatial event used to differentiate between different
/// input sources or modes.
public enum Kind : Hashable {
/// An event generated from a touch directly targeting content.
case touch
/// An event generated from a pencil making contact with content.
@available(iOS 17.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, unavailable)
case pencil
/// An event representing a click-based, indirect input device
/// describing the input sequence from click to click release.
@available(visionOS 1.0, iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
case pointer
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpatialEventCollection.Event.Kind, b: SpatialEventCollection.Event.Kind) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// The phase of a particular state of the event.
public enum Phase {
/// The phase is active and the state associated with it is
/// guaranteed to produce at least one more update.
case active
/// The state associated with this phase ended normally
/// and won't produce any more updates.
case ended
/// The state associated with this phase was canceled
/// and won't produce any more updates.
case cancelled
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpatialEventCollection.Event.Phase, b: SpatialEventCollection.Event.Phase) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A pose describing the input device such as a pencil
/// or hand controlling the event.
public struct InputDevicePose {
/// Altitude angle.
///
/// An angle of zero indicates that the device is parallel to the content,
/// while 90 degrees indicates that it is normal to the content surface.
public var altitude: Angle
/// Azimuth angle.
///
/// An angle of zero points along the content's positive X axis.
public var azimuth: Angle
}
/// An identifier that uniquely identifies this event over its lifetime.
public var id: SpatialEventCollection.Event.ID
/// The time this `Event` was processed.
public var timestamp: TimeInterval
/// Indicates what input source generated this event.
public var kind: SpatialEventCollection.Event.Kind
/// The 2D location of the touch.
public var location: CGPoint
/// The phase of the event.
public var phase: SpatialEventCollection.Event.Phase
/// The set of active modifier keys at the time of this event.
public var modifierKeys: EventModifiers
/// The 3D position and orientation of the device controlling the touch, if one exists.
@available(visionOS 1.0, iOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public var inputDevicePose: SpatialEventCollection.Event.InputDevicePose?
}
/// Retrieves an event using its unique identifier.
///
/// Returns `nil` if the `Event` no longer exists in the collection.
public subscript(index: SpatialEventCollection.Event.ID) -> SpatialEventCollection.Event? { get }
/// An iterator over all events in the collection.
public struct Iterator : IteratorProtocol {
/// The next `Event` in the sequence, if one exists.
public mutating func next() -> SpatialEventCollection.Event?
/// The type of element traversed by the iterator.
public typealias Element = SpatialEventCollection.Event
}
/// Makes an iterator over all events in the collection.
public func makeIterator() -> SpatialEventCollection.Iterator
/// A type that represents a position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript
/// argument.
public struct Index : Comparable {
/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func < (lhs: SpatialEventCollection.Index, rhs: SpatialEventCollection.Index) -> Bool
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpatialEventCollection.Index, b: SpatialEventCollection.Index) -> Bool
}
/// The position of the first element in a nonempty collection.
///
/// If the collection is empty, `startIndex` is equal to `endIndex`.
public var startIndex: SpatialEventCollection.Index { get }
/// The collection's "past the end" position---that is, the position one
/// greater than the last valid subscript argument.
///
/// When you need a range that includes the last element of a collection, use
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator
/// creates a range that doesn't include the upper bound, so it's always
/// safe to use with `endIndex`. For example:
///
///     let numbers = [10, 20, 30, 40, 50]
///     if let index = numbers.firstIndex(of: 30) {
///         print(numbers[index ..< numbers.endIndex])
///     }
///     // Prints "[30, 40, 50]"
///
/// If the collection is empty, `endIndex` is equal to `startIndex`.
public var endIndex: SpatialEventCollection.Index { get }
/// Accesses the element at the specified position.
///
/// The following example accesses an element of an array through its
/// subscript to print its value:
///
///     var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"]
///     print(streets[1])
///     // Prints "Bryant"
///
/// You can subscript a collection with any valid index other than the
/// collection's end index. The end index refers to the position one past
/// the last element of a collection, so it doesn't correspond with an
/// element.
///
/// - Parameter position: The position of the element to access. `position`
///   must be a valid index of the collection that is not equal to the
///   `endIndex` property.
///
/// - Complexity: O(1)
public subscript(position: SpatialEventCollection.Index) -> SpatialEventCollection.Event { get }
/// Returns the position immediately after the given index.
///
/// The successor of an index must be well defined. For an index `i` into a
/// collection `c`, calling `c.index(after: i)` returns the same index every
/// time.
///
/// - Parameter i: A valid index of the collection. `i` must be less than
///   `endIndex`.
/// - Returns: The index value immediately after `i`.
public func index(after i: SpatialEventCollection.Index) -> SpatialEventCollection.Index
/// A type representing the sequence's elements.
public typealias Element = SpatialEventCollection.Event
/// A type that represents the indices that are valid for subscripting the
/// collection, in ascending order.
public typealias Indices = DefaultIndices<SpatialEventCollection>
/// A collection representing a contiguous subrange of this collection's
/// elements. The subsequence shares indices with the original collection.
///
/// The default subsequence type for collections that don't define their own
/// is `Slice`.
public typealias SubSequence = Slice<SpatialEventCollection>
}
extension SpatialEventCollection.Event {
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public static func == (lhs: SpatialEventCollection.Event, rhs: SpatialEventCollection.Event) -> Bool
}
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
extension SpatialEventCollection.Event.Phase : Equatable {
}
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
extension SpatialEventCollection.Event.Phase : Hashable {
}
/// A gesture that activates immediately upon receiving any spatial event that describes
/// clicks, touches, or pinches.
///
/// Use the `action` closure to handle the collection
/// of events that target this gesture's view. The `phase` of
/// the events in the collection may move to `ended` or `cancelled` while
/// the gesture itself remains active. Individually track state for each `Event`
/// inside the `action` closure. The following shows a `SpatialEventGesture` that emits
/// particles in a simulation:
///
/// ```
/// struct ParticlePlayground: View {
///     @StateObject
///     var model = ParticlesModel()
///     var body: some View {
///         Canvas { context, size in
///             for p in model.particles {
///                 drawParticle(p, in: context)
///             }
///         }.gesture(SpatialEventGesture { events in
///             for event in events {
///                 if event.phase == .active {
///                     // Update a particle emitter at each active event's location.
///                     model.emitters[event.id] = ParticlesModel.Emitter(
///                         location: event.location
///                     )
///                 } else {
///                     // Clear out emitter state when the event is no longer active.
///                     model.emitters[event.id] = nil
///                 }
///             }
///         })
///     }
/// }
/// ```
@available(visionOS 1.0, iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public struct SpatialEventGesture : Gesture {
/// Creates the gesture with a desired coordinate space and a handler
/// that triggers when any event state changes.
public init(coordinateSpace: CoordinateSpaceProtocol = .local, action: @escaping (SpatialEventCollection) -> Void)
/// The type representing the gesture's value.
public typealias Value = Void
/// The coordinate space of the gesture.
public let coordinateSpace: CoordinateSpace
/// The action to call when the state of any event changes.
public let action: (SpatialEventCollection) -> Void
public var internalBody: some Gesture<()> { get }
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A gesture that recognizes one or more taps and reports their location.
///
/// To recognize a tap gesture on a view, create and configure the gesture, and
/// then add it to the view using the ``View/gesture(_:including:)`` modifier.
/// The following code adds a tap gesture to a ``Circle`` that toggles the color
/// of the circle based on the tap location:
///
///     struct TapGestureView: View {
///         @State private var location: CGPoint = .zero
///
///         var tap: some Gesture {
///             SpatialTapGesture()
///                 .onEnded { event in
///                     self.location = event.location
///                  }
///         }
///
///         var body: some View {
///             Circle()
///                 .fill(self.location.y > 50 ? Color.blue : Color.red)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .gesture(tap)
///         }
///     }
@available(iOS 16.0, macOS 13.0, watchOS 9.0, visionOS 1.0, *)
@available(tvOS, unavailable)
public struct SpatialTapGesture : Gesture {
/// The attributes of a tap gesture.
public struct Value : Equatable, @unchecked Sendable {
/// The location of the tap gesture's current event.
public var location: CGPoint
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpatialTapGesture.Value, b: SpatialTapGesture.Value) -> Bool
}
/// The required number of tap events.
public var count: Int
/// The coordinate space in which to receive location values.
public var coordinateSpace: CoordinateSpace
/// Creates a tap gesture with the number of required taps and the
/// coordinate space of the gesture's location.
///
/// - Parameters:
///   - count: The required number of taps to complete the tap
///     gesture.
///   - coordinateSpace: The coordinate space of the tap gesture's location.
@available(iOS, introduced: 16.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(macOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(watchOS, introduced: 9.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(tvOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
public init(count: Int = 1, coordinateSpace: CoordinateSpace = .local)
/// Creates a tap gesture with the number of required taps and the
/// coordinate space of the gesture's location.
///
/// - Parameters:
///   - count: The required number of taps to complete the tap
///     gesture.
///   - coordinateSpace: The coordinate space of the tap gesture's location.
@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public init(count: Int = 1, coordinateSpace: some CoordinateSpaceProtocol = .local)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
/// A representation of a spring's motion.
///
/// Use this type to convert between different representations of spring
/// parameters:
///
///     let spring = Spring(duration: 0.5, bounce: 0.3)
///     let (mass, stiffness, damping) = (spring.mass, spring.stiffness, spring.damping)
///     // (1.0, 157.9, 17.6)
///
///     let spring2 = Spring(mass: 1, stiffness: 100, damping: 10)
///     let (duration, bounce) = (spring2.duration, spring2.bounce)
///     // (0.63, 0.5)
///
/// You can also use it to query for a spring's position and its other properties for
/// a given set of inputs:
///
///     func unitPosition(time: TimeInterval) -> Double {
///         let spring = Spring(duration: 0.5, bounce: 0.3)
///         return spring.position(target: 1.0, time: time)
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct Spring : Hashable, Sendable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Spring, b: Spring) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Duration/Bounce Parameters
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// Creates a spring with the specified duration and bounce.
///
/// - Parameters:
///   - duration: Defines the pace of the spring. This is approximately
///   equal to the settling duration, but for springs with very large
///   bounce values, will be the duration of the period of oscillation
///   for the spring.
///   - bounce: How bouncy the spring should be. A value of 0 indicates
///   no bounces (a critically damped spring), positive values indicate
///   increasing amounts of bounciness up to a maximum of 1.0
///   (corresponding to undamped oscillation), and negative values
///   indicate overdamped springs with a minimum value of -1.0.
public init(duration: TimeInterval = 0.5, bounce: Double = 0.0)
/// The perceptual duration, which defines the pace of the spring.
public var duration: TimeInterval { get }
/// How bouncy the spring is.
///
/// A value of 0 indicates no bounces (a critically damped spring), positive
/// values indicate increasing amounts of bounciness up to a maximum of 1.0
/// (corresponding to undamped oscillation), and negative values indicate
/// overdamped springs with a minimum value of -1.0.
public var bounce: Double { get }
}
/// Response/DampingRatio Parameters
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// Creates a spring with the specified response and damping ratio.
///
/// - Parameters:
///   - response: Defines the stiffness of the spring as an approximate
///   duration in seconds.
///   - dampingRatio: Defines the amount of drag applied as a fraction the
///   amount needed to produce critical damping.
public init(response: Double, dampingRatio: Double)
/// The stiffness of the spring, defined as an approximate duration in
/// seconds.
public var response: Double { get }
/// The amount of drag applied, as a fraction of the amount needed to
/// produce critical damping.
///
/// When `dampingRatio` is 1, the spring will smoothly decelerate to its
/// final position without oscillating. Damping ratios less than 1 will
/// oscillate more and more before coming to a complete stop.
public var dampingRatio: Double { get }
}
/// Mass/Stiffness/Damping Parameters
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// Creates a spring with the specified mass, stiffness, and damping.
///
/// - Parameters:
///   - mass: Specifies that property of the object attached to the end of
///   the spring.
///   - stiffness: The corresponding spring coefficient.
///   - damping: Defines how the spring's motion should be damped due to the
///   forces of friction.
///   - allowOverdamping: A value of true specifies that over-damping
///   should be allowed when appropriate based on the other inputs, and a
///   value of false specifies that such cases should instead be treated as
///   critically damped.
public init(mass: Double = 1.0, stiffness: Double, damping: Double, allowOverDamping: Bool = false)
/// The mass of the object attached to the end of the spring.
///
/// The default mass is 1. Increasing this value will increase the spring's
/// effect: the attached object will be subject to more oscillations and
/// greater overshoot, resulting in an increased settling duration.
/// Decreasing the mass will reduce the spring effect: there will be fewer
/// oscillations and a reduced overshoot, resulting in a decreased
/// settling duration.
public var mass: Double { get }
/// The spring stiffness coefficient.
///
/// Increasing the stiffness reduces the number of oscillations and will
/// reduce the settling duration. Decreasing the stiffness increases the the
/// number of oscillations and will increase the settling duration.
public var stiffness: Double { get }
/// Defines how the spring’s motion should be damped due to the forces of
/// friction.
///
/// Reducing this value reduces the energy loss with each oscillation: the
/// spring will overshoot its destination. Increasing the value increases
/// the energy loss with each duration: there will be fewer and smaller
/// oscillations.
public var damping: Double { get }
}
/// SettlingDuration/DampingRatio Parameters
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// Creates a spring with the specified duration and damping ratio.
///
/// - Parameters:
///   - settlingDuration: The approximate time it will take for the spring
///   to come to rest.
///   - dampingRatio: The amount of drag applied as a fraction of the amount
///   needed to produce critical damping.
///   - epsilon: The threshhold for how small all subsequent values need to
///   be before the spring is considered to have settled.
public init(settlingDuration: TimeInterval, dampingRatio: Double, epsilon: Double = 0.001)
}
/// VectorArithmetic Evaluation
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// The estimated duration required for the spring system to be considered
/// at rest.
///
/// This uses a `target` of 1.0, an `initialVelocity` of 0, and an `epsilon`
/// of 0.001.
public var settlingDuration: TimeInterval { get }
/// The estimated duration required for the spring system to be considered
/// at rest.
///
/// The epsilon value specifies the threshhold for how small all subsequent
/// values need to be before the spring is considered to have settled.
public func settlingDuration<V>(target: V, initialVelocity: V = .zero, epsilon: Double) -> TimeInterval where V : VectorArithmetic
/// Calculates the value of the spring at a given time given a target
/// amount of change.
public func value<V>(target: V, initialVelocity: V = .zero, time: TimeInterval) -> V where V : VectorArithmetic
/// Calculates the velocity of the spring at a given time given a target
/// amount of change.
public func velocity<V>(target: V, initialVelocity: V = .zero, time: TimeInterval) -> V where V : VectorArithmetic
/// Updates the current  value and velocity of a spring.
///
/// - Parameters:
///   - value: The current value of the spring.
///   - velocity: The current velocity of the spring.
///   - target: The target that `value` is moving towards.
///   - deltaTime: The amount of time that has passed since the spring was
///     at the position specified by `value`.
public func update<V>(value: inout V, velocity: inout V, target: V, deltaTime: TimeInterval) where V : VectorArithmetic
/// Calculates the force upon the spring given a current position, target,
/// and velocity amount of change.
///
/// This value is in units of the vector type per second squared.
public func force<V>(target: V, position: V, velocity: V) -> V where V : VectorArithmetic
}
/// Animatable Evaluation
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// The estimated duration required for the spring system to be considered
/// at rest.
///
/// The epsilon value specifies the threshhold for how small all subsequent
/// values need to be before the spring is considered to have settled.
public func settlingDuration<V>(fromValue: V, toValue: V, initialVelocity: V, epsilon: Double) -> TimeInterval where V : Animatable
/// Calculates the value of the spring at a given time for a starting
/// and ending value for the spring to travel.
public func value<V>(fromValue: V, toValue: V, initialVelocity: V, time: TimeInterval) -> V where V : Animatable
/// Calculates the velocity of the spring at a given time given a starting
/// and ending value for the spring to travel.
public func velocity<V>(fromValue: V, toValue: V, initialVelocity: V, time: TimeInterval) -> V where V : Animatable
/// Calculates the force upon the spring given a current position,
/// velocity, and divisor from the starting and end values for the spring to travel.
///
/// This value is in units of the vector type per second squared.
public func force<V>(fromValue: V, toValue: V, position: V, velocity: V) -> V where V : Animatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Spring {
/// A smooth spring with a predefined duration and no bounce.
public static var smooth: Spring { get }
/// A smooth spring with a predefined duration and no bounce that can be
/// tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounce should be added to the base
///     bounce of 0.
public static func smooth(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Spring
/// A spring with a predefined duration and small amount of bounce that
/// feels more snappy.
public static var snappy: Spring { get }
/// A spring with a predefined duration and small amount of bounce that
/// feels more snappy and can be tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounciness should be added to the
///     base bounce of 0.15.
public static func snappy(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Spring
/// A spring with a predefined duration and higher amount of bounce.
public static var bouncy: Spring { get }
/// A spring with a predefined duration and higher amount of bounce that
/// can be tuned.
///
/// - Parameters:
///   - duration: The perceptual duration, which defines the pace of the
///     spring. This is approximately equal to the settling duration, but
///     for very bouncy springs, will be the duration of the period of
///     oscillation for the spring.
///   - extraBounce: How much additional bounce should be added to the base
///     bounce of 0.3.
///   - blendDuration: The duration in seconds over which to interpolate
///     changes to the duration.
public static func bouncy(duration: TimeInterval = 0.5, extraBounce: Double = 0.0) -> Spring
}
/// A keyframe that uses a spring function to interpolate to the given value.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct SpringKeyframe<Value> : KeyframeTrackContent where Value : Animatable {
/// Creates a new keyframe using the given value and timestamp.
///
/// - Parameters:
///   - to: The value of the keyframe.
///   - duration: The duration of the segment defined by this keyframe,
///     or nil to use the settling duration of the spring.
///   - spring: The spring that defines the shape of the segment befire
///     this keyframe
///   - startVelocity: The velocity of the value at the start of the
///     segment, or `nil` to automatically compute the velocity to maintain
///     smooth motion.
public init(_ to: Value, duration: TimeInterval? = nil, spring: Spring = Spring(), startVelocity: Value? = nil)
public typealias Body = SpringKeyframe<Value>
}
/// The options for controlling the spring loading behavior of views.
///
/// Use values of this type with the ``View/springLoadingBehavior(_:)``
/// modifier.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct SpringLoadingBehavior : Hashable, Sendable {
/// The automatic spring loading behavior.
///
/// This defers to default component behavior for spring loading.
/// Some components, such as `TabView`, will default to allowing spring
/// loading; while others do not.
public static let automatic: SpringLoadingBehavior
/// Spring loaded interactions will be enabled for applicable views.
public static let enabled: SpringLoadingBehavior
/// Spring loaded interactions will be disabled for applicable views.
public static let disabled: SpringLoadingBehavior
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SpringLoadingBehavior, b: SpringLoadingBehavior) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A navigation view style represented by a view stack that only shows a
/// single top view at a time.
///
/// You can also use ``NavigationViewStyle/stack`` to construct this style.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace stack-styled NavigationView with NavigationStack")
public struct StackNavigationViewStyle : NavigationViewStyle {
public init()
}
/// A property wrapper type that can read and write a value managed by SwiftUI.
///
/// Use state as the single source of truth for a given value type that you
/// store in a view hierarchy. Create a state value in an ``App``, ``Scene``,
/// or ``View`` by applying the `@State` attribute to a property declaration
/// and providing an initial value. Declare state as private to prevent setting
/// it in a memberwise initializer, which can conflict with the storage
/// management that SwiftUI provides:
///
///     struct PlayButton: View {
///         @State private var isPlaying: Bool = false // Create the state.
///
///         var body: some View {
///             Button(isPlaying ? "Pause" : "Play") { // Read the state.
///                 isPlaying.toggle() // Write the state.
///             }
///         }
///     }
///
/// SwiftUI manages the property's storage. When the value changes, SwiftUI
/// updates the parts of the view hierarchy that depend on the value.
/// To access a state's underlying value, you use its ``wrappedValue`` property.
/// However, as a shortcut Swift enables you to access the wrapped value by
/// referring directly to the state instance. The above example reads and
/// writes the `isPlaying` state property's wrapped value by referring to the
/// property directly.
///
/// Declare state as private in the highest view in the view hierarchy that
/// needs access to the value. Then share the state with any subviews that also
/// need access, either directly for read-only access, or as a binding for
/// read-write access. You can safely mutate state properties from any thread.
///
/// > Note: If you need to store a reference type, like an instance of a class,
///   use a ``StateObject`` instead.
///
/// ### Share state with subviews
///
/// If you pass a state property to a subview, SwiftUI updates the subview
/// any time the value changes in the container view, but the subview can't
/// modify the value. To enable the subview to modify the state's stored value,
/// pass a ``Binding`` instead. You can get a binding to a state value by
/// accessing the state's ``projectedValue``, which you get by prefixing the
/// property name with a dollar sign (`$`).
///
/// For example, you can remove the `isPlaying` state from the play button in
/// the above example, and instead make the button take a binding:
///
///     struct PlayButton: View {
///         @Binding var isPlaying: Bool // Play button now receives a binding.
///
///         var body: some View {
///             Button(isPlaying ? "Pause" : "Play") {
///                 isPlaying.toggle()
///             }
///         }
///     }
///
/// Then you can define a player view that declares the state and creates a
/// binding to the state using the dollar sign prefix:
///
///     struct PlayerView: View {
///         @State private var isPlaying: Bool = false // Create the state here now.
///
///         var body: some View {
///             VStack {
///                 PlayButton(isPlaying: $isPlaying) // Pass a binding.
///
///                 // ...
///             }
///         }
///     }
///
/// Like you do for a ``StateObject``, declare ``State`` as private to prevent
/// setting it in a memberwise initializer, which can conflict with the storage
/// management that SwiftUI provides. Unlike a state object, always
/// initialize state by providing a default value in the state's
/// declaration, as in the above examples. Use state only for storage that's
/// local to a view and its subviews.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen @propertyWrapper public struct State<Value> : DynamicProperty {
/// Creates a state property that stores an initial wrapped value.
///
/// You don't call this initializer directly. Instead, SwiftUI
/// calls it for you when you declare a property with the `@State`
/// attribute and provide an initial value:
///
///     struct MyView: View {
///         @State private var isPlaying: Bool = false
///
///         // ...
///     }
///
/// SwiftUI initializes the state's storage only once for each
/// container instance that you declare. In the above code, SwiftUI
/// creates `isPlaying` only the first time it initializes a particular
/// instance of `MyView`. On the other hand, each instance of `MyView`
/// creates a distinct instance of the state. For example, each of
/// the views in the following ``VStack`` has its own `isPlaying` value:
///
///     var body: some View {
///         VStack {
///             MyView()
///             MyView()
///         }
///     }
///
/// - Parameter value: An initial value to store in the state
///   property.
public init(wrappedValue value: Value)
/// Creates a state property that stores an initial value.
///
/// This initializer has the same behavior as the ``init(wrappedValue:)``
/// initializer. See that initializer for more information.
///
/// - Parameter value: An initial value to store in the state
///   property.
public init(initialValue value: Value)
/// The underlying value referenced by the state variable.
///
/// This property provides primary access to the value's data. However, you
/// don't typically access `wrappedValue` explicitly. Instead, you gain
/// access to the wrapped value by referring to the property variable that
/// you create with the `@State` attribute.
///
/// In the following example, the button's label depends on the value of
/// `isPlaying` and the button's action toggles the value of `isPlaying`.
/// Both of these accesses implicitly access the state property's wrapped
/// value:
///
///     struct PlayButton: View {
///         @State private var isPlaying: Bool = false
///
///         var body: some View {
///             Button(isPlaying ? "Pause" : "Play") {
///                 isPlaying.toggle()
///             }
///         }
///     }
///
public var wrappedValue: Value { get nonmutating set }
/// A binding to the state value.
///
/// Use the projected value to get a ``Binding`` to the stored value. The
/// binding provides a two-way connection to the stored value. To access
/// the `projectedValue`, prefix the property variable with a dollar
/// sign (`$`).
///
/// In the following example, `PlayerView` projects a binding of the state
/// property `isPlaying` to the `PlayButton` view using `$isPlaying`. That
/// enables the play button to both read and write the value:
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var isPlaying: Bool = false
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                     .foregroundStyle(isPlaying ? .primary : .secondary)
///                 PlayButton(isPlaying: $isPlaying)
///             }
///         }
///     }
///
public var projectedValue: Binding<Value> { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension State where Value : ExpressibleByNilLiteral {
/// Creates a state property without an initial value.
///
/// This initializer behaves like the ``init(wrappedValue:)`` initializer
/// with an input of `nil`. See that initializer for more information.
@inlinable public init()
}
/// A property wrapper type that instantiates an observable object.
///
/// Use a state object as the single source of truth for a reference type that
/// you store in a view hierarchy. Create a state object in an ``App``,
/// ``Scene``, or ``View`` by applying the `@StateObject` attribute to a
/// property declaration and providing an initial value that conforms to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol. Declare state objects as private to prevent setting them from a
/// memberwise initializer, which can conflict with the storage management that
/// SwiftUI provides:
///
///     class DataModel: ObservableObject {
///         @Published var name = "Some Name"
///         @Published var isEnabled = false
///     }
///
///     struct MyView: View {
///         @StateObject private var model = DataModel() // Create the state object.
///
///         var body: some View {
///             Text(model.name) // Updates when the data model changes.
///             MySubView()
///                 .environmentObject(model)
///         }
///     }
///
/// SwiftUI creates a new instance of the model object only once during the
/// lifetime of the container that declares the state object. For example,
/// SwiftUI doesn't create a new instance if a view's inputs change, but does
/// create a new instance if the identity of a view changes. When published
/// properties of the observable object change, SwiftUI updates any view that
/// depends on those properties, like the ``Text`` view in the above example.
///
/// > Note: If you need to store a value type, like a structure, string, or
///   integer, use the ``State`` property wrapper instead. Also use ``State``
///   if you need to store a reference type that conforms to the
///   <doc://com.apple.documentation/documentation/Observation/Observable()>
///   protocol. To learn more about Observation in SwiftUI, see
///   <doc:Managing-model-data-in-your-app>.
///
/// ### Share state objects with subviews
///
/// You can pass a state object into a subview through a property that has the
/// ``ObservedObject`` attribute. Alternatively, add the object to the
/// environment of a view hierarchy by applying the
/// ``View/environmentObject(_:)`` modifier to a view, like `MySubView` in the
/// above code. You can then read the object inside `MySubView` or any of its
/// descendants using the ``EnvironmentObject`` attribute:
///
///     struct MySubView: View {
///         @EnvironmentObject var model: DataModel
///
///         var body: some View {
///             Toggle("Enabled", isOn: $model.isEnabled)
///         }
///     }
///
/// Get a ``Binding`` to the state object's properties using the dollar sign
/// (`$`) operator. Use a binding when you want to create a two-way connection.
/// In the above code, the ``Toggle`` controls the model's `isEnabled` value
/// through a binding.
///
/// ### Initialize state objects using external data
///
/// When a state object's initial state depends on data that comes from
/// outside its container, you can call the object's initializer
/// explicitly from within its container's initializer. For example,
/// suppose the data model from the previous example takes a `name`
/// input during initialization and you want to use a value for that
/// name that comes from outside the view. You can do this with
/// a call to the state object's initializer inside an explicit initializer
/// that you create for the view:
///
///     struct MyInitializableView: View {
///         @StateObject private var model: DataModel
///
///         init(name: String) {
///             // SwiftUI ensures that the following initialization uses the
///             // closure only once during the lifetime of the view, so
///             // later changes to the view's name input have no effect.
///             _model = StateObject(wrappedValue: DataModel(name: name))
///         }
///
///         var body: some View {
///             VStack {
///                 Text("Name: \(model.name)")
///             }
///         }
///     }
///
/// Use caution when doing this. SwiftUI only initializes a state object
/// the first time you call its initializer in a given view. This
/// ensures that the object provides stable storage even as the view's
/// inputs change. However, it might result in unexpected behavior or
/// unwanted side effects if you explicitly initialize the state object.
///
/// In the above example, if the `name` input to `MyInitializableView`
/// changes, SwiftUI reruns the view's initializer with the new value. However,
/// SwiftUI runs the autoclosure that you provide to the state object's
/// initializer only the first time you call the state object's initializer, so
/// the model's stored `name` value doesn't change.
///
/// Explicit state object initialization works well when the external data
/// that the object depends on doesn't change for a given instance of the
/// object's container. For example, you can create two views with different
/// constant names:
///
///     var body: some View {
///         VStack {
///             MyInitializableView(name: "Ravi")
///             MyInitializableView(name: "Maria")
///         }
///     }
///
/// > Important: Even for a configurable state object, you still declare it
///   as private. This ensures that you can't accidentally set the parameter
///   through a memberwise initializer of the view, because doing so can
///   conflict with the framework's storage management and produce unexpected
///   results.
///
/// ### Force reinitialization by changing view identity
///
/// If you want SwiftUI to reinitialize a state object when a view input
/// changes, make sure that the view's identity changes at the same time.
/// One way to do this is to bind the view's identity to the value that changes
/// using the ``View/id(_:)`` modifier. For example, you can ensure that
/// the identity of an instance of `MyInitializableView` changes when its
/// `name` input changes:
///
///     MyInitializableView(name: name)
///         .id(name) // Binds the identity of the view to the name property.
///
/// > NOTE: If your view appears inside a ``ForEach``, it implicitly receives an
///   ``View/id(_:)`` modifier that uses the identifier of the corresponding
///   data element.
///
/// If you need the view to reinitialize state based on changes in more than
/// one value, you can combine the values into a single identifier using a
/// <doc://com.apple.documentation/documentation/Swift/Hasher>. For example,
/// if you want to update the data model in `MyInitializableView` when the
/// values of either `name` or `isEnabled` change, you can combine both
/// variables into a single hash:
///
///     var hash: Int {
///         var hasher = Hasher()
///         hasher.combine(name)
///         hasher.combine(isEnabled)
///         return hasher.finalize()
///     }
///
/// Then apply the combined hash to the view as an identifier:
///
///     MyInitializableView(name: name, isEnabled: isEnabled)
///         .id(hash)
///
/// Be mindful of the performance cost of reinitializing the state object every
/// time the input changes. Also, changing view identity can have side
/// effects. For example, SwiftUI doesn't automatically animate
/// changes inside the view if the view's identity changes at the same time.
/// Also, changing the identity resets _all_ state held by the view, including
/// values that you manage as ``State``, ``FocusState``, ``GestureState``,
/// and so on.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen @propertyWrapper public struct StateObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject {
/// Creates a new state object with an initial wrapped value.
///
/// You typically don’t call this initializer directly. Instead, SwiftUI
/// calls it for you when you declare a property with the `@StateObject`
/// attribute in an ``App``, ``Scene``, or ``View`` and provide an initial
/// value:
///
///     struct MyView: View {
///         @StateObject private var model = DataModel()
///
///         // ...
///     }
///
/// SwiftUI creates only one instance of the state object for each
/// container instance that you declare. In the above code, SwiftUI
/// creates `model` only the first time it initializes a particular
/// instance of `MyView`. On the other hand, each instance of `MyView`
/// creates a distinct instance of the data model. For example, each of
/// the views in the following ``VStack`` has its own model storage:
///
///     var body: some View {
///         VStack {
///             MyView()
///             MyView()
///         }
///     }
///
/// ### Initialize using external data
///
/// If the initial state of a state object depends on external data, you can
/// call this initializer directly. However, use caution when doing this,
/// because SwiftUI only initializes the object once during the lifetime of
/// the view --- even if you call the state object initializer more than
/// once --- which might result in unexpected behavior. For more information
/// and an example, see ``StateObject``.
///
/// - Parameter thunk: An initial value for the state object.
@inlinable public init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType)
/// The underlying value referenced by the state object.
///
/// The wrapped value property provides primary access to the value's data.
/// However, you don't typically access it directly. Instead,
/// SwiftUI accesses this property for you when you refer to the variable
/// that you create with the `@StateObject` attribute:
///
///     @StateObject private var contact = Contact()
///
///     var body: some View {
///         Text(contact.name) // Reads name from contact's wrapped value.
///     }
///
/// When you change a wrapped value, you can access the new
/// value immediately. However, SwiftUI updates views that display the value
/// asynchronously, so the interface might not update immediately.
@MainActor public var wrappedValue: ObjectType { get }
/// A projection of the state object that creates bindings to its
/// properties.
///
/// Use the projected value to get a ``Binding`` to a property of a state
/// object. To access the projected value, prefix the property name
/// with a dollar sign (`$`). For example, you can get a binding to a
/// model's `isEnabled` Boolean so that a ``Toggle`` can control the value:
///
///     struct MyView: View {
///         @StateObject private var model = DataModel()
///
///         var body: some View {
///             Toggle("Enabled", isOn: $model.isEnabled)
///         }
///     }
///
@MainActor public var projectedValue: ObservedObject<ObjectType>.Wrapper { get }
}
/// A control that performs increment and decrement actions.
///
/// Use a stepper control when you want the user to have granular control while
/// incrementing or decrementing a value. For example, you can use a stepper
/// to:
///
///  * Change a value up or down by `1`.
///  * Operate strictly over a prescribed range.
///  * Step by specific amounts over a stepper's range of possible values.
///
/// The example below uses an array that holds a number of ``Color`` values,
/// a local state variable, `value`, to set the control's background
/// color, and title label. When the user clicks or taps on the stepper's
/// increment or decrement buttons SwiftUI executes the relevant
/// closure that updates `value`, wrapping the `value` to prevent overflow.
/// SwiftUI then re-renders the view, updating the text and background
/// color to match the current index:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let colors: [Color] = [.orange, .red, .gray, .blue,
///                                .green, .purple, .pink]
///
///         func incrementStep() {
///             value += 1
///             if value >= colors.count { value = 0 }
///         }
///
///         func decrementStep() {
///             value -= 1
///             if value < 0 { value = colors.count - 1 }
///         }
///
///         var body: some View {
///             Stepper {
///                 Text("Value: \(value) Color: \(colors[value].description)")
///             } onIncrement: {
///                 incrementStep()
///             } onDecrement: {
///                 decrementStep()
///             }
///             .padding(5)
///             .background(colors[value])
///         }
///    }
///
/// ![A view displaying a stepper that uses a text view for stepper's title
///   and that changes the background color of its view when incremented or
///   decremented. The view selects the new background color from a
///    predefined array of colors using the stepper's value as the
///   index.](SwiftUI-Stepper-increment-decrement-closures.png)
///
/// The following example shows a stepper that displays the effect of
/// incrementing or decrementing a value with the step size of `step` with
/// the bounds defined by `range`:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper(value: $value,
///                     in: range,
///                     step: step) {
///                 Text("Current: \(value) in \(range.description) " +
///                      "stepping by \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper with a step size of five, and a
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png)
@available(iOS 13.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
public struct Stepper<Label> : View where Label : View {
/// Creates a stepper instance that performs the closures you provide when
/// the user increments or decrements the stepper.
///
/// Use this initializer to create a control with a custom title that
/// executes closures you provide when the user clicks or taps the
/// stepper's increment or decrement buttons.
///
/// The example below uses an array that holds a number of ``Color`` values,
/// a local state variable, `value`, to set the control's background
/// color, and title label. When the user clicks or taps on the stepper's
/// increment or decrement buttons SwiftUI executes the relevant
/// closure that updates `value`, wrapping the `value` to prevent overflow.
/// SwiftUI then re-renders the view, updating the text and background
/// color to match the current index:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let colors: [Color] = [.orange, .red, .gray, .blue, .green,
///                                .purple, .pink]
///
///         func incrementStep() {
///             value += 1
///             if value >= colors.count { value = 0 }
///         }
///
///         func decrementStep() {
///             value -= 1
///             if value < 0 { value = colors.count - 1 }
///         }
///
///         var body: some View {
///             Stepper {
///                 Text("Value: \(value) Color: \(colors[value].description)")
///             } onIncrement: {
///                 incrementStep()
///             } onDecrement: {
///                 decrementStep()
///             }
///             .padding(5)
///             .background(colors[value])
///         }
///    }
///
/// ![A view displaying a stepper that uses a text view for stepper's title
///   and that changes the background color of its view when incremented or
///   decremented. The view selects the new background color from a
///    predefined array of colors using the stepper's value as the
///   index.](SwiftUI-Stepper-increment-decrement-closures.png)
///
/// - Parameters:
///     - label: A view describing the purpose of this stepper.
///     - onIncrement: The closure to execute when the user clicks or taps
///       the control's plus button.
///     - onDecrement: The closure to execute when the user clicks or taps
///       the control's minus button.
///     - onEditingChanged: A closure called when editing begins and ends.
///       For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
public init(@ViewBuilder label: () -> Label, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in })
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Stepper {
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value you provide.
///
/// Use this initializer to create a stepper that increments or decrements
/// a bound value by a specific amount each time the user
/// clicks or taps the stepper's increment or decrement buttons.
///
/// In the example below, a stepper increments or decrements `value` by the
/// `step` value of 5 at each click or tap of the control's increment or
/// decrement button:
///
///     struct StepperView: View {
///         @State private var value = 1
///         let step = 5
///         var body: some View {
///             Stepper(value: $value,
///                     step: step) {
///                 Text("Current value: \(value), step: \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements a value by
///   a specified amount each time the user clicks or taps the stepper's
///   increment or decrement buttons.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///   - value: The ``Binding`` to a value that you provide.
///   - step: The amount to increment or decrement `value` each time the
///     user clicks or taps the stepper's increment or decrement buttons.
///     Defaults to `1`.
///   - label: A view describing the purpose of this stepper.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value and within a range of values you provide.
///
/// Use this initializer to create a stepper that increments or decrements
/// a binding to value by the step size you provide within the given bounds.
/// By setting the bounds, you ensure that the value never goes below or
/// above the lowest or highest value, respectively.
///
/// The example below shows a stepper that displays the effect of
/// incrementing or decrementing a value with the step size of `step`
/// with the bounds defined by `range`:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper(value: $value,
///                     in: range,
///                     step: step) {
///                 Text("Current: \(value) in \(range.description) " +
///                      "stepping by \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper with a step size of five, and a
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png)
///
/// - Parameters:
///   - value: A ``Binding`` to a value that you provide.
///   - bounds: A closed range that describes the upper and lower bounds
///     permitted by the stepper.
///   - step: The amount to increment or decrement the stepper when the
///     user clicks or taps the stepper's increment or decrement buttons,
///     respectively.
///   - label: A view describing the purpose of this stepper.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable
}
@available(iOS 13.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Stepper where Label == Text {
/// Creates a stepper that uses a title key and executes the closures
/// you provide when the user clicks or taps the stepper's increment and
/// decrement buttons.
///
/// Use this initializer to create a stepper with a custom title that
/// executes closures you provide when either of the stepper's increment
/// or decrement buttons are pressed. This version of ``Stepper`` doesn't
/// take a binding to a value, nor does it allow you to specify a range of
/// acceptable values, or a step value -- it simply calls the closures you
/// provide when the control's buttons are pressed.
///
/// The example below uses an array that holds a number of ``Color`` values,
/// a local state variable, `value`, to set the control's background
/// color, and title label. When the user clicks or taps on the stepper's
/// increment or decrement buttons SwiftUI executes the relevant
/// closure that updates `value`, wrapping the `value` to prevent overflow.
/// SwiftUI then re-renders the view, updating the text and background
/// color to match the current index:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let colors: [Color] = [.orange, .red, .gray, .blue, .green,
///                                .purple, .pink]
///
///         func incrementStep() {
///             value += 1
///             if value >= colors.count { value = 0 }
///         }
///
///         func decrementStep() {
///             value -= 1
///             if value < 0 { value = colors.count - 1 }
///         }
///
///         var body: some View {
///             Stepper("Value: \(value) Color: \(colors[value].description)",
///                      onIncrement: incrementStep,
///                      onDecrement: decrementStep)
///             .padding(5)
///             .background(colors[value])
///         }
///     }
///
/// ![A view displaying a stepper that uses a title key for the stepper's
/// localized title and that changes the background color of its view
/// when incremented or decremented selecting a color from a predefined
/// array using the stepper value as the
/// index.](SwiftUI-Stepper-increment-decrement-closures.png)
///
/// - Parameters:
///     - titleKey: The key for the stepper's localized title describing
///       the purpose of the stepper.
///     - onIncrement: The closure to execute when the user clicks or taps the
///       control's plus button.
///     - onDecrement: The closure to execute when the user clicks or taps the
///       control's minus button.
///    - onEditingChanged: A closure that's called when editing begins and
///      ends. For example, on iOS, the user may touch and hold the increment
///      or decrement buttons on a `Stepper` which causes the execution
///      of the `onEditingChanged` closure at the start and end of
///      the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init(_ titleKey: LocalizedStringKey, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in })
/// Creates a stepper using a title string and that executes closures
/// you provide when the user clicks or taps the stepper's increment or
/// decrement buttons.
///
/// Use `Stepper(_:onIncrement:onDecrement:onEditingChanged:)` to create a
/// control with a custom title that executes closures you provide when
/// the user clicks or taps on the stepper's increment or decrement buttons.
///
/// The example below uses an array that holds a number of ``Color`` values,
/// a local state variable, `value`, to set the control's background
/// color, and title label. When the user clicks or taps on the stepper's
/// increment or decrement buttons SwiftUI executes the relevant
/// closure that updates `value`, wrapping the `value` to prevent overflow.
/// SwiftUI then re-renders the view, updating the text and background
/// color to match the current index:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let title: String
///         let colors: [Color] = [.orange, .red, .gray, .blue, .green,
///                                .purple, .pink]
///
///         func incrementStep() {
///             value += 1
///             if value >= colors.count { value = 0 }
///         }
///
///         func decrementStep() {
///             value -= 1
///             if value < 0 { value = colors.count - 1 }
///         }
///
///         var body: some View {
///             Stepper(title, onIncrement: incrementStep, onDecrement: decrementStep)
///                 .padding(5)
///                 .background(colors[value])
///         }
///     }
///
/// ![A view displaying a stepper that uses a string for the stepper's title
///   and that changes the background color of its view when incremented or
///   decremented selecting a color from a predefined array using the
///   stepper's value as the
///   index.](SwiftUI-Stepper-increment-decrement-closures.png)
///
/// - Parameters:
///     - title: A string describing the purpose of the stepper.
///     - onIncrement: The closure to execute when the user clicks or taps the
///       control's plus button.
///     - onDecrement: The closure to execute when the user clicks or taps the
///       control's minus button.
///    - onEditingChanged: A closure that's called when editing begins and
///      ends. For example, on iOS, the user may touch and hold the increment
///      or decrement buttons on a `Stepper` which causes the execution
///      of the `onEditingChanged` closure at the start and end of
///      the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<S>(_ title: S, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol
/// Creates a stepper with a title key and configured to increment and
/// decrement a binding to a value and step amount you provide.
///
/// Use `Stepper(_:value:step:onEditingChanged:)` to create a stepper with a
/// custom title that increments or decrements a binding to value by the
/// step size you specify.
///
/// In the example below, the stepper increments or decrements the binding
/// value by `5` each time the user clicks or taps on the control's
/// increment or decrement buttons, respectively:
///
///     struct StepperView: View {
///         @State private var value = 1
///         let step = 5
///
///         var body: some View {
///             Stepper("Current value: \(value), step: \(step)",
///                     value: $value,
///                     step: step)
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements by 5 each
///   time the user clicks or taps on the control's increment or decrement
///   buttons, respectively.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///     - titleKey: The key for the stepper's localized title describing
///       the purpose of the stepper.
///     - value: A ``Binding`` to a value that you provide.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's plus or minus button,
///       respectively.  Defaults to `1`.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the
///       increment or decrement buttons on a `Stepper` which causes the
///       execution of the `onEditingChanged` closure at the start and end
///       of the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable
/// Creates a stepper with a title and configured to increment and
/// decrement a binding to a value and step amount you provide.
///
/// Use `Stepper(_:value:step:onEditingChanged:)` to create a stepper with a
/// custom title that increments or decrements a binding to value by the
/// step size you specify.
///
/// In the example below, the stepper increments or decrements the binding
/// value by `5` each time one of the user clicks or taps the control's
/// increment or decrement buttons:
///
///     struct StepperView: View {
///         @State private var value = 1
///         let step = 5
///         let title: String
///
///         var body: some View {
///             Stepper(title, value: $value, step: step)
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements by 1 each
///   time the control's buttons
///   are pressed.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///     - title: A string describing the purpose of the stepper.
///     - value: The ``Binding`` to a value that you provide.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the
///       increment or decrement buttons on a `Stepper` which causes the
///       execution of the `onEditingChanged` closure at the start and end
///       of the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<S, V>(_ title: S, value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, V : Strideable
/// Creates a stepper instance that increments and decrements a binding to
/// a value, by a step size and within a closed range that you provide.
///
/// Use `Stepper(_:value:in:step:onEditingChanged:)` to create a stepper
/// that increments or decrements a value within a specific range of values
/// by a specific step size. In the example below, a stepper increments or
/// decrements a binding to value over a range of `1...50` by `5` at each
/// press of the stepper's increment or decrement buttons:
///
///     struct StepperView: View {
///         @State private var value = 0
///         @State private var titleKey = "Stepper"
///
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             VStack(spacing: 20) {
///                 Text("Current Stepper Value: \(value)")
///                 Stepper(titleKey, value: $value, in: range, step: step)
///             }
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements within a
///   specified range and step size.](SwiftUI-Stepper-value-step-range.png)
///
/// - Parameters:
///     - titleKey: The key for the stepper's localized title describing
///       the purpose of the stepper.
///     - value: A ``Binding`` to a value that your provide.
///     - bounds: A closed range that describes the upper and lower bounds
///       permitted by the stepper.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable
/// Creates a stepper instance that increments and decrements a binding to
/// a value, by a step size and within a closed range that you provide.
///
/// Use `Stepper(_:value:in:step:onEditingChanged:)` to create a stepper
/// that increments or decrements a value within a specific range of values
/// by a specific step size. In the example below, a stepper increments or
/// decrements a binding to value over a range of `1...50` by `5` each time
/// the user clicks or taps the stepper's increment or decrement buttons:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper("Current: \(value) in \(range.description) stepping by \(step)",
///                     value: $value,
///                     in: range,
///                     step: step)
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements within a
///   specified range and step size.](SwiftUI-Stepper-value-step-range.png)
///
/// - Parameters:
///     - title: A string describing the purpose of the stepper.
///     - value: A ``Binding`` to a value that your provide.
///     - bounds: A closed range that describes the upper and lower bounds
///       permitted by the stepper.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
@available(watchOS 9.0, *)
@available(tvOS, unavailable)
public init<S, V>(_ title: S, value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, V : Strideable
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Stepper {
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value you provide, displaying its value with an
/// applied format style.
///
/// Use this initializer to create a stepper that increments or decrements
/// a bound value by a specific amount each time the user clicks or taps
/// the stepper's increment or decrement buttons, while displaying the
/// current value.
///
/// In the example below, a stepper increments or decrements `value` by the
/// `step` value of 5 at each click or tap of the control's increment or
/// decrement button:
///
///     struct StepperView: View {
///         @State private var value = 1
///         let step = 5
///         var body: some View {
///             Stepper(value: $value,
///                     step: step,
///                     format: .number) {
///                 Text("Current value: \(value), step: \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements a value by
///   a specified amount each time the user clicks or taps the stepper's
///   increment or decrement buttons.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///   - value: The ``Binding`` to a value that you provide.
///   - step: The amount to increment or decrement `value` each time the
///     user clicks or taps the stepper's increment or decrement buttons.
///     Defaults to `1`.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the
///     stepper leaves `value` unchanged. If the user stops editing the
///     text in an invalid state, the stepper updates the text to the last
///     known valid value.
///   - label: A view describing the purpose of this stepper.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
public init<F>(value: Binding<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value and within a range of values you provide,
/// displaying its value with an applied format style.
///
/// Use this initializer to create a stepper that increments or decrements
/// a binding to value by the step size you provide within the given bounds.
/// By setting the bounds, you ensure that the value never goes below or
/// above the lowest or highest value, respectively.
///
/// The example below shows a stepper that displays the effect of
/// incrementing or decrementing a value with the step size of `step`
/// with the bounds defined by `range`:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper(value: $value,
///                     in: range,
///                     step: step,
///                     format: .number) {
///                 Text("Current: \(value) in \(range.description) " +
///                      "stepping by \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper with a step size of five, and a
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png)
///
/// - Parameters:
///   - value: A ``Binding`` to a value that you provide.
///   - bounds: A closed range that describes the upper and lower bounds
///     permitted by the stepper.
///   - step: The amount to increment or decrement the stepper when the
///     user clicks or taps the stepper's increment or decrement buttons,
///     respectively.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the
///     stepper leaves `value` unchanged. If the user stops editing the
///     text in an invalid state, the stepper updates the text to the last
///     known valid value.
///   - label: A view describing the purpose of this stepper.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
public init<F>(value: Binding<F.FormatInput>, in bounds: ClosedRange<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Stepper where Label == Text {
/// Creates a stepper with a title key and configured to increment and
/// decrement a binding to a value and step amount you provide,
/// displaying its value with an applied format style.
///
/// Use `Stepper(_:value:step:onEditingChanged:)` to create a stepper with a
/// custom title that increments or decrements a binding to value by the
/// step size you specify, while displaying the current value.
///
/// In the example below, the stepper increments or decrements the binding
/// value by `5` each time the user clicks or taps on the control's
/// increment or decrement buttons, respectively:
///
///     struct StepperView: View {
///         @State private var value = 1
///
///         var body: some View {
///             Stepper("Stepping by \(step)",
///                 value: $value,
///                 step: 5,
///                 format: .number
///             )
///             .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements by 5 each
///   time the user clicks or taps on the control's increment or decrement
///   buttons, respectively.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///     - titleKey: The key for the stepper's localized title describing
///       the purpose of the stepper.
///     - value: A ``Binding`` to a value that you provide.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's plus or minus button,
///       respectively.  Defaults to `1`.
///     - format: A format style of type `F` to use when converting between
///       the string the user edits and the underlying value of type
///       `F.FormatInput`. If `format` can't perform the conversion, the
///       stepper leaves `value` unchanged. If the user stops editing the
///       text in an invalid state, the stepper updates the text to the last
///       known valid value.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the
///       increment or decrement buttons on a `Stepper` which causes the
///       execution of the `onEditingChanged` closure at the start and end
///       of the gesture.
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
/// Creates a stepper with a title and configured to increment and
/// decrement a binding to a value and step amount you provide,
/// displaying its value with an applied format style.
///
/// Use `Stepper(_:value:step:format:onEditingChanged:)` to create a stepper
/// with a custom title that increments or decrements a binding to value by
/// the step size you specify, while displaying the current value.
///
/// In the example below, the stepper increments or decrements the binding
/// value by `5` each time one of the user clicks or taps the control's
/// increment or decrement buttons:
///
///     struct StepperView: View {
///         let title: String
///         @State private var value = 1
///
///         var body: some View {
///             Stepper(title, value: $value, step: 5, format: .number)
///                 .padding(10)
///         }
///     }
///
/// - Parameters:
///     - title: A string describing the purpose of the stepper.
///     - value: The ``Binding`` to a value that you provide.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - format: A format style of type `F` to use when converting between
///       the string the user edits and the underlying value of type
///       `F.FormatInput`. If `format` can't perform the conversion, the
///       stepper leaves `value` unchanged. If the user stops editing the
///       text in an invalid state, the stepper updates the text to the last
///       known valid value.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the
///       increment or decrement buttons on a `Stepper` which causes the
///       execution of the `onEditingChanged` closure at the start and end
///       of the gesture.
public init<S, F>(_ title: S, value: Binding<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
/// Creates a stepper instance that increments and decrements a binding to
/// a value, by a step size and within a closed range that you provide,
/// displaying its value with an applied format style.
///
/// Use `Stepper(_:value:in:step:format:onEditingChanged:)` to create a
/// stepper that increments or decrements a value within a specific range
/// of values by a specific step size, while displaying the current value.
/// In the example below, a stepper increments or decrements a binding to
/// value over a range of `1...50` by `5` each time the user clicks or taps
/// the stepper's increment or decrement buttons:
///
///     struct StepperView: View {
///         @State private var value = 0
///
///         var body: some View {
///             Stepper("Stepping by \(step) in \(range.description)",
///                 value: $value,
///                 in: 1...50,
///                 step: 5,
///                 format: .number
///             )
///             .padding()
///         }
///     }
///
/// - Parameters:
///     - titleKey: The key for the stepper's localized title describing
///       the purpose of the stepper.
///     - value: A ``Binding`` to a value that your provide.
///     - bounds: A closed range that describes the upper and lower bounds
///       permitted by the stepper.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - format: A format style of type `F` to use when converting between
///       the string the user edits and the underlying value of type
///       `F.FormatInput`. If `format` can't perform the conversion, the
///       stepper leaves `value` unchanged. If the user stops editing the
///       text in an invalid state, the stepper updates the text to the last
///       known valid value.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput>, in bounds: ClosedRange<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
/// Creates a stepper instance that increments and decrements a binding to
/// a value, by a step size and within a closed range that you provide,
/// displaying its value with an applied format style.
///
/// Use `Stepper(_:value:in:step:format:onEditingChanged:)` to create a
/// stepper that increments or decrements a value within a specific range
/// of values by a specific step size, while displaying the current value.
/// In the example below, a stepper increments or decrements a binding to
/// value over a range of `1...50` by `5` each time the user clicks or taps
/// the stepper's increment or decrement buttons:
///
///     struct StepperView: View {
///         let title: String
///         @State private var value = 0
///
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper(title,
///                 value: $value,
///                 in: 1...50,
///                 step: 5,
///                 format: .number
///             )
///             .padding()
///         }
///     }
///
/// - Parameters:
///     - title: A string describing the purpose of the stepper.
///     - value: A ``Binding`` to a value that your provide.
///     - bounds: A closed range that describes the upper and lower bounds
///       permitted by the stepper.
///     - step: The amount to increment or decrement `value` each time the
///       user clicks or taps the stepper's increment or decrement button,
///       respectively. Defaults to `1`.
///     - format: A format style of type `F` to use when converting between
///       the string the user edits and the underlying value of type
///       `F.FormatInput`. If `format` can't perform the conversion, the
///       stepper leaves `value` unchanged. If the user stops editing the
///       text in an invalid state, the stepper updates the text to the last
///       known valid value.
///     - onEditingChanged: A closure that's called when editing begins and
///       ends. For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
public init<S, F>(_ title: S, value: Binding<F.FormatInput>, in bounds: ClosedRange<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
}
@available(iOS 13.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Stepper {
/// Creates a stepper instance that performs the closures you provide when
/// the user increments or decrements the stepper.
///
/// Use this initializer to create a control with a custom title that
/// executes closures you provide when the user clicks or taps the
/// stepper's increment or decrement buttons.
///
/// The example below uses an array that holds a number of ``Color`` values,
/// a local state variable, `value`, to set the control's background
/// color, and title label. When the user clicks or taps on the stepper's
/// increment or decrement buttons SwiftUI executes the relevant
/// closure that updates `value`, wrapping the `value` to prevent overflow.
/// SwiftUI then re-renders the view, updating the text and background
/// color to match the current index:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let colors: [Color] = [.orange, .red, .gray, .blue, .green,
///                                .purple, .pink]
///
///         func incrementStep() {
///             value += 1
///             if value >= colors.count { value = 0 }
///         }
///
///         func decrementStep() {
///             value -= 1
///             if value < 0 { value = colors.count - 1 }
///         }
///
///         var body: some View {
///             Stepper(onIncrement: incrementStep,
///                 onDecrement: decrementStep) {
///                 Text("Value: \(value) Color: \(colors[value].description)")
///             }
///             .padding(5)
///             .background(colors[value])
///         }
///    }
///
/// ![A view displaying a stepper that uses a text view for stepper's title
///   and that changes the background color of its view when incremented or
///   decremented. The view selects the new background color from a
///    predefined array of colors using the stepper's value as the
///   index.](SwiftUI-Stepper-increment-decrement-closures.png)
///
/// - Parameters:
///     - onIncrement: The closure to execute when the user clicks or taps
///       the control's plus button.
///     - onDecrement: The closure to execute when the user clicks or taps
///       the control's minus button.
///     - onEditingChanged: A closure called when editing begins and ends.
///       For example, on iOS, the user may touch and hold the increment
///       or decrement buttons on a `Stepper` which causes the execution
///       of the `onEditingChanged` closure at the start and end of
///       the gesture.
///     - label: A view describing the purpose of this stepper.
@available(iOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)")
public init(onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label)
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value you provide.
///
/// Use this initializer to create a stepper that increments or decrements
/// a bound value by a specific amount each time the user
/// clicks or taps the stepper's increment or decrement buttons.
///
/// In the example below, a stepper increments or decrements `value` by the
/// `step` value of 5 at each click or tap of the control's increment or
/// decrement button:
///
///     struct StepperView: View {
///         @State private var value = 1
///         let step = 5
///         var body: some View {
///             Stepper(value: $value,
///                     step: step) {
///                 Text("Current value: \(value), step: \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper that increments or decrements a value by
///   a specified amount each time the user clicks or taps the stepper's
///   increment or decrement buttons.](SwiftUI-Stepper-value-step.png)
///
/// - Parameters:
///   - value: The ``Binding`` to a value that you provide.
///   - step: The amount to increment or decrement `value` each time the
///     user clicks or taps the stepper's increment or decrement buttons.
///     Defaults to `1`.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
///   - label: A view describing the purpose of this stepper.
@available(iOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)")
public init<V>(value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : Strideable
/// Creates a stepper configured to increment or decrement a binding to a
/// value using a step value and within a range of values you provide.
///
/// Use this initializer to create a stepper that increments or decrements
/// a binding to value by the step size you provide within the given bounds.
/// By setting the bounds, you ensure that the value never goes below or
/// above the lowest or highest value, respectively.
///
/// The example below shows a stepper that displays the effect of
/// incrementing or decrementing a value with the step size of `step`
/// with the bounds defined by `range`:
///
///     struct StepperView: View {
///         @State private var value = 0
///         let step = 5
///         let range = 1...50
///
///         var body: some View {
///             Stepper(value: $value,
///                     in: range,
///                     step: step) {
///                 Text("Current: \(value) in \(range.description) " +
///                      "stepping by \(step)")
///             }
///                 .padding(10)
///         }
///     }
///
/// ![A view displaying a stepper with a step size of five, and a
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png)
///
/// - Parameters:
///   - value: A ``Binding`` to a value that you provide.
///   - bounds: A closed range that describes the upper and lower bounds
///     permitted by the stepper.
///   - step: The amount to increment or decrement the stepper when the
///     user clicks or taps the stepper's increment or decrement buttons,
///     respectively.
///   - onEditingChanged: A closure that's called when editing begins and
///     ends. For example, on iOS, the user may touch and hold the increment
///     or decrement buttons on a stepper which causes the execution
///     of the `onEditingChanged` closure at the start and end of
///     the gesture.
///   - label: A view describing the purpose of this stepper.
@available(iOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)")
@available(watchOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)")
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : Strideable
}
/// A shape provider that strokes the border of its shape.
///
/// You don't create this type directly; it's the return type of
/// `Shape.strokeBorder`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct StrokeBorderShapeView<Content, Style, Background> : ShapeView where Content : InsettableShape, Style : ShapeStyle, Background : View {
/// The shape that this type draws and provides for other drawing
/// operations.
public var shape: Content
/// The style that strokes the border of this view's shape.
public var style: Style
/// The stroke style used when stroking this view's shape.
public var strokeStyle: StrokeStyle
/// Whether this shape should be drawn antialiased.
public var isAntialiased: Bool
/// The background shown beneath this view.
public var background: Background
/// Create a stroke border shape.
public init(shape: Content, style: Style, strokeStyle: StrokeStyle, isAntialiased: Bool, background: Background)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A shape provider that strokes its shape.
///
/// You don't create this type directly; it's the return type of
/// `Shape.stroke`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct StrokeShapeView<Content, Style, Background> : ShapeView where Content : Shape, Style : ShapeStyle, Background : View {
/// The shape that this type draws and provides for other drawing
/// operations.
public var shape: Content
/// The style that strokes this view's shape.
public var style: Style
/// The stroke style used when stroking this view's shape.
public var strokeStyle: StrokeStyle
/// Whether this shape should be drawn antialiased.
public var isAntialiased: Bool
/// The background shown beneath this view.
public var background: Background
/// Create a StrokeShapeView.
public init(shape: Content, style: Style, strokeStyle: StrokeStyle, isAntialiased: Bool, background: Background)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The characteristics of a stroke that traces a path.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct StrokeStyle : Equatable {
/// The width of the stroked path.
public var lineWidth: CGFloat
/// The endpoint style of a line.
public var lineCap: CGLineCap
/// The join type of a line.
public var lineJoin: CGLineJoin
/// A threshold used to determine whether to use a bevel instead of a
/// miter at a join.
public var miterLimit: CGFloat
/// The lengths of painted and unpainted segments used to make a dashed line.
public var dash: [CGFloat]
/// How far into the dash pattern the line starts.
public var dashPhase: CGFloat
/// Creates a new stroke style from the given components.
///
/// - Parameters:
///   - lineWidth: The width of the segment.
///   - lineCap: The endpoint style of a segment.
///   - lineJoin: The join type of a segment.
///   - miterLimit: The threshold used to determine whether to use a bevel
///     instead of a miter at a join.
///   - dash: The lengths of painted and unpainted segments used to make a
///     dashed line.
///   - dashPhase: How far into the dash pattern the line starts.
public init(lineWidth: CGFloat = 1, lineCap: CGLineCap = .butt, lineJoin: CGLineJoin = .miter, miterLimit: CGFloat = 10, dash: [CGFloat] = [CGFloat](), dashPhase: CGFloat = 0)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: StrokeStyle, b: StrokeStyle) -> Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension StrokeStyle : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGFloat, AnimatablePair<CGFloat, CGFloat>>
/// The data to animate.
public var animatableData: StrokeStyle.AnimatableData
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension StrokeStyle : Sendable {
}
/// A semantic label describing the label of submission within a view hierarchy.
///
/// A submit label is a description of a submission action provided to a
/// view hierarchy using the ``View/onSubmit(of:_:)`` modifier.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SubmitLabel : Sendable {
/// Defines a submit label with text of "Done".
public static var done: SubmitLabel { get }
/// Defines a submit label with text of "Go".
public static var go: SubmitLabel { get }
/// Defines a submit label with text of "Send".
public static var send: SubmitLabel { get }
/// Defines a submit label with text of "Join".
public static var join: SubmitLabel { get }
/// Defines a submit label with text of "Route".
public static var route: SubmitLabel { get }
/// Defines a submit label with text of "Search".
public static var search: SubmitLabel { get }
/// Defines a submit label with text of "Return".
public static var `return`: SubmitLabel { get }
/// Defines a submit label with text of "Next".
public static var next: SubmitLabel { get }
/// Defines a submit label with text of "Continue".
public static var `continue`: SubmitLabel { get }
}
/// A type that defines various triggers that result in the firing of a
/// submission action.
///
/// These triggers may be provided to the ``View/onSubmit(of:_:)``
/// modifier to alter which types of user behaviors trigger a provided
/// submission action.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SubmitTriggers : OptionSet, Sendable {
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: SubmitTriggers.RawValue
/// Creates a set of submit triggers.
public init(rawValue: SubmitTriggers.RawValue)
/// Defines triggers originating from text input controls like `TextField`
/// and `SecureField`.
public static let text: SubmitTriggers
/// Defines triggers originating from search fields constructed from
/// searchable modifiers.
///
/// In the example below, only the search field or search completions
/// placed by the searchable modifier will trigger the view model to submit
/// its current search query.
///
///     @StateObject private var viewModel = ViewModel()
///
///     NavigationView {
///         SidebarView()
///         DetailView()
///     }
///     .searchable(
///         text: $viewModel.searchText,
///         placement: .sidebar
///     ) {
///         SuggestionsView()
///     }
///     .onSubmit(of: .search) {
///         viewModel.submitCurrentSearchQuery()
///     }
///
public static let search: SubmitTriggers
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = SubmitTriggers
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = SubmitTriggers
}
/// A view that subscribes to a publisher with an action.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct SubscriptionView<PublisherType, Content> : View where PublisherType : Publisher, Content : View, PublisherType.Failure == Never {
/// The content view.
public var content: Content
/// The `Publisher` that is being subscribed.
public var publisher: PublisherType
/// The `Action` executed when `publisher` emits an event.
public var action: (PublisherType.Output) -> Void
@inlinable public init(content: Content, publisher: PublisherType, action: @escaping (PublisherType.Output) -> Void)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A toggle style that displays a leading label and a trailing switch.
///
/// Use the ``ToggleStyle/switch`` static variable to create this style:
///
///     Toggle("Enhance Sound", isOn: $isEnhanced)
///         .toggleStyle(.switch)
///
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
public struct SwitchToggleStyle : ToggleStyle {
/// Creates a switch toggle style.
///
/// Don't call this initializer directly. Instead, use the
/// ``ToggleStyle/switch`` static variable to create this style:
///
///     Toggle("Enhance Sound", isOn: $isEnhanced)
///         .toggleStyle(.switch)
///
public init()
/// Creates a switch style with a tint color.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(tvOS, unavailable)
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.")
public init(tint: Color)
/// Creates a view that represents the body of a toggle switch.
///
/// SwiftUI implements this required method of the ``ToggleStyle``
/// protocol to define the behavior and appearance of the
/// ``ToggleStyle/switch`` toggle style. Don't call this method
/// directly. Rather, the system calls this method for each
/// ``Toggle`` instance in a view hierarchy that's styled as
/// a switch.
///
/// - Parameter configuration: The properties of the toggle, including a
///   label and a binding to the toggle's state.
/// - Returns: A view that represents a switch.
public func makeBody(configuration: SwitchToggleStyle.Configuration) -> some View
/// A view that represents the appearance and interaction of a toggle.
///
/// SwiftUI infers this type automatically based on the ``View``
/// instance that you return from your implementation of the
/// ``makeBody(configuration:)`` method.
public typealias Body = some View
}
/// Creates a transition that applies the Appear or Disappear
/// symbol animation to symbol images within the inserted or
/// removed view hierarchy.
///
/// Other views are unaffected by this transition.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public struct SymbolEffectTransition : Transition {
public init<T>(effect: T, options: SymbolEffectOptions) where T : SymbolEffect, T : TransitionSymbolEffect
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: SymbolEffectTransition.Content, phase: TransitionPhase) -> some View
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
public static let properties: TransitionProperties
/// The type of view representing the body.
public typealias Body = some View
}
/// A symbol rendering mode.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SymbolRenderingMode : Sendable {
/// A mode that renders symbols as a single layer filled with the
/// foreground style.
///
/// For example, you can render a filled exclamation mark triangle in
/// purple:
///
///     Image(systemName: "exclamationmark.triangle.fill")
///         .symbolRenderingMode(.monochrome)
///         .foregroundStyle(Color.purple)
public static let monochrome: SymbolRenderingMode
/// A mode that renders symbols as multiple layers with their inherit
/// styles.
///
/// The layers may be filled with their own inherent styles, or the
/// foreground style. For example, you can render a filled exclamation
/// mark triangle in its inherent colors, with yellow for the triangle and
/// white for the exclamation mark:
///
///     Image(systemName: "exclamationmark.triangle.fill")
///         .symbolRenderingMode(.multicolor)
public static let multicolor: SymbolRenderingMode
/// A mode that renders symbols as multiple layers, with different opacities
/// applied to the foreground style.
///
/// SwiftUI fills the first layer with the foreground style, and the others
/// the secondary, and tertiary variants of the foreground style. You can
/// specify these styles explicitly using the ``View/foregroundStyle(_:_:)``
/// and ``View/foregroundStyle(_:_:_:)`` modifiers. If you only specify
/// a primary foreground style, SwiftUI automatically derives
/// the others from that style. For example, you can render a filled
/// exclamation mark triangle with purple as the tint color for the
/// exclamation mark, and lower opacity purple for the triangle:
///
///     Image(systemName: "exclamationmark.triangle.fill")
///         .symbolRenderingMode(.hierarchical)
///         .foregroundStyle(Color.purple)
public static let hierarchical: SymbolRenderingMode
/// A mode that renders symbols as multiple layers, with different styles
/// applied to the layers.
///
/// In this mode SwiftUI maps each successively defined layer in the image
/// to the next of the primary, secondary, and tertiary variants of the
/// foreground style. You can specify these styles explicitly using the
/// ``View/foregroundStyle(_:_:)`` and ``View/foregroundStyle(_:_:_:)``
/// modifiers. If you only specify a primary foreground style, SwiftUI
/// automatically derives the others from that style. For example, you can
/// render a filled exclamation mark triangle with yellow as the tint color
/// for the exclamation mark, and fill the triangle with cyan:
///
///     Image(systemName: "exclamationmark.triangle.fill")
///         .symbolRenderingMode(.palette)
///         .foregroundStyle(Color.yellow, Color.cyan)
///
/// You can also omit the symbol rendering mode, as specifying multiple
/// foreground styles implies switching to palette rendering mode:
///
///     Image(systemName: "exclamationmark.triangle.fill")
///         .foregroundStyle(Color.yellow, Color.cyan)
public static let palette: SymbolRenderingMode
}
/// A variant of a symbol.
///
/// Many of the
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/)
/// that you can add to your app using an ``Image`` or a ``Label`` instance
/// have common variants, like a filled version or a version that's
/// contained within a circle. The symbol's name indicates the variant:
///
///     VStack(alignment: .leading) {
///         Label("Default", systemImage: "heart")
///         Label("Fill", systemImage: "heart.fill")
///         Label("Circle", systemImage: "heart.circle")
///         Label("Circle Fill", systemImage: "heart.circle.fill")
///     }
///
/// ![A screenshot showing an outlined heart, a filled heart, a heart in
/// a circle, and a filled heart in a circle, each with a text label
/// describing the symbol.](SymbolVariants-1)
///
/// You can configure a part of your view hierarchy to use a particular variant
/// for all symbols in that view and its child views using `SymbolVariants`.
/// Add the ``View/symbolVariant(_:)`` modifier to a view to set a variant
/// for that view's environment. For example, you can use the modifier to
/// create the same set of labels as in the example above, using only the
/// base name of the symbol in the label declarations:
///
///     VStack(alignment: .leading) {
///         Label("Default", systemImage: "heart")
///         Label("Fill", systemImage: "heart")
///             .symbolVariant(.fill)
///         Label("Circle", systemImage: "heart")
///             .symbolVariant(.circle)
///         Label("Circle Fill", systemImage: "heart")
///             .symbolVariant(.circle.fill)
///     }
///
/// Alternatively, you can set the variant in the environment directly by
/// passing the ``EnvironmentValues/symbolVariants`` environment value to the
/// ``View/environment(_:_:)`` modifier:
///
///     Label("Fill", systemImage: "heart")
///         .environment(\.symbolVariants, .fill)
///
/// SwiftUI sets a variant for you in some environments. For example, SwiftUI
/// automatically applies the ``SymbolVariants/fill-swift.type.property``
/// symbol variant for items that appear in the `content` closure of the
/// ``View/swipeActions(edge:allowsFullSwipe:content:)``
/// method, or as the tab bar items of a ``TabView``.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SymbolVariants : Hashable, Sendable {
/// No variant for a symbol.
///
/// Using this variant with the ``View/symbolVariant(_:)`` modifier doesn't
/// have any effect. Instead, to show a symbol that ignores the current
/// variant, directly set the ``EnvironmentValues/symbolVariants``
/// environment value to `none` using the ``View/environment(_:_:)``
/// modifer:
///
///     HStack {
///         Image(systemName: "heart")
///         Image(systemName: "heart")
///             .environment(\.symbolVariants, .none)
///     }
///     .symbolVariant(.fill)
///
/// ![A screenshot of two heart symbols. The first is filled while the
/// second is outlined.](SymbolVariants-none-1)
public static let none: SymbolVariants
/// A variant that encapsulates the symbol in a circle.
///
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier
/// to draw symbols in a circle, for those symbols that have a circle
/// variant:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         .symbolVariant(.circle)
///     }
///
/// ![A screenshot showing two rows of four symbols each. Both rows contain
/// a flag, a heart, a bolt, and a star. The symbols in the second row are
/// versions of the symbols in the first row, but each is enclosed in a
/// circle.](SymbolVariants-circle-1)
public static let circle: SymbolVariants
/// A variant that encapsulates the symbol in a square.
///
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier
/// to draw symbols in a square, for those symbols that have a square
/// variant:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         .symbolVariant(.square)
///     }
///
/// ![A screenshot showing two rows of four symbols each. Both rows contain
/// a flag, a heart, a bolt, and a star. The symbols in the second row are
/// versions of the symbols in the first row, but each is enclosed in a
/// square.](SymbolVariants-square-1)
public static let square: SymbolVariants
/// A variant that encapsulates the symbol in a rectangle.
///
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier
/// to draw symbols in a rectangle, for those symbols that have a rectangle
/// variant:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "plus")
///             Image(systemName: "minus")
///             Image(systemName: "xmark")
///             Image(systemName: "checkmark")
///         }
///         HStack(spacing: 20) {
///             Image(systemName: "plus")
///             Image(systemName: "minus")
///             Image(systemName: "xmark")
///             Image(systemName: "checkmark")
///         }
///         .symbolVariant(.rectangle)
///     }
///
/// ![A screenshot showing two rows of four symbols each. Both rows contain
/// a plus sign, a minus sign, a multiplication sign, and a check mark.
/// The symbols in the second row are versions of the symbols in the first
/// row, but each is enclosed in a rectangle.](SymbolVariants-rectangle-1)
public static let rectangle: SymbolVariants
/// A version of the variant that's encapsulated in a circle.
///
/// Use this property to modify a variant like ``fill-swift.property``
/// so that it's also contained in a circle:
///
///     Label("Fill Circle", systemImage: "bolt")
///         .symbolVariant(.fill.circle)
///
/// ![A screenshot of a label that shows a bolt in a filled circle
/// beside the words Fill Circle.](SymbolVariants-circle-2)
public var circle: SymbolVariants { get }
/// A version of the variant that's encapsulated in a square.
///
/// Use this property to modify a variant like ``fill-swift.property``
/// so that it's also contained in a square:
///
///     Label("Fill Square", systemImage: "star")
///         .symbolVariant(.fill.square)
///
/// ![A screenshot of a label that shows a star in a filled square
/// beside the words Fill Square.](SymbolVariants-square-2)
public var square: SymbolVariants { get }
/// A version of the variant that's encapsulated in a rectangle.
///
/// Use this property to modify a variant like ``fill-swift.property``
/// so that it's also contained in a rectangle:
///
///     Label("Fill Rectangle", systemImage: "plus")
///         .symbolVariant(.fill.rectangle)
///
/// ![A screenshot of a label that shows a plus sign in a filled rectangle
/// beside the words Fill Rectangle.](SymbolVariants-rectangle-2)
public var rectangle: SymbolVariants { get }
/// A variant that fills the symbol.
///
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier
/// to draw filled symbols, for those symbols that have a filled variant:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         .symbolVariant(.fill)
///     }
///
/// ![A screenshot showing two rows of four symbols each. Both rows contain
/// a flag, a heart, a bolt, and a star. The symbols in the second row are
/// filled version of the symbols in the first row.](SymbolVariants-fill-1)
public static let fill: SymbolVariants
/// A filled version of the variant.
///
/// Use this property to modify a shape variant like
/// ``circle-swift.type.property`` so that it's also filled:
///
///     Label("Circle Fill", systemImage: "flag")
///         .symbolVariant(.circle.fill)
///
/// ![A screenshot of a label that shows a flag in a filled circle
/// beside the words Circle Fill.](SymbolVariants-fill-2)
public var fill: SymbolVariants { get }
/// A variant that draws a slash through the symbol.
///
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier
/// to draw symbols with a slash, for those symbols that have such a
/// variant:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         HStack(spacing: 20) {
///             Image(systemName: "flag")
///             Image(systemName: "heart")
///             Image(systemName: "bolt")
///             Image(systemName: "star")
///         }
///         .symbolVariant(.slash)
///     }
///
/// ![A screenshot showing two rows of four symbols each. Both rows contain
/// a flag, a heart, a bolt, and a star. A slash is superimposed over
/// all the symbols in the second row.](SymbolVariants-slash-1)
public static let slash: SymbolVariants
/// A slashed version of the variant.
///
/// Use this property to modify a shape variant like
/// ``circle-swift.type.property`` so that it's also covered by a slash:
///
///     Label("Circle Slash", systemImage: "flag")
///         .symbolVariant(.circle.slash)
///
/// ![A screenshot of a label that shows a flag in a circle with a
/// slash over it beside the words Circle Slash.](SymbolVariants-slash-2)
public var slash: SymbolVariants { get }
/// Returns a Boolean value that indicates whether the current variant
/// contains the specified variant.
///
/// - Parameter other: A variant to look for in this variant.
/// - Returns: `true` if this variant contains `other`; otherwise,
///   `false`.
public func contains(_ other: SymbolVariants) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: SymbolVariants, b: SymbolVariants) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A view that switches between multiple child views using interactive user
/// interface elements.
///
/// To create a user interface with tabs, place views in a `TabView` and apply
/// the ``View/tabItem(_:)`` modifier to the contents of each tab. On iOS, you
/// can also use one of the badge modifiers, like ``View/badge(_:)-84e43``, to
/// assign a badge to each of the tabs.
///
/// The following example creates a tab view with three tabs, each presenting a
/// custom child view. The first tab has a numeric badge and the third has a
/// string badge.
///
///     TabView {
///         ReceivedView()
///             .badge(2)
///             .tabItem {
///                 Label("Received", systemImage: "tray.and.arrow.down.fill")
///             }
///         SentView()
///             .tabItem {
///                 Label("Sent", systemImage: "tray.and.arrow.up.fill")
///             }
///         AccountView()
///             .badge("!")
///             .tabItem {
///                 Label("Account", systemImage: "person.crop.circle.fill")
///             }
///     }
///
/// ![A tab bar with three tabs, each with an icon image and a text label.
/// The first and third tabs have badges.](TabView-1)
///
/// Use a ``Label`` for each tab item, or optionally a ``Text``, an ``Image``,
/// or an image followed by text. Passing any other type of view results in a
/// visible but empty tab item.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
public struct TabView<SelectionValue, Content> : View where SelectionValue : Hashable, Content : View {
/// Creates an instance that selects from content associated with
/// `Selection` values.
public init(selection: Binding<SelectionValue>?, @ViewBuilder content: () -> Content)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
extension TabView where SelectionValue == Int {
public init(@ViewBuilder content: () -> Content)
}
/// A specification for the appearance and interaction of a `TabView`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol TabViewStyle {
}
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
@available(macOS, unavailable)
extension TabViewStyle where Self == PageTabViewStyle {
/// A `TabViewStyle` that implements a paged scrolling `TabView`.
public static var page: PageTabViewStyle { get }
/// A `TabViewStyle` that implements a paged scrolling `TabView` with an
/// index display mode.
public static func page(indexDisplayMode: PageTabViewStyle.IndexDisplayMode) -> PageTabViewStyle
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension TabViewStyle where Self == DefaultTabViewStyle {
/// The default `TabView` style.
public static var automatic: DefaultTabViewStyle { get }
}
/// A container that presents rows of data arranged in one or more columns,
/// optionally providing the ability to select one or more members.
///
/// You commonly create tables from collections of data. The following example
/// shows how to create a simple, three-column table from an array of `Person`
/// instances that conform to the
/// <doc://com.apple.documentation/documentation/Swift/Identifiable> protocol:
///
///     struct Person: Identifiable {
///         let givenName: String
///         let familyName: String
///         let emailAddress: String
///         let id = UUID()
///
///         var fullName: String { givenName + " " + familyName }
///     }
///
///     @State private var people = [
///         Person(givenName: "Juan", familyName: "Chavez", emailAddress: "juanchavez@icloud.com"),
///         Person(givenName: "Mei", familyName: "Chen", emailAddress: "meichen@icloud.com"),
///         Person(givenName: "Tom", familyName: "Clark", emailAddress: "tomclark@icloud.com"),
///         Person(givenName: "Gita", familyName: "Kumar", emailAddress: "gitakumar@icloud.com")
///     ]
///
///     struct PeopleTable: View {
///         var body: some View {
///             Table(people) {
///                 TableColumn("Given Name", value: \.givenName)
///                 TableColumn("Family Name", value: \.familyName)
///                 TableColumn("E-Mail Address", value: \.emailAddress)
///             }
///         }
///     }
///
/// ![A table with three columns and four rows, showing the
/// given name, family name, and email address of four people. Nonsortable
/// column headers at the top of the table indicate the data each column
/// displays.](Table-1-iOS)
///
/// If there are more rows than can fit in the available space, `Table` provides
/// vertical scrolling automatically. On macOS, the table also provides
/// horizontal scrolling if there are more columns than can fit in the width of the view. Scroll bars
/// appear as needed on iOS; on macOS, the `Table` shows or hides
/// scroll bars based on the "Show scroll bars" system preference.
///
/// ### Supporting selection in tables
///
/// To make rows of a table selectable, provide a binding to a selection
/// variable. Binding to a single instance of the table data's
/// <doc://com.apple.documentation/documentation/Swift/Identifiable/id-8t2ws>
/// type creates a single-selection table. Binding to a
/// <doc://com.apple.documentation/documentation/Swift/Set> creates a table that
/// supports multiple selections. The following example shows how to add
/// multi-select to the previous example. A ``Text`` view below the table shows
/// the number of items currently selected.
///
///     struct SelectableTable: View {
///         @State private var selectedPeople = Set<Person.ID>()
///
///         var body: some View {
///             Table(people, selection: $selectedPeople) {
///                 TableColumn("Given Name", value: \.givenName)
///                 TableColumn("Family Name", value: \.familyName)
///                 TableColumn("E-Mail Address", value: \.emailAddress)
///             }
///             Text("\(selectedPeople.count) people selected")
///         }
///     }
///
/// ### Supporting sorting in tables
///
/// To make the columns of a table sortable, provide a binding to an array
/// of <doc://com.apple.documentation/documentation/Foundation/SortComparator>
/// instances. The table reflects the sorted state through its column
/// headers, allowing sorting for any columns with key paths.
///
/// When the table sort descriptors update, re-sort the data collection
/// that underlies the table; the table itself doesn't perform a sort operation.
/// You can watch for changes in the sort descriptors by using a
/// ``View/onChange(of:perform:)`` modifier, and then sort the data in the
/// modifier's `perform` closure.
///
/// The following example shows how to add sorting capability to the
/// previous example:
///
///     struct SortableTable: View {
///         @State private var sortOrder = [KeyPathComparator(\Person.givenName)]
///
///         var body: some View {
///             Table(people, sortOrder: $sortOrder) {
///                 TableColumn("Given Name", value: \.givenName)
///                 TableColumn("Family Name", value: \.familyName)
///                 TableColumn("E-Mail address", value: \.emailAddress)
///             }
///             .onChange(of: sortOrder) {
///                 people.sort(using: $0)
///             }
///         }
///     }
///
/// ### Building tables with static rows
///
/// To create a table from static rows, rather than the contents of a collection
/// of data, you provide both the columns and the rows.
///
/// The following example shows a table that calculates prices from applying
/// varying gratuities ("tips") to a fixed set of prices. It creates the table
/// with the ``Table/init(of:columns:rows:)`` initializer, with the `rows`
/// parameter providing the base price that each row uses for its calculations. Each
/// column receives each price and performs its calculation, producing a
/// ``Text`` to display the formatted result.
///
///     struct Purchase: Identifiable {
///         let price: Decimal
///         let id = UUID()
///     }
///
///     struct TipTable: View {
///         let currencyStyle = Decimal.FormatStyle.Currency(code: "USD")
///
///         var body: some View {
///             Table(of: Purchase.self) {
///                 TableColumn("Base price") { purchase in
///                     Text(purchase.price, format: currencyStyle)
///                 }
///                 TableColumn("With 15% tip") { purchase in
///                     Text(purchase.price * 1.15, format: currencyStyle)
///                 }
///                 TableColumn("With 20% tip") { purchase in
///                     Text(purchase.price * 1.2, format: currencyStyle)
///                 }
///                 TableColumn("With 25% tip") { purchase in
///                     Text(purchase.price * 1.25, format: currencyStyle)
///                 }
///             } rows: {
///                 TableRow(Purchase(price: 20))
///                 TableRow(Purchase(price: 50))
///                 TableRow(Purchase(price: 75))
///             }
///         }
///     }
///
/// ![A table with four columns and three rows. Each row of the
/// table shows a base price — $20, $50, and $75 — followed in subsequent
/// columns by a dollar value calculated by applying a tip — 15%, 20%, and 25% —
/// to the base amount.](Table-2-macOS)
///
/// ### Styling tables
///
/// Use the ``View/tableStyle(_:)`` modifier to set a ``TableStyle`` for all
/// tables within a view. SwiftUI provides several table styles, such as
/// ``InsetTableStyle`` and, on macOS, ``BorderedTableStyle``. The default
/// style is ``AutomaticTableStyle``, which is available on all platforms
/// that support `Table`.
///
/// ### Using tables on different platforms
///
/// You can define a single table for use on macOS, iOS, and iPadOS.
/// However, in a compact horizontal size class environment --- typical on
/// iPhone or on iPad in certain modes, like Slide Over --- the table has
/// limited space to display its columns. To conserve space, the table
/// automatically hides headers and all columns after the first when it detects
/// this condition.
///
/// To provide a good user experience in a space-constrained environment, you
/// can customize the first column to show more information when you detect that
/// the ``EnvironmentValues/horizontalSizeClass`` environment value becomes
/// ``UserInterfaceSizeClass/compact``. For example, you can modify the sortable
/// table from above to conditionally show all the information in
/// the first column:
///
///     struct CompactableTable: View {
///         #if os(iOS)
///         @Environment(\.horizontalSizeClass) private var horizontalSizeClass
///         private var isCompact: Bool { horizontalSizeClass == .compact }
///         #else
///         private let isCompact = false
///         #endif
///
///         @State private var sortOrder = [KeyPathComparator(\Person.givenName)]
///
///         var body: some View {
///             Table(people, sortOrder: $sortOrder) {
///                 TableColumn("Given Name", value: \.givenName) { person in
///                     VStack(alignment: .leading) {
///                         Text(isCompact ? person.fullName : person.givenName)
///                         if isCompact {
///                             Text(person.emailAddress)
///                                 .foregroundStyle(.secondary)
///                         }
///                     }
///                 }
///                 TableColumn("Family Name", value: \.familyName)
///                 TableColumn("E-Mail Address", value: \.emailAddress)
///             }
///             .onChange(of: sortOrder) {
///                 people.sort(using: $0)
///             }
///         }
///     }
///
/// By making this change, you provide a list-like appearance for narrower
/// displays, while displaying the full table on wider ones.
/// Because you use the same table instance in both cases, you get a seamless
/// transition when the size class changes, like when someone moves your app
/// into or out of Slide Over.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct Table<Value, Rows, Columns> : View where Value == Rows.TableRowValue, Rows : TableRowContent, Columns : TableColumnContent, Rows.TableRowValue == Columns.TableRowValue {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Table {
/// Creates a table with the given columns and rows that generates its contents using values of the
/// given type.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a table with the given columns and rows that supports selecting
/// zero or one row that generates its data using values of the given type.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to the optional selected row ID.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, selection: Binding<Value.ID?>, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a table with the given columns and rows that supports selecting
/// multiple rows that generates its data using values of the given type.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to a set that identifies the selected rows IDs.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, selection: Binding<Set<Value.ID>>, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a sortable table with the given columns and rows.
///
/// - Parameters:
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting zero or one row.
///
/// - Parameters:
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting zero or one row.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type, selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting multiple rows.
///
/// - Parameters:
///   - selection: A binding to a set that identifies selected rows ids.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting multiple rows.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to a set that identifies selected rows ids.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type, selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Table {
/// Creates a table that computes its rows based on a collection of
/// identifiable data.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a table that computes its rows based on a collection of
/// identifiable data, and that supports selecting zero or one row.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to the optional selected row ID.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, selection: Binding<Value.ID?>, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a table that computes its rows based on a collection of
/// identifiable data, and that supports selecting multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, selection: Binding<Set<Value.ID>>, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data, and supports selecting zero or one row.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data, and supports selecting multiple rows.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Table {
/// Creates a table with the given columns and rows that generates its
/// contents using values of the given type and has dynamically customizable
/// columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a table with the given columns and rows that supports selecting
/// zero or one row that generates its data using values of the given type
/// and has dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to the optional selected row ID.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, selection: Binding<Value.ID?>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a table with the given columns and rows that supports selecting
/// multiple rows that generates its data using values of the given type
/// and has dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to a set that identifies the selected rows IDs.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init(of valueType: Value.Type, selection: Binding<Set<Value.ID>>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows)
/// Creates a sortable table with the given columns and rows and has
/// dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type = Value.self, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting zero or one row and has dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type = Value.self, selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a sortable table with the given columns and rows that supports
/// selecting multiple rows and dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - valueType: The type of value used to derive the table's contents.
///   - selection: A binding to a set that identifies selected rows ids.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
///   - rows: The rows to display in the table.
public init<Sort>(of valueType: Value.Type = Value.self, selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
/// Creates a table that computes its rows based on a collection of
/// identifiable data and has dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a table that computes its rows based on a collection of
/// identifiable data, that supports selecting zero or one row, and that has
/// dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to the optional selected row ID.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, selection: Binding<Value.ID?>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a table that computes its rows based on a collection of
/// identifiable data, that supports selecting multiple rows, and that has
/// dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, selection: Binding<Set<Value.ID>>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data and has dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data, supports selecting zero or one row, and has
/// dynamically customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable table that computes its rows based on a collection of
/// identifiable data, supports selecting multiple rows, and has dynamically
/// customizable columns.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableForEachContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Table {
/// Creates a hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, children: KeyPath<Value, Data?>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data, and supports selecting zero or one row.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - selection: A binding to the optional selected row ID.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Value.ID?>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data, and supports selecting multiple rows.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<Value.ID>>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Never> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Columns.TableRowValue == Data.Element
/// Creates a sortable, hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, children: KeyPath<Data.Element, Data?>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable, hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data, and supports selecting zero or one row.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - selection: A binding to the optional selected row ID.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
/// Creates a sortable, hierarchical table that computes its rows based on a
/// collection of identifiable data and key path to the children of that
/// data, and supports selecting multiple rows.
///
/// Each column in the table that should participate in customization is
/// required to have an identifier, specified with
/// ``TableColumnContent/customizationID(_:)``.
///
/// - Parameters:
///   - data: The identifiable data for computing the table rows.
///   - children: A key path to a property whose non-`nil` value gives the
///     children of `data`, and whose `nil` value represents a leaf row of
///     the hierarchy, which is not capable of having children.
///   - selection: A binding to a set that identifies selected rows IDs.
///   - sortOrder: A binding to the ordered sorting of columns.
///   - columnCustomization: A binding to the state of columns.
///   - columns: The columns to display in the table.
public init<Data, Sort>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<Value.ID>>, sortOrder: Binding<[Sort]>, columnCustomization: Binding<TableColumnCustomization<Value>>? = nil, @TableColumnBuilder<Value, Sort> columns: () -> Columns) where Rows == TableOutlineGroupContent<Data>, Data : RandomAccessCollection, Sort : SortComparator, Columns.TableRowValue == Data.Element, Data.Element == Sort.Compared
}
/// A column that displays a view for each row in a table.
///
/// You create a column with a label, content view, and optional key path.
/// The table calls the content view builder with the value for each row
/// in the table. The column uses a key path to map to a property of each row
/// value, which sortable tables use to reflect the current sort order.
///
/// The following example creates a sortable column for a table with `Person`
/// rows, displaying each person's given name:
///
///     TableColumn("Given name", value: \.givenName) { person in
///         Text(person.givenName)
///     }
///
/// For the common case of `String` properties, you can use the convenience
/// initializer that doesn't require an explicit content closure and displays
/// that string verbatim as a ``Text`` view. This means you can write the
/// previous example as:
///
///     TableColumn("Given name", value: \.givenName)
///
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableColumn<RowValue, Sort, Content, Label> : TableColumnContent where RowValue : Identifiable, Sort : SortComparator, Content : View, Label : View {
/// The type of value of rows presented by this column content.
public typealias TableRowValue = RowValue
/// The type of sort comparator associated with this table column content.
public typealias TableColumnSortComparator = Sort
/// The type of content representing the body of this table column content.
public typealias TableColumnBody = Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumn where RowValue == Sort.Compared, Label == Text {
/// Creates a sortable column that generates its label from a localized
/// string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see``Text``.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - comparator: The prototype sort comparator to use when representing
///     this column. When a person taps or clicks the column header,
///     the containing table's `sortOrder` incorporates this value,
///     potentially with a flipped order.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, sortUsing comparator: Sort, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column that generates its label from a string.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - comparator: The prototype sort comparator to use when representing
///     this column. When a person taps or clicks the column header,
///     the containing table's `sortOrder` incorporates this value,
///     potentially with a flipped order.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, sortUsing comparator: Sort, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column with text label.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - comparator: The prototype sort comparator to use when representing
///     this column. When a person taps or clicks the column header,
///     the containing table's `sortOrder` incorporates this value,
///     potentially with a flipped order.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, sortUsing comparator: Sort, @ViewBuilder content: @escaping (RowValue) -> Content)
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumn where Sort == Never, Label == Text {
/// Creates an unsortable column that generates its label from a localized
/// string key.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates an unsortable column that generates its label from a string.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates an unsortable column with a text label
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates an unsortable column that displays a string property that
/// generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column.
///     The table uses this to display the property as verbatim text in each
///     row of the table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, String>) where Content == Text
/// Creates an unsortable column that displays a string property that
/// generates its label from a string.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column.
///     The table uses this to display the property as verbatim text in each
///     row of the table.
public init<S>(_ title: S, value: KeyPath<RowValue, String>) where Content == Text, S : StringProtocol
/// Creates an unsortable column that displays a string property with a
/// text label.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column.
///     The table uses this to display the property as verbatim text in each
///     row of the table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, String>) where Content == Text
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumn {
/// Creates a fixed width table column that isn't user resizable.
///
/// - Parameter width: A fixed width for the resulting column. If `width`
///   is `nil`, the resulting column has no change in sizing.
public func width(_ width: CGFloat? = nil) -> TableColumn<RowValue, Sort, Content, Label>
/// Creates a resizable table column with the provided constraints.
///
/// Always specify at least one width constraint when calling this method.
/// Pass `nil` or leave out a constraint to indicate no change to the
/// sizing of a column.
///
/// To create a fixed size column use ``SwiftUI/TableColumn/width(_:)``
/// instead.
///
/// - Parameters:
///   - min: The minimum width of a resizable column. If non-`nil`, the
///     value must be greater than or equal to `0`.
///   - ideal: The ideal width of the column, used to determine the initial
///     width of the table column. The column always starts at least as
///     large as the set ideal size, but may be larger if table was sized
///     larger than the ideal of all of its columns.
///   - max: The maximum width of a resizable column. If non-`nil`, the
///     value must be greater than `0`. Pass
///     <doc://com.apple.documentation/documentation/CoreGraphics/CGFloat/1454161-infinity>
///     to indicate unconstrained maximum width.
public func width(min: CGFloat? = nil, ideal: CGFloat? = nil, max: CGFloat? = nil) -> TableColumn<RowValue, Sort, Content, Label>
/// Does not change the table column's width.
///
/// Use ``SwiftUI/TableColumn/width(_:)`` or
/// ``SwiftUI/TableColumn/width(min:ideal:max:)`` instead.
@available(*, deprecated, message: "Please pass one or more parameters to modify a column's width.")
public func width() -> TableColumn<RowValue, Sort, Content, Label>
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumn where Sort == KeyPathComparator<RowValue>, Label == Text {
/// Creates a sortable column for comparable values that generates its label
/// from a localized string key.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<V>(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, V>, @ViewBuilder content: @escaping (RowValue) -> Content) where V : Comparable
/// Creates a sortable column for comparable values that generates its label
/// from a string.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S, V>(_ title: S, value: KeyPath<RowValue, V>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol, V : Comparable
/// Creates a sortable column for comparable values with a text label.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init<V>(_ text: Text, value: KeyPath<RowValue, V>, @ViewBuilder content: @escaping (RowValue) -> Content) where V : Comparable
/// Creates a sortable column that generates its label from a localized
/// string key, and uses an explicit comparator for sorting values.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The `SortComparator` used to order values of the sort
///     value type.
///   - content: The view content to display for each row in a table.
public init<V, C>(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, V>, comparator: C, @ViewBuilder content: @escaping (RowValue) -> Content) where V == C.Compared, C : SortComparator
/// Creates a sortable column that generates its label from a string, and
/// uses an explicit comparator for sorting values.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The `SortComparator` used to order values of the sort
///     value type.
///   - content: The view content to display for each row in a table.
public init<S, V, C>(_ title: S, value: KeyPath<RowValue, V>, comparator: C, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol, V == C.Compared, C : SortComparator
/// Creates a sortable column that has a text label, and uses an explicit
/// comparator for sorting values.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The `SortComparator` used to order values of the sort
///     value type.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init<V, C>(_ text: Text, value: KeyPath<RowValue, V>, comparator: C, @ViewBuilder content: @escaping (RowValue) -> Content) where V == C.Compared, C : SortComparator
/// Creates a sortable column that displays a string property, and
/// generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     to display verbatim as text in each row of a table,
///     and the key path used to create a sort comparator when
///     sorting the column.
///   - comparator: The `SortComparator` used to order the string values.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text
/// Creates a sortable column that displays a string property, and
/// generates its label from a string.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     to display verbatim as text in each row of a table,
///     and the key path used to create a sort comparator when
///     sorting the column.
///   - comparator: The `SortComparator` used to order the string values.
public init<S>(_ title: S, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text, S : StringProtocol
/// Creates a sortable column that displays a string property and
/// has a text label.
///
/// This initializer creates a ``Text`` view for you, and treats the
/// title similar to ``Text/init(_:)-9d1g4``.
/// For more information about localizing strings, see ``Text``.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     to display verbatim as text in each row of a table,
///     and the key path used to create a sort comparator when
///     sorting the column.
///   - comparator: The `SortComparator` used to order the string values.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumn where RowValue : NSObject, Sort == SortDescriptor<RowValue>, Label == Text {
/// Creates a sortable column for Boolean values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Bool>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for Boolean
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Bool>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for Boolean values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Bool>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional Boolean values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Bool?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional Boolean values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Bool?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional Boolean values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Bool?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for double-precision floating-point values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Double>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for double-precision floating-point
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Double>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for double-precision floating-point values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Double>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional double-precision floating-point values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Double?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional double-precision floating-point values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Double?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional double-precision floating-point values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Double?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for single-precision floating-point values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Float>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for single-precision floating-point
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Float>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for single-precision floating-point values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Float>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional single-precision floating-point values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Float?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional single-precision floating-point values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Float?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional single-precision floating-point values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Float?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 8-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int8>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 8-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int8>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for 8-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int8>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 8-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int8?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 8-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int8?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional 8-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int8?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 16-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int16>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 16-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int16>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for 16-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int16>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 16-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int16?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 16-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int16?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional 16-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int16?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 32-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int32>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 32-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int32>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for 32-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int32>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 32-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int32?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 32-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int32?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional 32-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int32?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 64-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int64>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for 64-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int64>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for 64-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int64>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 64-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int64?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional 64-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int64?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional 64-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int64?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Int?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Int?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Int?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 8-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt8>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 8-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt8>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for unsigned 8-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt8>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 8-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt8?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 8-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt8?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional unsigned 8-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt8?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 16-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt16>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 16-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt16>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for unsigned 16-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt16>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 16-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt16?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 16-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt16?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional unsigned 16-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt16?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 32-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt32>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 32-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt32>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for unsigned 32-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt32>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 32-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt32?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 32-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt32?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional unsigned 32-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt32?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 64-bit integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt64>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned 64-bit integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt64>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for unsigned 64-bit integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt64>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 64-bit integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt64?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned 64-bit integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt64?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional unsigned 64-bit integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt64?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned integer values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for unsigned integer
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for unsigned integer values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned integer values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UInt?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional unsigned integer values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UInt?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional unsigned integer values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UInt?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for date values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Date>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for date
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Date>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for date values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Date>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional date values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, Date?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional date values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, Date?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional date values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, Date?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for UUID values
/// that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UUID>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for UUID
/// values that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UUID>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for UUID values with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     which will be used to update and reflect the sorting state in a
///     table.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UUID>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional UUID values that generates
/// its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, UUID?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column for optional UUID values that displays a
/// string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, UUID?>, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column for optional UUID values with a text
/// label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, UUID?>, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column that generates its label from a localized
/// string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column with a text label.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column that generates its label from a localized
/// string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, String?>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates a sortable column that displays a string property.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
public init<S>(_ title: S, value: KeyPath<RowValue, String?>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content) where S : StringProtocol
/// Creates a sortable column with a text label.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state.
///   - comparator: The specific comparator to compare string values.
///   - content: The view content to display for each row in a table.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, String?>, comparator: String.StandardComparator = .localizedStandard, @ViewBuilder content: @escaping (RowValue) -> Content)
/// Creates an unsortable column that displays a string property, and which
/// generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// ``Text`` for more information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the column's localized title.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state and to display as verbatim
///     text in each row.
///   - comparator: The specific comparator to compare string values.
public init(_ titleKey: LocalizedStringKey, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text
/// Creates a sortable column that displays a string property, and which
/// generates its label from a string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. For more information about
/// localizing strings, see ``Text``.
///
/// - Parameters:
///   - title: A string that describes the column.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state and to display as verbatim
///     text in each row.
///   - comparator: The specific comparator to compare string values.
public init<S>(_ title: S, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text, S : StringProtocol
/// Creates an unsortable column that displays a string property and has a
/// text label.
///
/// - Parameters:
///   - text: The column's label.
///   - value: The path to the property associated with the column,
///     used to update the table's sorting state and to display as verbatim
///     text in each row.
///   - comparator: The specific comparator to compare string values.
@available(iOS 16.6, macOS 13.5, *)
public init(_ text: Text, value: KeyPath<RowValue, String>, comparator: String.StandardComparator = .localizedStandard) where Content == Text
}
/// Describes the alignment of the content of a table column.
///
/// The alignment of a column applies to both its header label as well as the
/// default alignment of its content view for each row.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableColumnAlignment : Hashable, Sendable {
/// The default column alignment.
///
/// This is equivalent to `leading`.
public static var automatic: TableColumnAlignment { get }
/// Leading column alignment.
///
/// With a `layoutDirection` of `leftToRight`, this is equivalent to left;
/// and with a `layoutDirection` of `rightToLeft`, this is equivalent to
/// right.
public static var leading: TableColumnAlignment { get }
/// Center column alignment.
public static var center: TableColumnAlignment { get }
/// Trailing column alignment.
///
/// With a `layoutDirection` of `leftToRight`, this is equivalent to right;
/// and with a `layoutDirection` of `rightToLeft`, this is equivalent to
/// left.
public static var trailing: TableColumnAlignment { get }
/// Column alignment appropriate for numeric content.
///
/// Use this alignment when a table column is primarily displaying numeric
/// content, so that the values are easy to visually scan and compare.
///
/// This uses the current locale's numbering system to determine the
/// alignment:
/// - For left to right numbering systems, this is equivalent to right.
/// - For right to left numbering systems, this is equivalent to left.
public static var numeric: TableColumnAlignment { get }
/// Column alignment appropriate for numeric content.
///
/// Use this alignment when a table column is primarily displaying numeric
/// content, so that the values are easy to visually scan and compare.
///
/// This uses the provided numbering system to determine the alignment:
/// - For left to right numbering systems, this is equivalent to right.
/// - For right to left numbering systems, this is equivalent to left.
public static func numeric(_ numberingSystem: Locale.NumberingSystem) -> TableColumnAlignment
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TableColumnAlignment, b: TableColumnAlignment) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A result builder that creates table column content from closures.
///
/// The `buildBlock` methods in this type create ``TableColumnContent``
/// instances based on the number and types of sources provided as parameters.
///
/// Don't use this type directly; instead, SwiftUI annotates the `columns`
/// parameter of the various ``Table`` initializers with the
/// `@TableColumnBuilder` annotation, implicitly calling this builder for you.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@resultBuilder public struct TableColumnBuilder<RowValue, Sort> where RowValue : Identifiable, Sort : SortComparator {
/// Creates a sortable table column expression whose value and sort types
/// match those of the builder.
public static func buildExpression<Content, Label>(_ column: TableColumn<RowValue, Sort, Content, Label>) -> TableColumn<RowValue, Sort, Content, Label> where Content : View, Label : View
/// Creates a sortable table column expression whose value type matches
/// that of the builder.
public static func buildExpression<Content, Label>(_ column: TableColumn<RowValue, Never, Content, Label>) -> TableColumn<RowValue, Never, Content, Label> where Content : View, Label : View
/// Creates a generic, sortable single column expression.
public static func buildExpression<Column>(_ column: Column) -> Column where RowValue == Column.TableRowValue, Sort == Column.TableColumnSortComparator, Column : TableColumnContent
/// Creates a generic, unsortable single column expression.
public static func buildExpression<Column>(_ column: Column) -> Column where RowValue == Column.TableRowValue, Column : TableColumnContent, Column.TableColumnSortComparator == Never
/// Creates a single, sortable column result.
public static func buildBlock<Column>(_ column: Column) -> Column where RowValue == Column.TableRowValue, Sort == Column.TableColumnSortComparator, Column : TableColumnContent
/// Creates a single, unsortable column result.
public static func buildBlock<Column>(_ column: Column) -> Column where RowValue == Column.TableRowValue, Column : TableColumnContent, Column.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from two sources.
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleTableColumnContent<RowValue, Sort, (C0, C1)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C0.TableRowValue == C1.TableRowValue
/// Creates an unsortable column result from two sources.
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleTableColumnContent<RowValue, Never, (C0, C1)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from three sources.
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue
/// Creates an unsortable column result from three sources.
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from four sources.
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue
/// Creates an unsortable column result from four sources.
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from five sources.
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue
/// Creates an unsortable column result from five sources.
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from six sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4, C5)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue
/// Creates an unsortable column result from six sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4, C5)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never, C4.TableRowValue == C5.TableRowValue, C5.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from seven sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4, C5, C6)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue
/// Creates an unsortable column result from seven sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4, C5, C6)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never, C4.TableRowValue == C5.TableRowValue, C5.TableColumnSortComparator == Never, C5.TableRowValue == C6.TableRowValue, C6.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from eight sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4, C5, C6, C7)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue
/// Creates an unsortable column result from eight sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4, C5, C6, C7)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never, C4.TableRowValue == C5.TableRowValue, C5.TableColumnSortComparator == Never, C5.TableRowValue == C6.TableRowValue, C6.TableColumnSortComparator == Never, C6.TableRowValue == C7.TableRowValue, C7.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from nine sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4, C5, C6, C7, C8)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C8 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue, C7.TableRowValue == C8.TableRowValue
/// Creates an unsortable column result from nine sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4, C5, C6, C7, C8)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C8 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never, C4.TableRowValue == C5.TableRowValue, C5.TableColumnSortComparator == Never, C5.TableRowValue == C6.TableRowValue, C6.TableColumnSortComparator == Never, C6.TableRowValue == C7.TableRowValue, C7.TableColumnSortComparator == Never, C7.TableRowValue == C8.TableRowValue, C8.TableColumnSortComparator == Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnBuilder {
/// Creates a sortable column result from ten sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> TupleTableColumnContent<RowValue, Sort, (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C8 : TableColumnContent, C9 : TableColumnContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue, C7.TableRowValue == C8.TableRowValue, C8.TableRowValue == C9.TableRowValue
/// Creates an unsortable column result from ten sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> TupleTableColumnContent<RowValue, Never, (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)> where RowValue == C0.TableRowValue, C0 : TableColumnContent, C1 : TableColumnContent, C2 : TableColumnContent, C3 : TableColumnContent, C4 : TableColumnContent, C5 : TableColumnContent, C6 : TableColumnContent, C7 : TableColumnContent, C8 : TableColumnContent, C9 : TableColumnContent, C0.TableColumnSortComparator == Never, C0.TableRowValue == C1.TableRowValue, C1.TableColumnSortComparator == Never, C1.TableRowValue == C2.TableRowValue, C2.TableColumnSortComparator == Never, C2.TableRowValue == C3.TableRowValue, C3.TableColumnSortComparator == Never, C3.TableRowValue == C4.TableRowValue, C4.TableColumnSortComparator == Never, C4.TableRowValue == C5.TableRowValue, C5.TableColumnSortComparator == Never, C5.TableRowValue == C6.TableRowValue, C6.TableColumnSortComparator == Never, C6.TableRowValue == C7.TableRowValue, C7.TableColumnSortComparator == Never, C7.TableRowValue == C8.TableRowValue, C8.TableColumnSortComparator == Never, C8.TableRowValue == C9.TableRowValue, C9.TableColumnSortComparator == Never
}
/// A type used to represent columns within a table.
///
/// This type provides the body content of the column, as well as the types
/// of the column's row values and the comparator used to sort rows.
///
/// You can factor column content out into separate types or properties, or
/// by creating a custom type conforming to `TableColumnContent`.
///
///     var body: some View {
///         Table(people, selection: $selectedPeople, sortOrder: $sortOrder) {
///             nameColumns
///
///             TableColumn("Location", value: \.location) {
///                 LocationView($0.location)
///             }
///         }
///     }
///
///     @TableColumnBuilder<Person, KeyPathComparator<Person>>
///     private var nameColumns: some TableColumnContent<
///         Person, KeyPathComparator<Person>
///     > {
///         TableColumn("First Name", value: \.firstName) {
///             PrimaryColumnView(person: $0)
///         }
///         TableColumn("Last Name", value: \.lastName)
///         TableColumn("Nickname", value: \.nickname)
///     }
///
/// The above example factors three table columns into a separate computed
/// property that has an opaque type. The property's primary associated
/// type `TableRowValue` is a `Person` and its associated type
/// `TableColumnSortComparator` is a key comparator for the `Person` type.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol TableColumnContent<TableRowValue, TableColumnSortComparator> {
/// The type of value of rows presented by this column content.
associatedtype TableRowValue : Identifiable = Self.TableColumnBody.TableRowValue
/// The type of sort comparator associated with this table column content.
associatedtype TableColumnSortComparator : SortComparator = Self.TableColumnBody.TableColumnSortComparator
/// The type of content representing the body of this table column content.
associatedtype TableColumnBody : TableColumnContent
/// The composition of content that comprise the table column content.
var tableColumnBody: Self.TableColumnBody { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnContent {
/// Sets the default visibility of a table column.
///
/// A `hidden` column will not be visible, unless the `Table` is also bound
/// to `TableColumnCustomization` and either modified programmatically or by
/// the user.
///
/// - Parameter visibility: The default visibility to apply to columns.
public func defaultVisibility(_ visibility: Visibility) -> some TableColumnContent<Self.TableRowValue, Self.TableColumnSortComparator>
/// Sets the identifier to be associated with a column when persisting its
/// state with `TableColumnCustomization`.
///
/// This is required to allow user customization of a specific table column,
/// in addition to the table as a whole being provided a binding to a
/// `TableColumnCustomization`.
///
/// The identifier needs to to be stable, including across app version
/// updates, since it is used to persist the user customization.
///
/// - Parameter id: The identifier to associate with a column.
public func customizationID(_ id: String) -> some TableColumnContent<Self.TableRowValue, Self.TableColumnSortComparator>
/// Sets the disabled customization behavior for a table column.
///
/// When the containing `Table` is bound to some `TableColumnCustomization`,
/// all columns will be able to be customized by the user on macOS by
/// default (i.e. `TableColumnCustomizationBehavior.all`). This
/// modifier allows disabling specific behavior.
///
/// This modifier has no effect on iOS since `Table` does not support any
/// built-in user customization features.
///
/// This does not prevent programmatic changes to a table column
/// customization.
///
/// - Parameter behavior: The behavior to disable, or `.all` to not allow
///   any customization.
public func disabledCustomizationBehavior(_ behavior: TableColumnCustomizationBehavior) -> some TableColumnContent<Self.TableRowValue, Self.TableColumnSortComparator>
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableColumnContent {
/// Sets the alignment of the column, applying to both its column header
/// label and the row view content for that column.
///
/// - Parameter alignment: The alignment to apply to the column.
public func alignment(_ alignment: TableColumnAlignment) -> some TableColumnContent<Self.TableRowValue, Self.TableColumnSortComparator>
}
/// A representation of the state of the columns in a table.
///
/// `TableColumnCustomization` can be created and provided to a table to enable
/// column reordering and column visibility. The state can be queried and
/// updated programmatically, as well as bound to persistent app or scene
/// storage.
///
///     struct BugReportTable: View {
///         @ObservedObject var dataModel: DataModel
///         @Binding var selectedBugReports: Set<BugReport.ID>
///
///         @SceneStorage("BugReportTableConfig")
///         private var columnCustomization: TableColumnCustomization<BugReport>
///
///         var body: some View {
///             Table(dataModel.bugReports, selection: $selectedBugReports,
///                 sortOrder: $dataModel.sortOrder,
///                 columnCustomization: $columnCustomization
///             ) {
///                 TableColumn("Title", value: \.title)
///                     .customizationID("title")
///                 TableColumn("ID", value: \.id) {
///                     Link("\($0.id)", destination: $0.url)
///                 }
///                 .customizationID("id")
///                 TableColumn("Number of Reports", value: \.duplicateCount) {
///                     Text($0.duplicateCount, format: .number)
///                 }
///                 .customizationID("duplicates")
///             }
///         }
///     }
///
/// The above example creates a table with three columns. On macOS, these
/// columns can be reordered or hidden and shown by the user of the app.
/// Their configuration will be saved and restored with the window on relaunches
/// of the app, using the "BugReportTableConfig" scene storage identifier.
///
/// The state of a specific column is stored relative to its customization
/// identifier, using using the value from the
/// ``TableColumnContent/customizationID(_:)`` modifier.
/// When column customization is encoded and decoded, it relies on stable
/// identifiers to restore the associate the saved state with a specific column.
/// If a table column does not have a customization identifier, it will not
/// be customizable.
///
/// These identifiers can also be used to programmatically change column
/// customizations, such as programmatically hiding a column:
///
///     columnCustomization[visibility: "duplicates"] = .hidden
///
/// With a binding to the overall customization, a binding to the visibility
/// of a column can be accessed using the same subscript syntax:
///
///     struct BugReportTable: View {
///         @SceneStorage("BugReportTableConfig")
///         private var columnCustomization: TableColumnCustomization<BugReport>
///
///         var body: some View {
///             ...
///             MyVisibilityView($columnCustomization[visibility: "duplicates"])
///         }
///     }
///
///     struct MyVisibilityView: View {
///         @Binding var visibility: Visibility
///         ...
///     }
///
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableColumnCustomization<RowValue> : Equatable, Sendable, Codable where RowValue : Identifiable {
/// Creates an empty table column customization.
///
/// With an empty customization, columns will be ordered as described by the
/// table's column builder.
public init()
/// The visibility of the column identified by its identifier.
///
/// Explicit identifiers can be associated with a `TableColumn` using the
/// `customizationID(_:)` modifier.
///
///     TableColumn("Number of Reports", value: \.duplicateCount) {
///         Text($0.duplicateCount, format: .number)
///     }
///     .customizationID("numberOfReports")
///
///     ...
///
///     columnsCustomization[visibility: "numberOfReports"] = .hidden
///
/// If the ID isn't associated with the state, a default value of
/// `.automatic` is returned.
public subscript(visibility id: String) -> Visibility
/// Resets the column order back to the default, preserving the customized
/// visibility and size.
///
/// Tables that are bound to this state will order their columns as
/// described by their column builder.
public mutating func resetOrder()
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TableColumnCustomization<RowValue>, b: TableColumnCustomization<RowValue>) -> Bool
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
public func encode(to encoder: Encoder) throws
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
public init(from decoder: Decoder) throws
}
/// A set of customization behaviors of a column that a table can offer to
/// a user.
///
/// This is used as a value provided to
/// ``TableColumnContent/disabledCustomizationBehavior(_:)``.
///
/// Setting any of these values as the `disabledCustomizationBehavior(_:)`
/// doesn't have any effect on iOS.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableColumnCustomizationBehavior : SetAlgebra, Sendable {
/// A type for which the conforming type provides a containment test.
public typealias Element = TableColumnCustomizationBehavior
/// Creates an empty customization behavior, representing no customization
public init()
/// All customization behaviors.
public static var all: TableColumnCustomizationBehavior { get }
/// A behavior that allows the column to be reordered by the user.
public static let reorder: TableColumnCustomizationBehavior
/// A behavior that allows the column to be resized by the user.
public static let resize: TableColumnCustomizationBehavior
/// A behavior that allows the column to be hidden or revealed by the user.
public static let visibility: TableColumnCustomizationBehavior
/// Returns a Boolean value that indicates whether the given element exists
/// in the set.
///
/// This example uses the `contains(_:)` method to test whether an integer is
/// a member of a set of prime numbers.
///
///     let primes: Set = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
///     let x = 5
///     if primes.contains(x) {
///         print("\(x) is prime!")
///     } else {
///         print("\(x). Not prime.")
///     }
///     // Prints "5 is prime!"
///
/// - Parameter member: An element to look for in the set.
/// - Returns: `true` if `member` exists in the set; otherwise, `false`.
public func contains(_ member: TableColumnCustomizationBehavior.Element) -> Bool
/// Returns a new set with the elements of both this and the given set.
///
/// In the following example, the `attendeesAndVisitors` set is made up
/// of the elements of the `attendees` and `visitors` sets:
///
///     let attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors = ["Marcia", "Nathaniel"]
///     let attendeesAndVisitors = attendees.union(visitors)
///     print(attendeesAndVisitors)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     let initialIndices = Set(0..<5)
///     let expandedIndices = initialIndices.union([2, 3, 6, 7])
///     print(expandedIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set with the unique elements of this set and `other`.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func union(_ other: TableColumnCustomizationBehavior) -> TableColumnCustomizationBehavior
/// Returns a new set with the elements that are common to both this set and
/// the given set.
///
/// In the following example, the `bothNeighborsAndEmployees` set is made up
/// of the elements that are in *both* the `employees` and `neighbors` sets.
/// Elements that are in only one or the other are left out of the result of
/// the intersection.
///
///     let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     let bothNeighborsAndEmployees = employees.intersection(neighbors)
///     print(bothNeighborsAndEmployees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
///
/// - Note: if this set and `other` contain elements that are equal but
///   distinguishable (e.g. via `===`), which of these elements is present
///   in the result is unspecified.
public func intersection(_ other: TableColumnCustomizationBehavior) -> TableColumnCustomizationBehavior
/// Returns a new set with the elements that are either in this set or in the
/// given set, but not in both.
///
/// In the following example, the `eitherNeighborsOrEmployees` set is made up
/// of the elements of the `employees` and `neighbors` sets that are not in
/// both `employees` *and* `neighbors`. In particular, the names `"Bethany"`
/// and `"Eric"` do not appear in `eitherNeighborsOrEmployees`.
///
///     let employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors)
///     print(eitherNeighborsOrEmployees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type as the current set.
/// - Returns: A new set.
public func symmetricDifference(_ other: TableColumnCustomizationBehavior) -> TableColumnCustomizationBehavior
/// Inserts the given element in the set if it is not already present.
///
/// If an element equal to `newMember` is already contained in the set, this
/// method has no effect. In this example, a new element is inserted into
/// `classDays`, a set of days of the week. When an existing element is
/// inserted, the `classDays` set does not change.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.wednesday, .friday]
///     print(classDays.insert(.monday))
///     // Prints "(true, .monday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
///     print(classDays.insert(.friday))
///     // Prints "(false, .friday)"
///     print(classDays)
///     // Prints "[.friday, .wednesday, .monday]"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: `(true, newMember)` if `newMember` was not contained in the
///   set. If an element equal to `newMember` was already contained in the
///   set, the method returns `(false, oldMember)`, where `oldMember` is the
///   element that was equal to `newMember`. In some cases, `oldMember` may
///   be distinguishable from `newMember` by identity comparison or some
///   other means.
public mutating func insert(_ newMember: TableColumnCustomizationBehavior.Element) -> (inserted: Bool, memberAfterInsert: TableColumnCustomizationBehavior.Element)
/// Removes the given element and any elements subsumed by the given element.
///
/// - Parameter member: The element of the set to remove.
/// - Returns: For ordinary sets, an element equal to `member` if `member` is
///   contained in the set; otherwise, `nil`. In some cases, a returned
///   element may be distinguishable from `member` by identity comparison
///   or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the set
///   and `[member]`, or `nil` if the intersection is empty.
public mutating func remove(_ member: TableColumnCustomizationBehavior.Element) -> TableColumnCustomizationBehavior.Element?
/// Inserts the given element into the set unconditionally.
///
/// If an element equal to `newMember` is already contained in the set,
/// `newMember` replaces the existing element. In this example, an existing
/// element is inserted into `classDays`, a set of days of the week.
///
///     enum DayOfTheWeek: Int {
///         case sunday, monday, tuesday, wednesday, thursday,
///             friday, saturday
///     }
///
///     var classDays: Set<DayOfTheWeek> = [.monday, .wednesday, .friday]
///     print(classDays.update(with: .monday))
///     // Prints "Optional(.monday)"
///
/// - Parameter newMember: An element to insert into the set.
/// - Returns: For ordinary sets, an element equal to `newMember` if the set
///   already contained such a member; otherwise, `nil`. In some cases, the
///   returned element may be distinguishable from `newMember` by identity
///   comparison or some other means.
///
///   For sets where the set type and element type are the same, like
///   `OptionSet` types, this method returns any intersection between the
///   set and `[newMember]`, or `nil` if the intersection is empty.
public mutating func update(with newMember: TableColumnCustomizationBehavior.Element) -> TableColumnCustomizationBehavior.Element?
/// Adds the elements of the given set to the set.
///
/// In the following example, the elements of the `visitors` set are added to
/// the `attendees` set:
///
///     var attendees: Set = ["Alicia", "Bethany", "Diana"]
///     let visitors: Set = ["Diana", "Marcia", "Nathaniel"]
///     attendees.formUnion(visitors)
///     print(attendees)
///     // Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
///
/// If the set already contains one or more elements that are also in
/// `other`, the existing members are kept.
///
///     var initialIndices = Set(0..<5)
///     initialIndices.formUnion([2, 3, 6, 7])
///     print(initialIndices)
///     // Prints "[2, 4, 6, 7, 0, 1, 3]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formUnion(_ other: TableColumnCustomizationBehavior)
/// Removes the elements of this set that aren't also in the given set.
///
/// In the following example, the elements of the `employees` set that are
/// not also members of the `neighbors` set are removed. In particular, the
/// names `"Alicia"`, `"Chris"`, and `"Diana"` are removed.
///
///     var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
///     employees.formIntersection(neighbors)
///     print(employees)
///     // Prints "["Bethany", "Eric"]"
///
/// - Parameter other: A set of the same type as the current set.
public mutating func formIntersection(_ other: TableColumnCustomizationBehavior)
/// Removes the elements of the set that are also in the given set and adds
/// the members of the given set that are not already in the set.
///
/// In the following example, the elements of the `employees` set that are
/// also members of `neighbors` are removed from `employees`, while the
/// elements of `neighbors` that are not members of `employees` are added to
/// `employees`. In particular, the names `"Bethany"` and `"Eric"` are
/// removed from `employees` while the name `"Forlani"` is added.
///
///     var employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
///     let neighbors: Set = ["Bethany", "Eric", "Forlani"]
///     employees.formSymmetricDifference(neighbors)
///     print(employees)
///     // Prints "["Diana", "Forlani", "Alicia"]"
///
/// - Parameter other: A set of the same type.
public mutating func formSymmetricDifference(_ other: TableColumnCustomizationBehavior)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TableColumnCustomizationBehavior, b: TableColumnCustomizationBehavior) -> Bool
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = TableColumnCustomizationBehavior.Element
}
/// A type of table row content that creates table rows created by iterating
/// over a collection.
///
/// You don't use this type directly. The various `Table.init(_:,...)`
/// initializers create this type as the table's `Rows` generic type.
///
/// To explicitly create dynamic collection-based rows, use ``ForEach`` instead.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableForEachContent<Data> : TableRowContent where Data : RandomAccessCollection, Data.Element : Identifiable {
/// The type of value represented by this table row content.
public typealias TableRowValue = Data.Element
/// The composition of content that comprise the table row content.
public var tableRowBody: some TableRowContent { get }
/// The type of content representing the body of this table row content.
public typealias TableRowBody = some TableRowContent
}
/// A table row that displays a single view instead of columned content.
///
/// You do not create this type directly. The framework creates it on your
/// behalf.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableHeaderRowContent<Value, Content> : TableRowContent where Value : Identifiable, Content : View {
/// The type of value represented by this table row content.
public typealias TableRowValue = Value
/// The composition of content that comprise the table row content.
public var tableRowBody: some TableRowContent { get }
/// The type of content representing the body of this table row content.
public typealias TableRowBody = some TableRowContent
}
/// An opaque table row type created by a table's hierarchical initializers.
///
/// This row content is created by `Table.init(_:,children:,...)` initializers
/// as the table's `Rows` generic type.
///
/// To explicitly create hierarchical rows, use ``OutlineGroup`` instead.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableOutlineGroupContent<Data> : TableRowContent where Data : RandomAccessCollection, Data.Element : Identifiable {
/// The type of value represented by this table row content.
public typealias TableRowValue = Data.Element
/// The composition of content that comprise the table row content.
public var tableRowBody: some TableRowContent { get }
/// The type of content representing the body of this table row content.
public typealias TableRowBody = some TableRowContent
}
/// A row that represents a data value in a table.
///
/// Create instances of ``TableRow`` in the closure you provide to the
/// `rows` parameter in ``Table`` initializers that take columns and rows.
/// The table provides the value of a row to each column of a table, which produces
/// the cells for each row in the column.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableRow<Value> : TableRowContent where Value : Identifiable {
/// The type of value represented by this table row content.
public typealias TableRowValue = Value
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// Creates a table row for the given value.
///
/// The table provides the value of a row to each column of a table,
/// which produces the cells for each row in the column.
///
/// The following example creates a row for one instance of the `Person`
/// type. The table delivers this value to its columns, which
/// displays different fields of `Person`.
///
///      TableRow(Person(givenName: "Tom", familyName: "Clark"))
///
/// - Parameter value: The value of the row.
public init(_ value: Value)
}
/// A result builder that creates table row content from closures.
///
/// The `buildBlock` methods in this type create ``TableRowContent``
/// instances based on the number and types of sources provided as parameters.
///
/// Don't use this type directly; instead, SwiftUI annotates the `rows`
/// parameter of the various ``Table`` initializers with the
/// `@TableRowBuilder` annotation, implicitly calling this builder for you.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@resultBuilder public struct TableRowBuilder<Value> where Value : Identifiable {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Value == Content.TableRowValue, Content : TableRowContent
/// Creates a single row result.
public static func buildBlock<C>(_ content: C) -> C where Value == C.TableRowValue, C : TableRowContent
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result for conditional statements.
///
/// This method provides support for "if" statements in multi-statement
/// closures, producing an optional value that is visible only when the
/// condition evaluates to `true`.
public static func buildIf<C>(_ content: C?) -> C? where Value == C.TableRowValue, C : TableRowContent
/// Creates a row result for the first of two row content alternatives.
///
/// This method provides support for "if" statements in multi-statement
/// closures, producing conditional content for the "then" branch.
public static func buildEither<T, F>(first: T) -> _ConditionalContent<T, F> where Value == T.TableRowValue, T : TableRowContent, F : TableRowContent, T.TableRowValue == F.TableRowValue
/// Creates a row result for the second of two row content alternatives.
///
/// This method provides support for "if" statements in multi-statement
/// closures, producing conditional content for the "else" branch.
public static func buildEither<T, F>(second: F) -> _ConditionalContent<T, F> where Value == T.TableRowValue, T : TableRowContent, F : TableRowContent, T.TableRowValue == F.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from two sources.
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleTableRowContent<Value, (C0, C1)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C0.TableRowValue == C1.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from three sources.
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> TupleTableRowContent<Value, (C0, C1, C2)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from four sources.
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> TupleTableRowContent<Value, (C0, C1, C2, C3)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from five sources.
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from six sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4, C5)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C5 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from seven sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4, C5, C6)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C5 : TableRowContent, C6 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from eight sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4, C5, C6, C7)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C5 : TableRowContent, C6 : TableRowContent, C7 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from nine sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4, C5, C6, C7, C8)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C5 : TableRowContent, C6 : TableRowContent, C7 : TableRowContent, C8 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue, C7.TableRowValue == C8.TableRowValue
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowBuilder {
/// Creates a row result from ten sources.
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> TupleTableRowContent<Value, (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)> where Value == C0.TableRowValue, C0 : TableRowContent, C1 : TableRowContent, C2 : TableRowContent, C3 : TableRowContent, C4 : TableRowContent, C5 : TableRowContent, C6 : TableRowContent, C7 : TableRowContent, C8 : TableRowContent, C9 : TableRowContent, C0.TableRowValue == C1.TableRowValue, C1.TableRowValue == C2.TableRowValue, C2.TableRowValue == C3.TableRowValue, C3.TableRowValue == C4.TableRowValue, C4.TableRowValue == C5.TableRowValue, C5.TableRowValue == C6.TableRowValue, C6.TableRowValue == C7.TableRowValue, C7.TableRowValue == C8.TableRowValue, C8.TableRowValue == C9.TableRowValue
}
/// A type used to represent table rows.
///
/// Like with the ``View`` protocol, you can create custom table row content
/// by declaring a type that conforms to the `TableRowContent` protocol and implementing
/// the required ``TableRowContent/tableRowBody-swift.property`` property.
///
///     struct GroupOfPeopleRows: TableRowContent {
///         @Binding var people: [Person]
///
///         var tableRowBody: some TableRowContent<Person> {
///             ForEach(people) { person in
///                 TableRow(person)
///                     .itemProvider { person.itemProvider }
///             }
///             .dropDestination(for: Person.self) { destination, newPeople in
///                 people.insert(contentsOf: newPeople, at: destination)
///             }
///         }
///     }
///
/// This example uses an opaque result type and specifies that the
/// primary associated type `TableRowValue` for the `tableRowBody`
/// property is a `Person`. From this, SwiftUI can infer
/// `TableRowValue` for the `GroupOfPeopleRows` structure is also `Person`.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol TableRowContent<TableRowValue> {
/// The type of value represented by this table row content.
associatedtype TableRowValue : Identifiable = Self.TableRowBody.TableRowValue
/// The type of content representing the body of this table row content.
associatedtype TableRowBody : TableRowContent
/// The composition of content that comprise the table row content.
var tableRowBody: Self.TableRowBody { get }
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowContent {
/// Activates this row as the source of a drag and drop operation.
///
/// Applying the `draggable(_:)` modifier adds the appropriate gestures for
/// drag and drop to this row.
///
/// - Parameter payload: A closure that returns a single
/// instance or a value conforming to <doc://com.apple.documentation/documentation/coretransferable/transferable> that
/// represents the draggable data from this view.
///
/// - Returns: A row that activates this row as the source of a drag and
///   drop operation.
public func draggable<T>(_ payload: @autoclosure @escaping () -> T) -> some TableRowContent<Self.TableRowValue> where T : Transferable
/// Defines the entire row as a destination of a drag and drop operation
/// that handles the dropped content with a closure that you specify.
///
/// - Parameters:
///   - payloadType: The expected type of the dropped models.
///   - action: A closure that takes the dropped content and responds
///     with `true` if the drop operation was successful; otherwise, return
///     `false`.
///
/// - Returns: A row that provides a drop destination for a drag
///   operation of the specified type.
public func dropDestination<T>(for payloadType: T.Type = T.self, action: @escaping (_ items: [T]) -> Void) -> some TableRowContent<Self.TableRowValue> where T : Transferable
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowContent {
/// Provides a closure that vends the drag representation for a
/// particular data element.
public func itemProvider(_ action: (() -> NSItemProvider?)?) -> ModifiedContent<Self, ItemProviderTableRowModifier>
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableRowContent {
/// Adds a context menu to a table row.
///
/// Use this modifier to add a context menu to a table row. Compose
/// the menu by returning controls like ``Button``, ``Toggle``, and
/// ``Picker`` from the `menuItems` closure. You can also use ``Menu``
/// to define submenus, or ``Section`` to group items.
///
/// The following example adds a context menu to each row in a table
/// that people can use to send an email to the person represented by
/// that row:
///
///     Table(of: Person.self) {
///         TableColumn("Given Name", value: \.givenName)
///         TableColumn("Family Name", value: \.familyName)
///     } rows: {
///         ForEach(people) { person in
///             TableRow(person)
///                 .contextMenu {
///                     Button("Send Email...") { }
///                 }
///         }
///     }
///
/// If you want to display a preview beside the context menu, use
/// ``TableRowContent/contextMenu(menuItems:preview:)``. If you want
/// to display a context menu that's based on the current selection,
/// use ``View/contextMenu(forSelectionType:menu:primaryAction:)``. To add
/// context menus to other kinds of views, use ``View/contextMenu(menuItems:)``.
///
/// - Parameter menuItems: A closure that produces the menu's contents. You
///   can deactivate the context menu by returning nothing from the closure.
///
/// - Returns: A row that can display a context menu.
public func contextMenu<M>(@ViewBuilder menuItems: () -> M) -> ModifiedContent<Self, _ContextMenuTableRowModifier<M>> where M : View
/// Adds a context menu with a preview to a table row.
///
/// When you use this modifier to add a context menu to rows in a
/// table, the system shows a preview beside the menu.
/// Compose the menu by returning controls like ``Button``, ``Toggle``, and
/// ``Picker`` from the `menuItems` closure. You can also use ``Menu`` to
/// define submenus.
///
/// Define the preview by returning a view from the `preview` closure. The
/// system sizes the preview to match the size of its content. For example,
/// the following code adds a context menu with a preview to each row in a
/// table that people can use to send an email to the person represented by
/// that row:
///
///     Table(of: Person.self) {
///         TableColumn("Given Name", value: \.givenName)
///         TableColumn("Family Name", value: \.familyName)
///     } rows: {
///         ForEach(people) { person in
///             TableRow(person)
///                 .contextMenu {
///                     Button("Send Email...") { }
///                 } preview: {
///                     Image("envelope") // Loads the image from an asset catalog.
///                 }
///         }
///     }
///
/// > Note: This view modifier produces a context menu on macOS, but that
/// platform doesn't display the preview.
///
/// If you don't need a preview, use
/// ``TableRowContent/contextMenu(menuItems:)``. If you want
/// to display a context menu that's based on the current selection,
/// use ``View/contextMenu(forSelectionType:menu:primaryAction:)``. To add
/// context menus to other kinds of views, see ``View/contextMenu(menuItems:)``.
///
/// - Parameters:
///   - menuItems: A closure that produces the menu's contents. You can
///     deactivate the context menu by returning nothing from the closure.
///   - preview: A view that the system displays along with the menu.
///
/// - Returns: A row that can display a context menu with a preview.
public func contextMenu<M, P>(@ViewBuilder menuItems: () -> M, @ViewBuilder preview: () -> P) -> ModifiedContent<Self, _ContextMenuPreviewTableRowModifier<M, P>> where M : View, P : View
}
/// A type that applies a custom appearance to all tables within a view.
///
/// To configure the current table style for a view hierarchy, use the
/// ``View/tableStyle(_:)`` modifier.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol TableStyle {
/// A view that represents the body of a table.
associatedtype Body : View
/// Creates a view that represents the body of a table.
///
/// The system calls this method for each ``Table`` instance in a view
/// hierarchy where this style is the current table style.
///
/// - Parameter configuration: The properties of the table.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a table.
typealias Configuration = TableStyleConfiguration
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableStyle where Self == InsetTableStyle {
/// The table style that describes the behavior and appearance of a table
/// with its content and selection inset from the table edges.
///
/// To customize whether the rows of the table should alternate their
/// backgrounds, use ``View/alternatingRowBackgrounds(_:)``.
public static var inset: InsetTableStyle { get }
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TableStyle where Self == AutomaticTableStyle {
/// The default table style in the current context.
public static var automatic: AutomaticTableStyle { get }
}
/// The properties of a table.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TableStyleConfiguration {
}
/// A gesture that recognizes one or more taps.
///
/// To recognize a tap gesture on a view, create and configure the gesture, and
/// then add it to the view using the ``View/gesture(_:including:)`` modifier.
/// The following code adds a tap gesture to a ``Circle`` that toggles the color
/// of the circle:
///
///     struct TapGestureView: View {
///         @State private var tapped = false
///
///         var tap: some Gesture {
///             TapGesture(count: 1)
///                 .onEnded { _ in self.tapped = !self.tapped }
///         }
///
///         var body: some View {
///             Circle()
///                 .fill(self.tapped ? Color.blue : Color.red)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .gesture(tap)
///         }
///     }
@available(iOS 13.0, macOS 10.15, tvOS 16.0, watchOS 6.0, *)
public struct TapGesture : Gesture {
/// The required number of tap events.
public var count: Int
/// Creates a tap gesture with the number of required taps.
///
/// - Parameter count: The required number of taps to complete the tap
///   gesture.
public init(count: Int = 1)
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
/// The type representing the gesture's value.
public typealias Value = Void
}
/// A view that displays one or more lines of read-only text.
///
/// A text view draws a string in your app's user interface using a
/// ``Font/body`` font that's appropriate for the current platform. You can
/// choose a different standard font, like ``Font/title`` or ``Font/caption``,
/// using the ``View/font(_:)`` view modifier.
///
///     Text("Hamlet")
///         .font(.title)
///
/// ![A text view showing the name "Hamlet" in a title
/// font.](SwiftUI-Text-title.png)
///
/// If you need finer control over the styling of the text, you can use the same
/// modifier to configure a system font or choose a custom font. You can also
/// apply view modifiers like ``Text/bold()`` or ``Text/italic()`` to further
/// adjust the formatting.
///
///     Text("by William Shakespeare")
///         .font(.system(size: 12, weight: .light, design: .serif))
///         .italic()
///
/// ![A text view showing by William Shakespeare in a 12 point, light, italic,
/// serif font.](SwiftUI-Text-font.png)
///
/// To apply styling within specific portions of the text, you can create
/// the text view from an
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString>,
/// which in turn allows you to use Markdown to style runs of text. You can
/// mix string attributes and SwiftUI modifiers, with the string attributes
/// taking priority.
///
///     let attributedString = try! AttributedString(
///         markdown: "_Hamlet_ by William Shakespeare")
///
///     var body: some View {
///         Text(attributedString)
///             .font(.system(size: 12, weight: .light, design: .serif))
///     }
///
/// ![A text view showing Hamlet by William Shakespeare in a 12 point, light,
/// serif font, with the title Hamlet in italics.](SwiftUI-Text-attributed.png)
///
/// A text view always uses exactly the amount of space it needs to display its
/// rendered contents, but you can affect the view's layout. For example, you
/// can use the ``View/frame(width:height:alignment:)`` modifier to propose
/// specific dimensions to the view. If the view accepts the proposal but the
/// text doesn't fit into the available space, the view uses a combination of
/// wrapping, tightening, scaling, and truncation to make it fit. With a width
/// of `100` points but no constraint on the height, a text view might wrap a
/// long string:
///
///     Text("To be, or not to be, that is the question:")
///         .frame(width: 100)
///
/// ![A text view showing a quote from Hamlet split over three
/// lines.](SwiftUI-Text-split.png)
///
/// Use modifiers like ``View/lineLimit(_:)-513mb``, ``View/allowsTightening(_:)``,
/// ``View/minimumScaleFactor(_:)``, and ``View/truncationMode(_:)`` to
/// configure how the view handles space constraints. For example, combining a
/// fixed width and a line limit of `1` results in truncation for text that
/// doesn't fit in that space:
///
///     Text("Brevity is the soul of wit.")
///         .frame(width: 100)
///         .lineLimit(1)
///
/// ![A text view showing a truncated quote from Hamlet starting Brevity is t
/// and ending with three dots.](SwiftUI-Text-truncated.png)
///
/// ### Localizing strings
///
/// If you initialize a text view with a string literal, the view uses the
/// ``Text/init(_:tableName:bundle:comment:)`` initializer, which interprets the
/// string as a localization key and searches for the key in the table you
/// specify, or in the default table if you don't specify one.
///
///     Text("pencil") // Searches the default table in the main bundle.
///
/// For an app localized in both English and Spanish, the above view displays
/// "pencil" and "lápiz" for English and Spanish users, respectively. If the
/// view can't perform localization, it displays the key instead. For example,
/// if the same app lacks Danish localization, the view displays "pencil" for
/// users in that locale. Similarly, an app that lacks any localization
/// information displays "pencil" in any locale.
///
/// To explicitly bypass localization for a string literal, use the
/// ``Text/init(verbatim:)`` initializer.
///
///     Text(verbatim: "pencil") // Displays the string "pencil" in any locale.
///
/// If you intialize a text view with a variable value, the view uses the
/// ``Text/init(_:)-9d1g4`` initializer, which doesn't localize the string. However,
/// you can request localization by creating a ``LocalizedStringKey`` instance
/// first, which triggers the ``Text/init(_:tableName:bundle:comment:)``
/// initializer instead:
///
///     // Don't localize a string variable...
///     Text(writingImplement)
///
///     // ...unless you explicitly convert it to a localized string key.
///     Text(LocalizedStringKey(writingImplement))
///
/// When localizing a string variable, you can use the default table by omitting
/// the optional initialization parameters — as in the above example — just like
/// you might for a string literal.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Text : Equatable, Sendable {
/// Creates a text view that displays a string literal without localization.
///
/// Use this initializer to create a text view with a string literal without
/// performing localization:
///
///     Text(verbatim: "pencil") // Displays the string "pencil" in any locale.
///
/// If you want to localize a string literal before displaying it, use the
/// ``Text/init(_:tableName:bundle:comment:)`` initializer instead. If you
/// want to display a string variable, use the ``Text/init(_:)-9d1g4``
/// initializer, which also bypasses localization.
///
/// - Parameter content: A string to display without localization.
@inlinable public init(verbatim content: String)
/// Creates a text view that displays a stored string without localization.
///
/// Use this initializer to create a text view that displays — without
/// localization — the text in a string variable.
///
///     Text(someString) // Displays the contents of `someString` without localization.
///
/// SwiftUI doesn't call the `init(_:)` method when you initialize a text
/// view with a string literal as the input. Instead, a string literal
/// triggers the ``Text/init(_:tableName:bundle:comment:)`` method — which
/// treats the input as a ``LocalizedStringKey`` instance — and attempts to
/// perform localization.
///
/// By default, SwiftUI assumes that you don't want to localize stored
/// strings, but if you do, you can first create a localized string key from
/// the value, and initialize the text view with that. Using a key as input
/// triggers the ``Text/init(_:tableName:bundle:comment:)`` method instead.
///
/// - Parameter content: The string value to display without localization.
public init<S>(_ content: S) where S : StringProtocol
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text, b: Text) -> Bool
}
extension Text {
/// Specifies the language for typesetting.
///
/// In some cases `Text` may contain text of a particular language which
/// doesn't match the device UI language. In that case it's useful to
/// specify a language so line height, line breaking and spacing will
/// respect the script used for that language. For example:
///
///     Text(verbatim: "แอปเปิล")
///         .typesettingLanguage(.init(languageCode: .thai))
///
/// Note: this language does not affect text localization.
///
/// - Parameters:
///   - language: The explicit language to use for typesetting.
///   - isEnabled: A Boolean value that indicates whether text langauge is
///     added
/// - Returns: Text with the typesetting language set to the value you
///   supply.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func typesettingLanguage(_ language: Locale.Language, isEnabled: Bool = true) -> Text
/// Specifies the language for typesetting.
///
/// In some cases `Text` may contain text of a particular language which
/// doesn't match the device UI language. In that case it's useful to
/// specify a language so line height, line breaking and spacing will
/// respect the script used for that language. For example:
///
///     Text(verbatim: "แอปเปิล").typesettingLanguage(
///         .explicit(.init(languageCode: .thai)))
///
/// Note: this language does not affect text localized localization.
///
/// - Parameters:
///   - language: The language to use for typesetting.
///   - isEnabled: A Boolean value that indicates whether text language is
///     added
/// - Returns: Text with the typesetting language set to the value you
///   supply.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func typesettingLanguage(_ language: TypesettingLanguage, isEnabled: Bool = true) -> Text
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Text {
/// Creates a text view that displays styled attributed content.
///
/// Use this initializer to style text according to attributes found in the specified
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString>.
/// Attributes in the attributed string take precedence over styles added by
/// view modifiers. For example, the attributed text in the following
/// example appears in blue, despite the use of the ``View/foregroundColor(_:)``
/// modifier to use red throughout the enclosing ``VStack``:
///
///     var content: AttributedString {
///         var attributedString = AttributedString("Blue text")
///         attributedString.foregroundColor = .blue
///         return attributedString
///     }
///
///     var body: some View {
///         VStack {
///             Text(content)
///             Text("Red text")
///         }
///         .foregroundColor(.red)
///     }
///
/// ![A vertical stack of two text views, the top labeled Blue Text with a
/// blue font color, and the bottom labeled Red Text with a red font
/// color.](SwiftUI-Text-init-attributed.png)
///
/// SwiftUI combines text attributes with SwiftUI modifiers whenever
/// possible. For example, the following listing creates text that is
/// both bold and red:
///
///     var content: AttributedString {
///         var content = AttributedString("Some text")
///         content.inlinePresentationIntent = .stronglyEmphasized
///         return content
///     }
///
///     var body: some View {
///         Text(content).foregroundColor(Color.red)
///     }
///
/// A SwiftUI ``Text`` view renders most of the styles defined by the
/// Foundation attribute
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/FoundationAttributes/3796123-inlinePresentationIntent>, like the
/// <doc://com.apple.documentation/documentation/Foundation/InlinePresentationIntent/3746899-stronglyEmphasized>
/// value, which SwiftUI presents as bold text.
///
/// > Important: ``Text`` uses only a subset of the attributes defined in
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/FoundationAttributes>.
/// `Text` renders all
/// <doc://com.apple.documentation/documentation/Foundation/InlinePresentationIntent>
/// attributes except for
/// <doc://com.apple.documentation/documentation/Foundation/InlinePresentationIntent/3787563-lineBreak> and
/// <doc://com.apple.documentation/documentation/Foundation/InlinePresentationIntent/3787564-softBreak>.
/// It also renders the
/// <doc://com.apple.documentation/Foundation/AttributeScopes/FoundationAttributes/3764633-link>
/// attribute as a clickable link. `Text` ignores any other
/// Foundation-defined attributes in an attributed string.
///
/// SwiftUI also defines additional attributes in the attribute scope
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/SwiftUIAttributes>
/// which you can access from an attributed string's
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/3788543-swiftUI>
/// property. SwiftUI attributes take precedence over equivalent attributes
/// from other frameworks, such as
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/UIKitAttributes> and
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/AppKitAttributes>.
///
///
/// You can create an `AttributedString` with Markdown syntax, which allows
/// you to style distinct runs within a `Text` view:
///
///     let content = try! AttributedString(
///         markdown: "**Thank You!** Please visit our [website](http://example.com).")
///
///     var body: some View {
///         Text(content)
///     }
///
/// The `**` syntax around "Thank You!" applies an
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/FoundationAttributes/3796123-inlinePresentationIntent>
/// attribute with the value
/// <doc://com.apple.documentation/documentation/Foundation/InlinePresentationIntent/3746899-stronglyEmphasized>.
/// SwiftUI renders this as
/// bold text, as described earlier. The link syntax around "website"
/// creates a
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/FoundationAttributes/3764633-link>
/// attribute, which `Text` styles to indicate it's a link; by default,
/// clicking or tapping the link opens the linked URL in the user's default
/// browser. Alternatively, you can perform custom link handling by putting
/// an ``OpenURLAction`` in the text view's environment.
///
/// ![A text view that says Thank you. Please visit our website. The text
/// The view displays the words Thank you in a bold font, and the word
/// website styled to indicate it is a
/// link.](SwiftUI-Text-init-markdown.png)
///
/// You can also use Markdown syntax in localized string keys, which means
/// you can write the above example without needing to explicitly create
/// an `AttributedString`:
///
///     var body: some View {
///         Text("**Thank You!** Please visit our [website](https://example.com).")
///     }
///
/// In your app's strings files, use Markdown syntax to apply styling
/// to the app's localized strings. You also use this approach when you want
/// to perform automatic grammar agreement on localized strings, with
/// the `^[text](inflect:true)` syntax.
///
/// For details about Markdown syntax support in SwiftUI, see
/// ``Text/init(_:tableName:bundle:comment:)``.
///
/// - Parameters:
///   - attributedContent: An attributed string to style and display,
///   in accordance with its attributes.
public init(_ attributedContent: AttributedString)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Text {
/// Sets an accessibility text content type.
///
/// Use this modifier to set the content type of this accessibility
/// element. Assistive technologies can use this property to choose
/// an appropriate way to output the text. For example, when
/// encountering a source coding context, VoiceOver could
/// choose to speak all punctuation.
///
/// If you don't set a value with this method, the default content type
/// is ``AccessibilityTextContentType/plain``.
///
/// - Parameter value: The accessibility content type from the available
/// ``AccessibilityTextContentType`` options.
public func accessibilityTextContentType(_ value: AccessibilityTextContentType) -> Text
/// Sets the accessibility level of this heading.
///
/// Use this modifier to set the level of this heading in relation to other headings. The system speaks
/// the level number of levels ``AccessibilityHeadingLevel/h1`` through
/// ``AccessibilityHeadingLevel/h6`` alongside the text.
///
/// The default heading level if you don't use this modifier
/// is ``AccessibilityHeadingLevel/unspecified``.
///
/// - Parameter level: The heading level to associate with this element
///   from the available ``AccessibilityHeadingLevel`` levels.
public func accessibilityHeading(_ level: AccessibilityHeadingLevel) -> Text
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an alternative accessibility label
/// to the text that is displayed. For example, you can give an alternate label to a navigation title:
///
///     var body: some View {
///         NavigationView {
///             ContentView()
///                 .navigationTitle(Text("􀈤").accessibilityLabel("Inbox"))
///         }
///     }
///
/// You can't style the label that you add
///
/// - Parameter label: The text view to add the label to.
public func accessibilityLabel(_ label: Text) -> Text
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an alternative accessibility label to the text that is displayed.
/// For example, you can give an alternate label to a navigation title:
///
///     var body: some View {
///         NavigationView {
///             ContentView()
///                 .navigationTitle(Text("􀈤").accessibilityLabel("Inbox"))
///         }
///     }
///
/// - Parameter labelKey: The string key for the alternative
///   accessibility label.
public func accessibilityLabel(_ labelKey: LocalizedStringKey) -> Text
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an alternative accessibility label to the text that is displayed.
/// For example, you can give an alternate label to a navigation title:
///
///     var body: some View {
///         NavigationView {
///             ContentView()
///                 .navigationTitle(Text("􀈤").accessibilityLabel("Inbox"))
///         }
///     }
///
/// - Parameter label: The string for the alternative accessibility label.
public func accessibilityLabel<S>(_ label: S) -> Text where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text {
/// The type of truncation to apply to a line of text when it's too long to
/// fit in the available space.
///
/// When a text view contains more text than it's able to display, the view
/// might truncate the text and place an ellipsis (...) at the truncation
/// point. Use the ``View/truncationMode(_:)`` modifier with one of the
/// `TruncationMode` values to indicate which part of the text to
/// truncate, either at the beginning, in the middle, or at the end.
public enum TruncationMode : Sendable {
/// Truncate at the beginning of the line.
///
/// Use this kind of truncation to omit characters from the beginning of
/// the string. For example, you could truncate the English alphabet as
/// "...wxyz".
case head
/// Truncate at the end of the line.
///
/// Use this kind of truncation to omit characters from the end of the
/// string. For example, you could truncate the English alphabet as
/// "abcd...".
case tail
/// Truncate in the middle of the line.
///
/// Use this kind of truncation to omit characters from the middle of
/// the string. For example, you could truncate the English alphabet as
/// "ab...yz".
case middle
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text.TruncationMode, b: Text.TruncationMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// A scheme for transforming the capitalization of characters within text.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public enum Case : Sendable {
/// Displays text in all uppercase characters.
///
/// For example, "Hello" would be displayed as "HELLO".
///
/// - SeeAlso: `StringProtocol.uppercased(with:)`
case uppercase
/// Displays text in all lowercase characters.
///
/// For example, "Hello" would be displayed as "hello".
///
/// - SeeAlso: `StringProtocol.lowercased(with:)`
case lowercase
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text.Case, b: Text.Case) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Text {
/// Sets whether VoiceOver should always speak all punctuation in the text
/// view.
///
/// Use this modifier to control whether the system speaks punctuation
/// characters in the text. You might use this for code or other text where
/// the punctuation is relevant, or where you want VoiceOver to speak a
/// verbatim transcription of the text you provide. For example, given the
/// text:
///
///     Text("All the world's a stage, " +
///          "And all the men and women merely players;")
///          .speechAlwaysIncludesPunctuation()
///
/// VoiceOver would speak "All the world apostrophe s a stage comma and all
/// the men and women merely players semicolon".
///
/// By default, VoiceOver voices punctuation based on surrounding context.
///
/// - Parameter value: A Boolean value that you set to `true` if
///   VoiceOver should speak all punctuation in the text. Defaults to `true`.
public func speechAlwaysIncludesPunctuation(_ value: Bool = true) -> Text
/// Sets whether VoiceOver should speak the contents of the text view
/// character by character.
///
/// Use this modifier when you want VoiceOver to speak text as individual
/// letters, character by character. This is important for text that is not
/// meant to be spoken together, like:
/// - An acronym that isn't a word, like APPL, spoken as "A-P-P-L".
/// - A number representing a series of digits, like 25, spoken as "two-five"
///   rather than "twenty-five".
///
/// - Parameter value: A Boolean value that when `true` indicates
///    VoiceOver should speak text as individual characters. Defaults
///    to `true`.
public func speechSpellsOutCharacters(_ value: Bool = true) -> Text
/// Raises or lowers the pitch of spoken text.
///
/// Use this modifier when you want to change the pitch of spoken text.
/// The value indicates how much higher or lower to change the pitch.
///
/// - Parameter value: The amount to raise or lower the pitch.
///   Values between `-1` and `0` result in a lower pitch while
///   values between `0` and `1` result in a higher pitch.
///   The method clamps values to the range `-1` to `1`.
public func speechAdjustedPitch(_ value: Double) -> Text
/// Controls whether to queue pending announcements behind existing speech
/// rather than interrupting speech in progress.
///
/// Use this modifier when you want affect the order in which the
/// accessibility system delivers spoken text. Announcements can
/// occur automatically when the label or value of an accessibility
/// element changes.
///
/// - Parameter value: A Boolean value that determines if VoiceOver speaks
///   changes to text immediately or enqueues them behind existing speech.
///   Defaults to `true`.
public func speechAnnouncementsQueued(_ value: Bool = true) -> Text
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
extension Text {
/// Creates a text view that displays a localized string resource.
///
/// Use this initializer to display a localized string that is
/// represented by a <doc://com.apple.documentation/documentation/Foundation/LocalizedStringResource>
///
///     var object = LocalizedStringResource("pencil")
///     Text(object) // Localizes the resource if possible, or displays "pencil" if not.
///
@available(iOS 16.0, macOS 13, tvOS 16.0, watchOS 9.0, *)
public init(_ resource: LocalizedStringResource)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text {
/// Creates a text view that displays the formatted representation
/// of a reference-convertible value.
///
/// Use this initializer to create a text view that formats `subject`
/// using `formatter`.
/// - Parameters:
///   - subject: A
///   <doc://com.apple.documentation/documentation/Foundation/ReferenceConvertible>
///   instance compatible with `formatter`.
///   - formatter: A
///   <doc://com.apple.documentation/documentation/Foundation/Formatter>
///   capable of converting `subject` into a string representation.
public init<Subject>(_ subject: Subject, formatter: Formatter) where Subject : ReferenceConvertible
/// Creates a text view that displays the formatted representation
/// of a Foundation object.
///
/// Use this initializer to create a text view that formats `subject`
/// using `formatter`.
/// - Parameters:
///   - subject: An
///   <doc://com.apple.documentation/documentation/ObjectiveC/NSObject>
///   instance compatible with `formatter`.
///   - formatter: A
///   <doc://com.apple.documentation/documentation/Foundation/Formatter>
///   capable of converting `subject` into a string representation.
public init<Subject>(_ subject: Subject, formatter: Formatter) where Subject : NSObject
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Text {
/// Creates a text view that displays the formatted representation
/// of a nonstring type supported by a corresponding format style.
///
/// Use this initializer to create a text view backed by a nonstring
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/FormatStyle>
/// to convert the type to a string representation. Any changes to the value
/// update the string displayed by the text view.
///
/// In the following example, three ``Text`` views present a date with
/// different combinations of date and time fields, by using different
/// <doc://com.apple.documentation/documentation/Foundation/Date/FormatStyle>
/// options.
///
///     @State private var myDate = Date()
///     var body: some View {
///         VStack {
///             Text(myDate, format: Date.FormatStyle(date: .numeric, time: .omitted))
///             Text(myDate, format: Date.FormatStyle(date: .complete, time: .complete))
///             Text(myDate, format: Date.FormatStyle().hour(.defaultDigitsNoAMPM).minute())
///         }
///     }
///
/// ![Three vertically stacked text views showing the date with different
/// levels of detail: 4/1/1976; April 1, 1976; Thursday, April 1,
/// 1976.](Text-init-format-1)
///
/// - Parameters:
///   - input: The underlying value to display.
///   - format: A format style of type `F` to convert the underlying value
///     of type `F.FormatInput` to a string representation.
public init<F>(_ input: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String
}
extension Text {
/// Creates an instance that wraps an `Image`, suitable for concatenating
/// with other `Text`
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public init(_ image: Image)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text {
/// Creates a text view that displays localized content identified by a key.
///
/// Use this initializer to look for the `key` parameter in a localization
/// table and display the associated string value in the initialized text
/// view. If the initializer can't find the key in the table, or if no table
/// exists, the text view displays the string representation of the key
/// instead.
///
///     Text("pencil") // Localizes the key if possible, or displays "pencil" if not.
///
/// When you initialize a text view with a string literal, the view triggers
/// this initializer because it assumes you want the string localized, even
/// when you don't explicitly specify a table, as in the above example. If
/// you haven't provided localization for a particular string, you still get
/// reasonable behavior, because the initializer displays the key, which
/// typically contains the unlocalized string.
///
/// If you initialize a text view with a string variable rather than a
/// string literal, the view triggers the ``Text/init(_:)-9d1g4``
/// initializer instead, because it assumes that you don't want localization
/// in that case. If you do want to localize the value stored in a string
/// variable, you can choose to call the `init(_:tableName:bundle:comment:)`
/// initializer by first creating a ``LocalizedStringKey`` instance from the
/// string variable:
///
///     Text(LocalizedStringKey(someString)) // Localizes the contents of `someString`.
///
/// If you have a string literal that you don't want to localize, use the
/// ``Text/init(verbatim:)`` initializer instead.
///
/// ### Styling localized strings with markdown
///
/// If the localized string or the fallback key contains Markdown, the
/// view displays the text with appropriate styling. For example, consider
/// an app with the following entry in its Spanish localization file:
///
///     "_Please visit our [website](https://www.example.com)._" = "_Visita nuestro [sitio web](https://www.example.com)._";
///
/// You can create a `Text` view with the Markdown-formatted base language
/// version of the string as the localization key, like this:
///
///     Text("_Please visit our [website](https://www.example.com)._")
///
/// When viewed in a Spanish locale, the view uses the Spanish text from the
/// strings file, applying the Markdown styling.
///
/// ![A text view that says Visita nuestro sitio web, with all text
/// displayed in italics. The words sitio web are colored blue to indicate
/// they are a link.](SwiftUI-Text-init-localized.png)
///
/// > Important: `Text` doesn't render all styling possible in Markdown. It
/// doesn't support line breaks, soft breaks, or any style of paragraph- or
/// block-based formatting like lists, block quotes, code blocks, or tables.
/// It also doesn't support the
/// <doc://com.apple.documentation/documentation/Foundation/AttributeScopes/FoundationAttributes/3796122-imageURL>
/// attribute. Parsing with SwiftUI treats any whitespace in the Markdown
/// string as described by the
/// <doc://com.apple.documentation/documentation/Foundation/AttributedString/MarkdownParsingOptions/InterpretedSyntax/inlineOnlyPreservingWhitespace>
/// parsing option.
///
/// - Parameters:
///   - key: The key for a string in the table identified by `tableName`.
///   - tableName: The name of the string table to search. If `nil`, use the
///     table in the `Localizable.strings` file.
///   - bundle: The bundle containing the strings file. If `nil`, use the
///     main bundle.
///   - comment: Contextual information about this key-value pair.
public init(_ key: LocalizedStringKey, tableName: String? = nil, bundle: Bundle? = nil, comment: StaticString? = nil)
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Text {
/// Description of the style used to draw the line for `StrikethroughStyleAttribute`
/// and `UnderlineStyleAttribute`.
///
/// Use this type to specify `underlineStyle` and `strikethroughStyle`
/// SwiftUI attributes of an `AttributedString`.
public struct LineStyle : Hashable, Sendable {
/// Creates a line style.
///
/// - Parameters:
///   - pattern: The pattern of the line.
///   - color: The color of the line. If not provided, the foreground
///     color of text is used.
public init(pattern: Text.LineStyle.Pattern = .solid, color: Color? = nil)
/// The pattern, that the line has.
public struct Pattern : Sendable {
/// Draw a solid line.
public static let solid: Text.LineStyle.Pattern
/// Draw a line of dots.
public static let dot: Text.LineStyle.Pattern
/// Draw a line of dashes.
public static let dash: Text.LineStyle.Pattern
public static let dashDot: Text.LineStyle.Pattern
/// Draw a line of alternating dashes and two dots.
public static let dashDotDot: Text.LineStyle.Pattern
}
/// Draw a single solid line.
public static let single: Text.LineStyle
/// Creates a ``Text.LineStyle`` from ``NSUnderlineStyle``.
///
/// > Note: Use this initializer only if you need to convert an existing
/// ``NSUnderlineStyle`` to a SwiftUI ``Text.LineStyle``.
/// Otherwise, create a ``Text.LineStyle`` using an
/// initializer like ``init(pattern:color:)``.
///
/// - Parameter nsUnderlineStyle: A value of ``NSUnderlineStyle``
/// to wrap with ``Text.LineStyle``.
///
/// - Returns: A new ``Text.LineStyle`` or `nil` when
/// `nsUnderlineStyle` contains styles not supported by ``Text.LineStyle``.
public init?(nsUnderlineStyle: NSUnderlineStyle)
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text.LineStyle, b: Text.LineStyle) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text {
/// A predefined style used to display a `Date`.
public struct DateStyle : Sendable {
/// A style displaying only the time component for a date.
///
///     Text(event.startDate, style: .time)
///
/// Example output:
///     11:23PM
public static let time: Text.DateStyle
/// A style displaying a date.
///
///     Text(event.startDate, style: .date)
///
/// Example output:
///     June 3, 2019
public static let date: Text.DateStyle
/// A style displaying a date as relative to now.
///
///     Text(event.startDate, style: .relative)
///
/// Example output:
///     2 hours, 23 minutes
///     1 year, 1 month
public static let relative: Text.DateStyle
/// A style displaying a date as offset from now.
///
///     Text(event.startDate, style: .offset)
///
/// Example output:
///     +2 hours
///     -3 months
public static let offset: Text.DateStyle
/// A style displaying a date as timer counting from now.
///
///     Text(event.startDate, style: .timer)
///
/// Example output:
///    2:32
///    36:59:01
public static let timer: Text.DateStyle
}
/// Creates an instance that displays localized dates and times using a specific style.
///
/// - Parameters:
///     - date: The target date to display.
///     - style: The style used when displaying a date.
public init(_ date: Date, style: Text.DateStyle)
/// Creates an instance that displays a localized range between two dates.
///
/// - Parameters:
///     - dates: The range of dates to display
public init(_ dates: ClosedRange<Date>)
/// Creates an instance that displays a localized time interval.
///
///     Text(DateInterval(start: event.startDate, duration: event.duration))
///
/// Example output:
///     9:30AM - 3:30PM
///
/// - Parameters:
///     - interval: The date interval to display
public init(_ interval: DateInterval)
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Text {
/// Creates an instance that displays a timer counting within the provided
/// interval.
///
///     Text(
///         timerInterval: Date.now...Date(timeInterval: 12 * 60, since: .now))
///         pauseTime: Date.now + (10 * 60))
///
/// The example above shows a text that displays a timer counting down
/// from "12:00" and will pause when reaching "10:00".
///
/// - Parameters:
///     - timerInterval: The interval between where to run the timer.
///     - pauseTime: If present, the date at which to pause the timer.
///         The default is `nil` which indicates to never pause.
///     - countsDown: Whether to count up or down. The default is `true`.
///     - showsHours: Whether to include an hours component if there are
///         more than 60 minutes left on the timer. The default is `true`.
public init(timerInterval: ClosedRange<Date>, pauseTime: Date? = nil, countsDown: Bool = true, showsHours: Bool = true)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text {
/// Sets the color of the text displayed by this view.
///
/// Use this method to change the color of the text rendered by a text view.
///
/// For example, you can display the names of the colors red, green, and
/// blue in their respective colors:
///
///     HStack {
///         Text("Red").foregroundColor(.red)
///         Text("Green").foregroundColor(.green)
///         Text("Blue").foregroundColor(.blue)
///     }
///
/// ![Three text views arranged horizontally, each containing
///     the name of a color displayed in that
///     color.](SwiftUI-Text-foregroundColor.png)
///
/// - Parameter color: The color to use when displaying this text.
/// - Returns: A text view that uses the color value you supply.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
public func foregroundColor(_ color: Color?) -> Text
/// Sets the style of the text displayed by this view.
///
/// Use this method to change the rendering style of the text
/// rendered by a text view.
///
/// For example, you can display the names of the colors red,
/// green, and blue in their respective colors:
///
///     HStack {
///         Text("Red").foregroundStyle(.red)
///         Text("Green").foregroundStyle(.green)
///         Text("Blue").foregroundStyle(.blue)
///     }
///
/// ![Three text views arranged horizontally, each containing
///     the name of a color displayed in that
///     color.](SwiftUI-Text-foregroundColor.png)
///
/// - Parameter style: The style to use when displaying this text.
/// - Returns: A text view that uses the color value you supply.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func foregroundStyle<S>(_ style: S) -> Text where S : ShapeStyle
/// Sets the default font for text in the view.
///
/// Use `font(_:)` to apply a specific font to an individual
/// Text View, or all of the text views in a container.
///
/// In the example below, the first text field has a font set directly,
/// while the font applied to the following container applies to all of the
/// text views inside that container:
///
///     VStack {
///         Text("Font applied to a text view.")
///             .font(.largeTitle)
///
///         VStack {
///             Text("These two text views have the same font")
///             Text("applied to their parent view.")
///         }
///         .font(.system(size: 16, weight: .light, design: .default))
///     }
///
///
/// ![Applying a font to a single text view or a view container](SwiftUI-view-font.png)
///
/// - Parameter font: The font to use when displaying this text.
/// - Returns: Text that uses the font you specify.
public func font(_ font: Font?) -> Text
/// Sets the font weight of the text.
///
/// - Parameter weight: One of the available font weights.
///
/// - Returns: Text that uses the font weight you specify.
public func fontWeight(_ weight: Font.Weight?) -> Text
/// Sets the font width of the text.
///
/// - Parameter width: One of the available font widths.
///
/// - Returns: Text that uses the font width you specify, if available.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func fontWidth(_ width: Font.Width?) -> Text
/// Applies a bold font weight to the text.
///
/// - Returns: Bold text.
public func bold() -> Text
/// Applies a bold font weight to the text.
///
/// - Parameter isActive: A Boolean value that indicates
///   whether text has bold styling.
///
/// - Returns: Bold text.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func bold(_ isActive: Bool) -> Text
/// Applies italics to the text.
///
/// - Returns: Italic text.
public func italic() -> Text
/// Applies italics to the text.
///
/// - Parameter isActive: A Boolean value that indicates
///   whether italic styling is added.
///
/// - Returns: Italic text.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func italic(_ isActive: Bool) -> Text
/// Modifies the font of the text to use the fixed-width variant
/// of the current font, if possible.
///
/// - Parameter isActive: A Boolean value that indicates
///   whether monospaced styling is added. Default value is `true`.
///
/// - Returns: Monospaced text.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public func monospaced(_ isActive: Bool = true) -> Text
/// Sets the font design of the text.
///
/// - Parameter design: One of the available font designs.
///
/// - Returns: Text that uses the font design you specify.
@available(iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1, *)
public func fontDesign(_ design: Font.Design?) -> Text
/// Modifies the text view's font to use fixed-width digits, while leaving
/// other characters proportionally spaced.
///
/// This modifier only affects numeric characters, and leaves all other
/// characters unchanged.
///
/// The following example shows the effect of `monospacedDigit()` on a
/// text view. It arranges two text views in a ``VStack``, each displaying
/// a formatted date that contains many instances of the character 1.
/// The second text view uses the `monospacedDigit()`. Because 1 is
/// usually a narrow character in proportional fonts, applying the
/// modifier widens all of the 1s, and the text view as a whole.
/// The non-digit characters in the text view remain unaffected.
///
///     let myDate = DateComponents(
///         calendar: Calendar(identifier: .gregorian),
///         timeZone: TimeZone(identifier: "EST"),
///         year: 2011,
///         month: 1,
///         day: 11,
///         hour: 11,
///         minute: 11
///     ).date!
///
///     var body: some View {
///         VStack(alignment: .leading) {
///             Text(myDate.formatted(date: .long, time: .complete))
///                 .font(.system(size: 20))
///             Text(myDate.formatted(date: .long, time: .complete))
///                 .font(.system(size: 20))
///                 .monospacedDigit()
///         }
///         .padding()
///         .navigationTitle("monospacedDigit() Modifier")
///     }
///
/// ![Two vertically stacked text views, displaying the date January 11,
/// 2011, 11:11:00 AM. The second text view uses fixed-width digits, causing
/// all of the 1s to be wider than in the first text
/// view.](Text-monospacedDigit-1)
///
/// If the base font of the text view doesn't support fixed-width digits,
/// the font remains unchanged.
///
/// - Returns: A text view with a modified font that uses fixed-width
/// numeric characters, while leaving other characters proportionally
/// spaced.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func monospacedDigit() -> Text
/// Applies a strikethrough to the text.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether the text has a
///     strikethrough applied.
///   - color: The color of the strikethrough. If `color` is `nil`, the
///     strikethrough uses the default foreground color.
///
/// - Returns: Text with a line through its center.
public func strikethrough(_ isActive: Bool = true, color: Color? = nil) -> Text
/// Applies a strikethrough to the text.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether strikethrough
///     is added. The default value is `true`.
///   - pattern: The pattern of the line.
///   - color: The color of the strikethrough. If `color` is `nil`, the
///     strikethrough uses the default foreground color.
///
/// - Returns: Text with a line through its center.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func strikethrough(_ isActive: Bool = true, pattern: Text.LineStyle.Pattern, color: Color? = nil) -> Text
/// Applies an underline to the text.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether the text has an
///     underline.
///   - color: The color of the underline. If `color` is `nil`, the
///     underline uses the default foreground color.
///
/// - Returns: Text with a line running along its baseline.
public func underline(_ isActive: Bool = true, color: Color? = nil) -> Text
/// Applies an underline to the text.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether underline
///     styling is added. The default value is `true`.
///   - pattern: The pattern of the line.
///   - color: The color of the underline. If `color` is `nil`, the
///     underline uses the default foreground color.
///
/// - Returns: Text with a line running along its baseline.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func underline(_ isActive: Bool = true, pattern: Text.LineStyle.Pattern, color: Color? = nil) -> Text
/// Sets the spacing, or kerning, between characters.
///
/// Kerning defines the offset, in points, that a text view should shift
/// characters from the default spacing. Use positive kerning to widen the
/// spacing between characters. Use negative kerning to tighten the spacing
/// between characters.
///
///     VStack(alignment: .leading) {
///         Text("ABCDEF").kerning(-3)
///         Text("ABCDEF")
///         Text("ABCDEF").kerning(3)
///     }
///
/// The last character in the first case, which uses negative kerning,
/// experiences cropping because the kerning affects the trailing edge of
/// the text view as well.
///
/// ![Three text views showing character groups, with progressively
/// increasing spacing between the characters in each
/// group.](SwiftUI-Text-kerning-1.png)
///
/// Kerning attempts to maintain ligatures. For example, the Hoefler Text
/// font uses a ligature for the letter combination _ffl_, as in the word
/// _raffle_, shown here with a small negative and a small positive kerning:
///
/// ![Two text views showing the word raffle in the Hoefler Text font, the
/// first with small negative and the second with small positive kerning.
/// The letter combination ffl has the same shape in both variants because
/// it acts as a ligature.](SwiftUI-Text-kerning-2.png)
///
/// The *ffl* letter combination keeps a constant shape as the other letters
/// move together or apart. Beyond a certain point in either direction,
/// however, kerning does disable nonessential ligatures.
///
/// ![Two text views showing the word raffle in the Hoefler Text font, the
/// first with large negative and the second with large positive kerning.
/// The letter combination ffl does not act as a ligature in either
/// case.](SwiftUI-Text-kerning-3.png)
///
/// - Important: If you add both the ``Text/tracking(_:)`` and
///   ``Text/kerning(_:)`` modifiers to a view, the view applies the
///   tracking and ignores the kerning.
///
/// - Parameter kerning: The spacing to use between individual characters in
///   this text. Value of `0` sets the kerning to the system default value.
///
/// - Returns: Text with the specified amount of kerning.
public func kerning(_ kerning: CGFloat) -> Text
/// Sets the tracking for the text.
///
/// Tracking adds space, measured in points, between the characters in the
/// text view. A positive value increases the spacing between characters,
/// while a negative value brings the characters closer together.
///
///     VStack(alignment: .leading) {
///         Text("ABCDEF").tracking(-3)
///         Text("ABCDEF")
///         Text("ABCDEF").tracking(3)
///     }
///
/// The code above uses an unusually large amount of tracking to make it
/// easy to see the effect.
///
/// ![Three text views showing character groups with progressively
/// increasing spacing between the characters in each
/// group.](SwiftUI-Text-tracking.png)
///
/// The effect of tracking resembles that of the ``Text/kerning(_:)``
/// modifier, but adds or removes trailing whitespace, rather than changing
/// character offsets. Also, using any nonzero amount of tracking disables
/// nonessential ligatures, whereas kerning attempts to maintain ligatures.
///
/// - Important: If you add both the ``Text/tracking(_:)`` and
///   ``Text/kerning(_:)`` modifiers to a view, the view applies the
///   tracking and ignores the kerning.
///
/// - Parameter tracking: The amount of additional space, in points, that
///   the view should add to each character cluster after layout. Value of `0`
///   sets the tracking to the system default value.
///
/// - Returns: Text with the specified amount of tracking.
public func tracking(_ tracking: CGFloat) -> Text
/// Sets the vertical offset for the text relative to its baseline.
///
/// Change the baseline offset to move the text in the view (in points) up
/// or down relative to its baseline. The bounds of the view expand to
/// contain the moved text.
///
///     HStack(alignment: .top) {
///         Text("Hello")
///             .baselineOffset(-10)
///             .border(Color.red)
///         Text("Hello")
///             .border(Color.green)
///         Text("Hello")
///             .baselineOffset(10)
///             .border(Color.blue)
///     }
///     .background(Color(white: 0.9))
///
/// By drawing a border around each text view, you can see how the text
/// moves, and how that affects the view.
///
/// ![Three text views, each with the word "Hello" outlined by a border and
/// aligned along the top edges. The first and last are larger than the
/// second, with padding inside the border above the word "Hello" in the
/// first case, and padding inside the border below the word in the last
/// case.](SwiftUI-Text-baselineOffset.png)
///
/// The first view, with a negative offset, grows downward to handle the
/// lowered text. The last view, with a positive offset, grows upward. The
/// enclosing ``HStack`` instance, shown in gray, ensures all the text views
/// remain aligned at their top edge, regardless of the offset.
///
/// - Parameter baselineOffset: The amount to shift the text vertically (up
///   or down) relative to its baseline.
///
/// - Returns: Text that's above or below its baseline.
public func baselineOffset(_ baselineOffset: CGFloat) -> Text
}
extension Text {
/// Defines text scales
///
/// Text scale provides a way to pick a logical text scale
/// relative to the base font which is used.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct Scale : Sendable, Hashable {
/// Defines default text scale
///
/// When specified uses the default text scale.
public static let `default`: Text.Scale
/// Defines secondary text scale
///
/// When specified a uses a secondary text scale.
public static let secondary: Text.Scale
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text.Scale, b: Text.Scale) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
}
extension Text {
/// Applies a text scale to the text.
///
/// - Parameters:
///   - scale: The text scale to apply.
///   - isEnabled: If true the text scale is applied; otherwise text scale
///     is unchanged.
/// - Returns: Text with the specified scale applied.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func textScale(_ scale: Text.Scale, isEnabled: Bool = true) -> Text
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text {
/// Concatenates the text in two text views in a new text view.
///
/// - Parameters:
///   - lhs: The first text view with text to combine.
///   - rhs: The second text view with text to combine.
///
/// - Returns: A new text view containing the combined contents of the two
///   input text views.
public static func + (lhs: Text, rhs: Text) -> Text
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text.Storage : @unchecked Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text.Modifier : @unchecked Sendable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text.TruncationMode : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Text.TruncationMode : Hashable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text.Case : Equatable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text.Case : Hashable {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text.DateStyle : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Text.DateStyle, b: Text.DateStyle) -> Bool
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Text.DateStyle : Codable {
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
public func encode(to encoder: Encoder) throws
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
public init(from decoder: Decoder) throws
}
/// An alignment position for text along the horizontal axis.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public enum TextAlignment : Hashable, CaseIterable {
case leading
case center
case trailing
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TextAlignment, b: TextAlignment) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [TextAlignment]
/// A collection of all values of this type.
public static var allCases: [TextAlignment] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension TextAlignment : Sendable {
}
/// A built-in group of commands for searching, editing, and transforming
/// selections of text.
///
/// These commands are optional and can be explicitly requested by passing a
/// value of this type to the `Scene.commands(_:)` modifier.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TextEditingCommands : Commands {
/// A new value describing the built-in text-editing commands.
public init()
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// A view that can display and edit long-form text.
///
/// A text editor view allows you to display and edit multiline, scrollable
/// text in your app's user interface. By default, the text editor view styles
/// the text using characteristics inherited from the environment, like
/// ``View/font(_:)``, ``View/foregroundColor(_:)``, and
/// ``View/multilineTextAlignment(_:)``.
///
/// You create a text editor by adding a `TextEditor` instance to the
/// body of your view, and initialize it by passing in a
/// ``Binding`` to a string variable in your app:
///
///     struct TextEditingView: View {
///         @State private var fullText: String = "This is some editable text..."
///
///         var body: some View {
///             TextEditor(text: $fullText)
///         }
///     }
///
/// To style the text, use the standard view modifiers to configure a system
/// font, set a custom font, or change the color of the view's text.
///
/// In this example, the view renders the editor's text in gray with a
/// custom font:
///
///     struct TextEditingView: View {
///         @State private var fullText: String = "This is some editable text..."
///
///         var body: some View {
///             TextEditor(text: $fullText)
///                 .foregroundColor(Color.gray)
///                 .font(.custom("HelveticaNeue", size: 13))
///         }
///     }
///
/// If you want to change the spacing or font scaling aspects of the text, you
/// can use modifiers like ``View/lineLimit(_:)-513mb``,
/// ``View/lineSpacing(_:)``, and ``View/minimumScaleFactor(_:)`` to configure
/// how the view displays text depending on the space constraints. For example,
/// here the ``View/lineSpacing(_:)`` modifier sets the spacing between lines
/// to 5 points:
///
///     struct TextEditingView: View {
///         @State private var fullText: String = "This is some editable text..."
///
///         var body: some View {
///             TextEditor(text: $fullText)
///                 .foregroundColor(Color.gray)
///                 .font(.custom("HelveticaNeue", size: 13))
///                 .lineSpacing(5)
///         }
///     }
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TextEditor : View {
/// Creates a plain text editor.
///
/// Use a ``TextEditor`` instance to create a view in which users can enter
/// and edit long-form text.
///
/// In this example, the text editor renders gray text using the 13
/// point Helvetica Neue font with 5 points of spacing between each line:
///
///     struct TextEditingView: View {
///         @State private var fullText: String = "This is some editable text..."
///
///         var body: some View {
///             TextEditor(text: $fullText)
///                 .foregroundColor(Color.gray)
///                 .font(.custom("HelveticaNeue", size: 13))
///                 .lineSpacing(5)
///         }
///     }
///
/// You can define the styling for the text within the view, including the
/// text color, font, and line spacing. You define these styles by applying
/// standard view modifiers to the view.
///
/// The default text editor doesn't support rich text, such as styling of
/// individual elements within the editor's view. The styles you set apply
/// globally to all text in the view.
///
/// - Parameter text: A ``Binding`` to the variable containing the
///    text to edit.
public init(text: Binding<String>)
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
/// A specification for the appearance and interaction of a text editor.
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol TextEditorStyle {
/// A view that represents the body of a text editor.
associatedtype Body : View
/// Creates a view that represents the body of a text editor.
///
/// The system calls this method for each ``TextEditor`` instance in a view
/// hierarchy where this style is the current text editor style.
///
/// - Parameter configuration: The properties of the text editor.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a text editor.
typealias Configuration = TextEditorStyleConfiguration
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TextEditorStyle where Self == AutomaticTextEditorStyle {
/// The default text editor style, based on the text editor's context.
///
/// The default style represents the recommended style based on the
/// current platform and the text editor's context within the view hierarchy.
public static var automatic: AutomaticTextEditorStyle { get }
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TextEditorStyle where Self == PlainTextEditorStyle {
/// A text editor style with no decoration.
public static var plain: PlainTextEditorStyle { get }
}
/// The properties of a text editor.
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TextEditorStyleConfiguration {
}
/// A control that displays an editable text interface.
///
/// You create a text field with a label and a binding to a value. If the
/// value is a string, the text field updates this value continuously as the
/// user types or otherwise edits the text in the field. For non-string types,
/// it updates the value when the user commits their edits, such as by pressing
/// the Return key.
///
/// The following example shows a text field to accept a username, and a
/// ``Text`` view below it that shadows the continuously updated value
/// of `username`. The ``Text`` view changes color as the user begins and ends
/// editing. When the user submits their completed entry to the text field,
/// the ``View/onSubmit(of:_:)`` modifer calls an internal `validate(name:)`
/// method.
///
///     @State private var username: String = ""
///     @FocusState private var emailFieldIsFocused: Bool = false
///
///     var body: some View {
///         TextField(
///             "User name (email address)",
///             text: $username
///         )
///         .focused($emailFieldIsFocused)
///         .onSubmit {
///             validate(name: username)
///         }
///         .textInputAutocapitalization(.never)
///         .disableAutocorrection(true)
///         .border(.secondary)
///
///         Text(username)
///             .foregroundColor(emailFieldIsFocused ? .red : .blue)
///     }
///
/// ![A text field showing the typed email mruiz2@icloud.com, with a text
/// view below it also showing this value.](SwiftUI-TextField-echoText.png)
///
/// The bound value doesn't have to be a string. By using a
/// <doc://com.apple.documentation/documentation/Foundation/FormatStyle>,
/// you can bind the text field to a nonstring type, using the format style
/// to convert the typed text into an instance of the bound type. The following
/// example uses a
/// <doc://com.apple.documentation/documentation/Foundation/PersonNameComponents/FormatStyle>
/// to convert the name typed in the text field to a
/// <doc://com.apple.documentation/documentation/Foundation/PersonNameComponents>
/// instance. A ``Text`` view below the text field shows the debug description
/// string of this instance.
///
///     @State private var nameComponents = PersonNameComponents()
///
///     var body: some View {
///         TextField(
///             "Proper name",
///             value: $nameComponents,
///             format: .name(style: .medium)
///         )
///         .onSubmit {
///             validate(components: nameComponents)
///         }
///         .disableAutocorrection(true)
///         .border(.secondary)
///         Text(nameComponents.debugDescription)
///     }
///
/// ![A text field showing the typed name Maria Ruiz, with a text view below
///  it showing the string givenName:Maria
///  familyName:Ruiz.](SwiftUI-TextField-nameComponents.png)
///
/// ### Text field prompts
///
/// You can set an explicit prompt on the text field to guide users on what
/// text they should provide. Each text field style determines where and
/// when the text field uses a prompt and label. For example, a form on macOS
/// always places the label at the leading edge of the field and
/// uses a prompt, when available, as placeholder text within the field itself.
/// In the same context on iOS, the text field uses either the prompt or label
/// as placeholder text, depending on whether the initializer provided a prompt.
///
/// The following example shows a ``Form`` with two text fields, each of which
/// provides a prompt to indicate that the field is required, and a view builder
/// to provide a label:
///
///     Form {
///         TextField(text: $username, prompt: Text("Required")) {
///             Text("Username")
///         }
///         SecureField(text: $password, prompt: Text("Required")) {
///             Text("Password")
///         }
///     }
///
/// ![A macOS form, showing two text fields, arranged vertically, with labels to
/// the side that say Username and Password, respectively. Inside each text
/// field, the prompt text says Required.](TextField-prompt-1)
///
/// ![An iOS form, showing two text fields, arranged vertically, with prompt
/// text that says Required.](TextField-prompt-2)
///
/// ### Styling text fields
///
/// SwiftUI provides a default text field style that reflects an appearance and
/// behavior appropriate to the platform. The default style also takes the
/// current context into consideration, like whether the text field is in a
/// container that presents text fields with a special style. Beyond this, you
/// can customize the appearance and interaction of text fields using the
/// ``View/textFieldStyle(_:)`` modifier, passing in an instance of
/// ``TextFieldStyle``. The following example applies the
/// ``TextFieldStyle/roundedBorder`` style to both text fields within a ``VStack``.
///
///     @State private var givenName: String = ""
///     @State private var familyName: String = ""
///
///     var body: some View {
///         VStack {
///             TextField(
///                 "Given Name",
///                 text: $givenName
///             )
///             .disableAutocorrection(true)
///             TextField(
///                 "Family Name",
///                 text: $familyName
///             )
///             .disableAutocorrection(true)
///         }
///         .textFieldStyle(.roundedBorder)
///     }
/// ![Two vertically-stacked text fields, with the prompt text Given Name and
/// Family Name, both with rounded
/// borders.](SwiftUI-TextField-roundedBorderStyle.png)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct TextField<Label> : View where Label : View {
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
extension TextField where Label == Text {
/// Creates a text field that applies a format style to a bound optional
/// value, with a label generated from a localized title string.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the text field
/// sets the bound value to `nil`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses an optional
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound currency value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle/Currency>
/// instance to convert to and from a representation as U.S. dollars. As
/// the user types, a `View.onChange(of:_:)` modifier logs the new value to
/// the console. If the user enters an invalid currency value, like letters
/// or emoji, the console output is `Optional(nil)`.
///
///     @State private var myMoney: Double? = 300.0
///     var body: some View {
///         TextField(
///             "Currency (USD)",
///             value: $myMoney,
///             format: .currency(code: "USD")
///         )
///         .onChange(of: myMoney) { newValue in
///             print ("myMoney: \(newValue)")
///         }
///     }
///
/// - Parameters:
///   - titleKey: The title of the text field, describing its purpose.
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field sets `binding.value` to `nil`.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil) where F : ParseableFormatStyle, F.FormatOutput == String
/// Creates a text field that applies a format style to a bound optional
/// value, with a label generated from a title string.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the text field
/// sets the bound value to `nil`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses an optional
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound currency value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle/Currency>
/// instance to convert to and from a representation as U.S. dollars. As
/// the user types, a `View.onChange(of:_:)` modifier logs the new value to
/// the console. If the user enters an invalid currency value, like letters
/// or emoji, the console output is `Optional(nil)`.
///
///     @State private var label = "Currency (USD)"
///     @State private var myMoney: Double? = 300.0
///     var body: some View {
///         TextField(
///             label,
///             value: $myMoney,
///             format: .currency(code: "USD")
///         )
///         .onChange(of: myMoney) { newValue in
///             print ("myMoney: \(newValue)")
///         }
///     }
///
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field sets `binding.value` to `nil`.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<S, F>(_ title: S, value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil) where S : StringProtocol, F : ParseableFormatStyle, F.FormatOutput == String
/// Creates a text field that applies a format style to a bound
/// value, with a label generated from a localized title string.
///
/// Use this initializer to create a text field that binds to a bound
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle>
/// instance to convert to and from a string representation. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     var body: some View {
///         VStack {
///             TextField(
///                 "Double",
///                 value: $myDouble,
///                 format: .number
///             )
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// ![A text field with the string 0.673. Below this, three text views
/// showing the number with different styles: 0.673, 0.67300, and 6.73E-1.](TextField-init-format-1)
///
/// - Parameters:
///   - titleKey: The title of the text field, describing its purpose.
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field leaves `binding.value` unchanged. If the user stops editing
///     the text in an invalid state, the text field updates the field's
///     text to the last known valid value.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput>, format: F, prompt: Text? = nil) where F : ParseableFormatStyle, F.FormatOutput == String
/// Creates a text field that applies a format style to a bound
/// value, with a label generated from a title string.
///
/// Use this initializer to create a text field that binds to a bound
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle>
/// instance to convert to and from a string representation. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var label = "Double"
///     @State private var myDouble: Double = 0.673
///     var body: some View {
///         VStack {
///             TextField(
///                 label,
///                 value: $myDouble,
///                 format: .number
///             )
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// ![A text field with the string 0.673. Below this, three text views
/// showing the number with different styles: 0.673, 0.67300, and 6.73E-1.](TextField-init-format-1)
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field leaves `binding.value` unchanged. If the user stops editing
///     the text in an invalid state, the text field updates the field's
///     text to the last known valid value.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<S, F>(_ title: S, value: Binding<F.FormatInput>, format: F, prompt: Text? = nil) where S : StringProtocol, F : ParseableFormatStyle, F.FormatOutput == String
}
extension TextField {
/// Creates a text field that applies a format style to a bound optional
/// value, with a label generated from a view builder.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the text field
/// sets the bound value to `nil`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses an optional
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound currency value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle/Currency>
/// instance to convert to and from a representation as U.S. dollars. As
/// the user types, a `View.onChange(of:_:)` modifier logs the new value to
/// the console. If the user enters an invalid currency value, like letters
/// or emoji, the console output is `Optional(nil)`.
///
///     @State private var myMoney: Double? = 300.0
///     var body: some View {
///         TextField(
///             value: $myMoney,
///             format: .currency(code: "USD")
///         ) {
///             Text("Currency (USD)")
///         }
///         .onChange(of: myMoney) { newValue in
///             print ("myMoney: \(newValue)")
///         }
///     }
///
/// - Parameters:
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field sets `binding.value` to `nil`.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
///   - label: A view builder that produces a label for the text field,
///     describing its purpose.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<F>(value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil, @ViewBuilder label: () -> Label) where F : ParseableFormatStyle, F.FormatOutput == String
/// Creates a text field that applies a format style to a bound
/// value, with a label generated from a view builder.
///
/// Use this initializer to create a text field that binds to a bound
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/ParseableFormatStyle>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the format style can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/FloatingPointFormatStyle>
/// instance to convert to and from a string representation. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     var body: some View {
///         VStack {
///             TextField(
///                 value: $myDouble,
///                 format: .number
///             ) {
///                 Text("Double")
///             }
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// ![A text field with the string 0.673. Below this, three text views
/// showing the number with different styles: 0.673, 0.67300, and 6.73E-1.](TextField-init-format-1)
///
/// - Parameters:
///   - value: The underlying value to edit.
///   - format: A format style of type `F` to use when converting between
///     the string the user edits and the underlying value of type
///     `F.FormatInput`. If `format` can't perform the conversion, the text
///     field leaves the value unchanged. If the user stops editing
///     the text in an invalid state, the text field updates the field's
///     text to the last known valid value.
///   - prompt: A `Text` which provides users with guidance on what to type
///     into the text field.
///   - label: A view builder that produces a label for the text field,
///     describing its purpose.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<F>(value: Binding<F.FormatInput>, format: F, prompt: Text? = nil, @ViewBuilder label: () -> Label) where F : ParseableFormatStyle, F.FormatOutput == String
}
extension TextField where Label == Text {
/// Creates a text field that applies a formatter to a bound
/// value, with a label generated from a localized title string.
///
/// Use this initializer to create a text field that binds to a bound
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the formatter can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter>
/// instance to convert to and from a string representation. The formatter
/// uses the
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter/Style/decimal>
/// style, to allow entering a fractional part. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     @State private var numberFormatter: NumberFormatter = {
///         var nf = NumberFormatter()
///         nf.numberStyle = .decimal
///         return nf
///     }()
///
///     var body: some View {
///         VStack {
///             TextField(
///                 "Double",
///                 value: $myDouble,
///                 formatter: numberFormatter
///             )
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - value: The underlying value to edit.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     If `formatter` can't perform the conversion, the text field doesn't
///     modify `binding.value`.
///   - prompt: A `Text` which provides users with guidance on what to enter
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter, prompt: Text?)
/// Creates a text field that applies a formatter to a bound
/// value, with a label generated from a title string.
///
/// Use this initializer to create a text field that binds to a bound
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the formatter can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter>
/// instance to convert to and from a string representation. The formatter
/// uses the
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter/Style/decimal>
/// style, to allow entering a fractional part. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var label = "Double"
///     @State private var myDouble: Double = 0.673
///     @State private var numberFormatter: NumberFormatter = {
///         var nf = NumberFormatter()
///         nf.numberStyle = .decimal
///         return nf
///     }()
///
///     var body: some View {
///         VStack {
///             TextField(
///                 label,
///                 value: $myDouble,
///                 formatter: numberFormatter
///             )
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to edit.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     If `formatter` can't perform the conversion, the text field doesn't
///     modify `binding.value`.
///   - prompt: A `Text` which provides users with guidance on what to enter
///     into the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<S, V>(_ title: S, value: Binding<V>, formatter: Formatter, prompt: Text?) where S : StringProtocol
}
extension TextField {
/// Creates a text field that applies a formatter to a bound optional
/// value, with a label generated from a view builder.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the formatter can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter>
/// instance to convert to and from a string representation. The formatter
/// uses the
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter/Style/decimal>
/// style, to allow entering a fractional part. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     @State private var numberFormatter: NumberFormatter = {
///         var nf = NumberFormatter()
///         nf.numberStyle = .decimal
///         return nf
///     }()
///
///     var body: some View {
///         VStack {
///             TextField(
///                 value: $myDouble,
///                 formatter: numberFormatter
///             ) {
///                 Text("Double")
///             }
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// - Parameters:
///   - value: The underlying value to edit.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     If `formatter` can't perform the conversion, the text field doesn't
///     modify `binding.value`.
///   - prompt: A `Text` which provides users with guidance on what to enter
///     into the text field.
///   - label: A view that describes the purpose of the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<V>(value: Binding<V>, formatter: Formatter, prompt: Text? = nil, @ViewBuilder label: () -> Label)
}
extension TextField where Label == Text {
/// Create an instance which binds over an arbitrary type, `V`.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the formatter can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter>
/// instance to convert to and from a string representation. The formatter
/// uses the
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter/Style/decimal>
/// style, to allow entering a fractional part. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     @State private var numberFormatter: NumberFormatter = {
///         var nf = NumberFormatter()
///         nf.numberStyle = .decimal
///         return nf
///     }()
///
///     var body: some View {
///         VStack {
///             TextField(
///                 value: $myDouble,
///                 formatter: numberFormatter
///             ) {
///                 Text("Double")
///             }
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - value: The underlying value to edit.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     If `formatter` can't perform the conversion, the text field doesn't
///     modify `binding.value`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter)
/// Create an instance which binds over an arbitrary type, `V`.
///
/// Use this initializer to create a text field that binds to a bound optional
/// value, using a
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>
/// to convert to and from this type. Changes to the bound value update
/// the string displayed by the text field. Editing the text field
/// updates the bound value, as long as the formatter can parse the
/// text. If the format style can't parse the input, the bound value
/// remains unchanged.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// The following example uses a
/// <doc://com.apple.documentation/documentation/Swift/Double>
/// as the bound value, and a
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter>
/// instance to convert to and from a string representation. The formatter
/// uses the
/// <doc://com.apple.documentation/documentation/Foundation/NumberFormatter/Style/decimal>
/// style, to allow entering a fractional part. As the user types, the bound
/// value updates, which in turn updates three ``Text`` views that use
/// different format styles. If the user enters text that doesn't represent
/// a valid `Double`, the bound value doesn't update.
///
///     @State private var myDouble: Double = 0.673
///     @State private var numberFormatter: NumberFormatter = {
///         var nf = NumberFormatter()
///         nf.numberStyle = .decimal
///         return nf
///     }()
///
///     var body: some View {
///         VStack {
///             TextField(
///                 value: $myDouble,
///                 formatter: numberFormatter
///             ) {
///                 Text("Double")
///             }
///             Text(myDouble, format: .number)
///             Text(myDouble, format: .number.precision(.significantDigits(5)))
///             Text(myDouble, format: .number.notation(.scientific))
///         }
///     }
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - value: The underlying value to edit.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     If `formatter` can't perform the conversion, the text field doesn't
///     modify `binding.value`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init<S, V>(_ title: S, value: Binding<V>, formatter: Formatter) where S : StringProtocol
}
extension TextField where Label == Text {
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void, onCommit: @escaping () -> Void)
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void)
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter, onCommit: @escaping () -> Void)
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S, V>(_ title: S, value: Binding<V>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void, onCommit: @escaping () -> Void) where S : StringProtocol
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S, V>(_ title: S, value: Binding<V>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void) where S : StringProtocol
/// Create an instance which binds over an arbitrary type, `V`.
///
/// - Parameters:
///   - title: The title of the text field, describing its purpose.
///   - value: The underlying value to be edited.
///   - formatter: A formatter to use when converting between the
///     string the user edits and the underlying value of type `V`.
///     In the event that `formatter` is unable to perform the conversion,
///     `binding.value` isn't modified.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S, V>(_ title: S, value: Binding<V>, formatter: Formatter, onCommit: @escaping () -> Void) where S : StringProtocol
}
extension TextField where Label == Text {
/// Creates a text field with a preferred axis and a text label generated
/// from a localized title string.
///
/// Specify a preferred axis in which the text field should scroll
/// its content when it does not fit in the available space. Depending
/// on the style of the field, this axis may not be respected.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - axis: The axis in which to scroll text when it doesn't fit
///     in the available space.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, axis: Axis)
/// Creates a text field with a preferred axis and a text label generated
/// from a localized title string.
///
/// Specify a preferred axis in which the text field should scroll
/// its content when it does not fit in the available space. Depending
/// on the style of the field, this axis may not be respected.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
///   - axis: The axis in which to scroll text when it doesn't fit
///     in the available space.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, prompt: Text?, axis: Axis)
/// Creates a text field with a preferred axis and a text label generated
/// from a title string.
///
/// Specify a preferred axis in which the text field should scroll
/// its content when it does not fit in the available space. Depending
/// on the style of the field, this axis may not be respected.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - axis: The axis in which to scroll text when it doesn't fit
///     in the available space.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<S>(_ title: S, text: Binding<String>, axis: Axis) where S : StringProtocol
/// Creates a text field with a text label generated from a title string.
///
/// Specify a preferred axis in which the text field should scroll
/// its content when it does not fit in the available space. Depending
/// on the style of the field, this axis may not be respected.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
///   - axis: The axis in which to scroll text when it doesn't fit
///     in the available space.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<S>(_ title: S, text: Binding<String>, prompt: Text?, axis: Axis) where S : StringProtocol
}
extension TextField {
/// Creates a text field with a preferred axis and a prompt generated from
/// a `Text`.
///
/// Specify a preferred axis in which the text field should scroll
/// its content when it does not fit in the available space. Depending
/// on the style of the field, this axis may not be respected.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
///   - axis: The axis in which to scroll text when it doesn't fit
///     in the available space.
///   - label: A view that describes the purpose of the text field.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init(text: Binding<String>, prompt: Text? = nil, axis: Axis, @ViewBuilder label: () -> Label)
}
extension TextField where Label == Text {
/// Creates a text field with a text label generated from a localized title
/// string.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, prompt: Text?)
/// Creates a text field with a text label generated from a title string.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init<S>(_ title: S, text: Binding<String>, prompt: Text?) where S : StringProtocol
}
extension TextField {
/// Creates a text field with a prompt generated from a `Text`.
///
/// Use the ``View/onSubmit(of:_:)`` modifier to invoke an action
/// whenever the user submits this text field.
///
/// - Parameters:
///   - text: The text to display and edit.
///   - prompt: A `Text` representing the prompt of the text field
///     which provides users with guidance on what to type into the text
///     field.
///   - label: A view that describes the purpose of the text field.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public init(text: Binding<String>, prompt: Text? = nil, @ViewBuilder label: () -> Label)
}
extension TextField where Label == Text {
/// Creates a text field with a text label generated from a localized title
/// string.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init(_ titleKey: LocalizedStringKey, text: Binding<String>)
/// Creates a text field with a text label generated from a title string.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init<S>(_ title: S, text: Binding<String>) where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension TextField where Label == Text {
/// Creates a text field with a text label generated from a localized title
/// string.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void, onCommit: @escaping () -> Void)
/// Creates a text field with a text label generated from a localized title
/// string.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void)
/// Creates a text field with a text label generated from a localized title
/// string.
///
/// - Parameters:
///   - titleKey: The key for the localized title of the text field,
///     describing its purpose.
///   - text: The text to display and edit.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onCommit: @escaping () -> Void)
/// Creates a text field with a text label generated from a title string.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S>(_ title: S, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void, onCommit: @escaping () -> Void) where S : StringProtocol
/// Creates a text field with a text label generated from a title string.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S>(_ title: S, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void) where S : StringProtocol
/// Creates a text field with a text label generated from a title string.
///
/// - Parameters:
///   - title: The title of the text view, describing its purpose.
///   - text: The text to display and edit.
///   - onEditingChanged: The action to perform when the user
///     begins editing `text` and after the user finishes editing `text`.
///     The closure receives a Boolean value that indicates the editing
///     status: `true` when the user begins editing, `false` when they
///     finish.
///   - onCommit: An action to perform when the user performs an action
///     (for example, when the user presses the Return key) while the text
///     field has focus.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.")
public init<S>(_ title: S, text: Binding<String>, onCommit: @escaping () -> Void) where S : StringProtocol
}
/// A specification for the appearance and interaction of a text field.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol TextFieldStyle {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension TextFieldStyle where Self == DefaultTextFieldStyle {
/// The default text field style, based on the text field's context.
///
/// The default style represents the recommended style based on the
/// current platform and the text field's context within the view hierarchy.
public static var automatic: DefaultTextFieldStyle { get }
}
@available(iOS 13.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TextFieldStyle where Self == RoundedBorderTextFieldStyle {
/// A text field style with a system-defined rounded border.
public static var roundedBorder: RoundedBorderTextFieldStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension TextFieldStyle where Self == PlainTextFieldStyle {
/// A text field style with no decoration.
public static var plain: PlainTextFieldStyle { get }
}
/// A built-in set of commands for transforming the styles applied to selections
/// of text.
///
/// These commands are optional and can be explicitly requested by passing a
/// value of this type to the `Scene.commands(_:)` modifier.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct TextFormattingCommands : Commands {
/// A new value describing the built-in text-formatting commands.
public init()
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// The kind of autocapitalization behavior applied during text input.
///
/// Pass an instance of `TextInputAutocapitalization` to the
/// ``View/textInputAutocapitalization(_:)`` view modifier.
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *)
@available(macOS, unavailable)
public struct TextInputAutocapitalization : Sendable {
/// Defines an autocapitalizing behavior that will not capitalize anything.
public static var never: TextInputAutocapitalization { get }
/// Defines an autocapitalizing behavior that will capitalize the first
/// letter of every word.
public static var words: TextInputAutocapitalization { get }
/// Defines an autocapitalizing behavior that will capitalize the first
/// letter in every sentence.
public static var sentences: TextInputAutocapitalization { get }
/// Defines an autocapitalizing behavior that will capitalize every letter.
public static var characters: TextInputAutocapitalization { get }
}
@available(iOS 15.0, tvOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension TextInputAutocapitalization {
/// Creates a new ``TextInputAutocapitalization`` struct from a
/// `UITextAutocapitalizationType` enum.
public init?(_ type: UITextAutocapitalizationType)
}
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct TextInputDictationActivation : Equatable, Sendable {
/// A configuration that activates dictation when someone selects the
/// microphone.
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static let onSelect: TextInputDictationActivation
/// A configuration that activates dictation when someone selects the
/// microphone or looks at the entry field.
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static let onLook: TextInputDictationActivation
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TextInputDictationActivation, b: TextInputDictationActivation) -> Bool
}
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct TextInputDictationBehavior : Equatable, Sendable {
/// A platform-appropriate default text input dictation behavior.
///
/// The automatic behavior uses a ``TextInputDictationActivation`` value of
/// ``TextInputDictationActivation/onLook`` for visionOS apps and
/// ``TextInputDictationActivation/onSelect`` for iOS apps.
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static let automatic: TextInputDictationBehavior
/// Adds a dictation microphone in the search bar.
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public static func inline(activation: TextInputDictationActivation) -> TextInputDictationBehavior
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TextInputDictationBehavior, b: TextInputDictationBehavior) -> Bool
}
/// A type that describes the ability to select text.
///
/// To configure whether people can select text in your app, use the
/// ``View/textSelection(_:)`` modifier, passing in a text selectability
/// value like ``enabled`` or ``disabled``.
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public protocol TextSelectability {
/// A Boolean value that indicates whether the selectability type allows
/// selection.
///
/// Conforming types, such as ``EnabledTextSelectability`` and
/// ``DisabledTextSelectability``, return `true` or `false` for this
/// property as appropriate. SwiftUI expects this value for a given
/// selectability type to be constant, unaffected by global state.
static var allowsSelection: Bool { get }
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TextSelectability where Self == EnabledTextSelectability {
/// A selectability value that enables text selection by a person using your app.
///
/// Enabling text selection allows people to perform actions on the text
/// content, such as copying and sharing. Enable text selection in views
/// where those operations are useful, such as copying unique IDs or
/// error messages. This allows people to paste the data into
/// emails or documents.
///
/// The following example enables text selection on the second of two
/// ``Text`` views in a ``VStack``.
///
///     VStack {
///         Text("Event Invite")
///             .font(.title)
///         Text(invite.date.formatted(date: .long, time: .shortened))
///             .textSelection(.enabled)
///     }
///
public static var enabled: EnabledTextSelectability { get }
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension TextSelectability where Self == DisabledTextSelectability {
/// A selectability value that disables text selection by the person using your app.
///
/// Use this property to disable text selection of views that
/// you don't want people to select and copy, even if contained within an
/// overall context that allows text selection.
///
///     content // Content that might contain Text views.
///        .textSelection(.disabled)
///        .padding()
///        .contentShape(Rectangle())
///        .gesture(someGesture)
///
public static var disabled: DisabledTextSelectability { get }
}
/// A type that provides a sequence of dates for use as a schedule.
///
/// Types that conform to this protocol implement a particular kind of schedule
/// by defining an ``TimelineSchedule/entries(from:mode:)`` method that returns
/// a sequence of dates. Use a timeline schedule type when you initialize
/// a ``TimelineView``. For example, you can create a timeline view that
/// updates every second, starting from some `startDate`, using a
/// periodic schedule returned by ``TimelineSchedule/periodic(from:by:)``:
///
///     TimelineView(.periodic(from: startDate, by: 1.0)) { context in
///         // View content goes here.
///     }
///
/// You can also create custom timeline schedules.
/// The timeline view updates its content according to the
/// sequence of dates produced by the schedule.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public protocol TimelineSchedule {
/// An alias for the timeline schedule update mode.
typealias Mode = TimelineScheduleMode
/// The sequence of dates within a schedule.
///
/// The ``TimelineSchedule/entries(from:mode:)`` method returns a value
/// of this type, which is a
/// <doc://com.apple.documentation/documentation/Swift/Sequence>
/// of dates in ascending order. A ``TimelineView`` that you create with a
/// schedule updates its content at the moments in time corresponding to
/// the dates included in the sequence.
associatedtype Entries : Sequence where Self.Entries.Element == Date
/// Provides a sequence of dates starting around a given date.
///
/// A ``TimelineView`` that you create calls this method to figure out
/// when to update its content. The method returns a sequence of dates in
/// increasing order that represent points in time when the timeline view
/// should update. Types that conform to the ``TimelineSchedule`` protocol,
/// like the one returned by ``TimelineSchedule/periodic(from:by:)``, or a custom schedule that
/// you define, implement a custom version of this method to implement a
/// particular kind of schedule.
///
/// One or more dates in the sequence might be before the given
/// `startDate`, in which case the timeline view performs its first
/// update at `startDate` using the entry that most closely precedes
/// that date. For example, if in response to a `startDate` of
/// `10:09:55`, the method returns a sequence with the values `10:09:00`,
/// `10:10:00`, `10:11:00`, and so on, the timeline view performs an initial
/// update at `10:09:55` (using the `10:09:00` entry), followed by another
/// update at the beginning of every minute, starting at `10:10:00`.
///
/// A type that conforms should adjust its behavior based on the `mode` when
/// possible. For example, a periodic schedule providing updates
/// for a timer could restrict updates to once per minute while in the
/// ``TimelineScheduleMode/lowFrequency`` mode:
///
///     func entries(
///         from startDate: Date, mode: TimelineScheduleMode
///     ) -> PeriodicTimelineSchedule {
///         .periodic(
///             from: startDate, by: (mode == .lowFrequency ? 60.0 : 1.0)
///         )
///     }
///
/// - Parameters:
///   - startDate: The date by which the sequence begins.
///   - mode: An indication of whether the schedule updates normally,
///     or with some other cadence.
/// - Returns: A sequence of dates in ascending order.
func entries(from startDate: Date, mode: Self.Mode) -> Self.Entries
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineSchedule where Self == AnimationTimelineSchedule {
/// A pausable schedule of dates updating at a frequency no more quickly
/// than the provided interval.
public static var animation: AnimationTimelineSchedule { get }
/// A pausable schedule of dates updating at a frequency no more quickly
/// than the provided interval.
///
/// - Parameters:
///     - minimumInterval: The minimum interval to update the schedule at.
///     Pass nil to let the system pick an appropriate update interval.
///     - paused: If the schedule should stop generating updates.
public static func animation(minimumInterval: Double? = nil, paused: Bool = false) -> AnimationTimelineSchedule
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineSchedule where Self == PeriodicTimelineSchedule {
/// A schedule for updating a timeline view at regular intervals.
///
/// Initialize a ``TimelineView`` with a periodic timeline schedule when
/// you want to schedule timeline view updates periodically with a custom
/// interval:
///
///     TimelineView(.periodic(from: startDate, by: 3.0)) { context in
///         Text(context.date.description)
///     }
///
/// The timeline view updates its content at the start date, and then
/// again at dates separated in time by the interval amount, which is every
/// three seconds in the example above. For a start date in the
/// past, the view updates immediately, providing as context the date
/// corresponding to the most recent interval boundary. The view then
/// refreshes normally at subsequent interval boundaries. For a start date
/// in the future, the view updates once with the current date, and then
/// begins regular updates at the start date.
///
/// The schedule defines the ``PeriodicTimelineSchedule/Entries``
/// structure to return the sequence of dates when the timeline view calls
/// the ``PeriodicTimelineSchedule/entries(from:mode:)`` method.
///
/// - Parameters:
///   - startDate: The date on which to start the sequence.
///   - interval: The time interval between successive sequence entries.
public static func periodic(from startDate: Date, by interval: TimeInterval) -> PeriodicTimelineSchedule
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineSchedule where Self == EveryMinuteTimelineSchedule {
/// A schedule for updating a timeline view at the start of every minute.
///
/// Initialize a ``TimelineView`` with an every minute timeline schedule
/// when you want to schedule timeline view updates at the start of every
/// minute:
///
///     TimelineView(.everyMinute) { context in
///         Text(context.date.description)
///     }
///
/// The schedule provides the first date as the beginning of the minute in
/// which you use it to initialize the timeline view. For example, if you
/// create the timeline view at `10:09:38`, the schedule's first entry is
/// `10:09:00`. In response, the timeline view performs its first update
/// immediately, providing the beginning of the current minute, namely
/// `10:09:00`, as context to its content. Subsequent updates happen at the
/// beginning of each minute that follows.
///
/// The schedule defines the ``EveryMinuteTimelineSchedule/Entries``
/// structure to return the sequence of dates when the timeline view calls
/// the ``EveryMinuteTimelineSchedule/entries(from:mode:)`` method.
public static var everyMinute: EveryMinuteTimelineSchedule { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineSchedule {
/// A schedule for updating a timeline view at explicit points in time.
///
/// Initialize a ``TimelineView`` with an explicit timeline schedule when
/// you want to schedule view updates at particular points in time:
///
///     let dates = [
///         Date(timeIntervalSinceNow: 10), // Update ten seconds from now,
///         Date(timeIntervalSinceNow: 12) // and a few seconds later.
///     ]
///
///     struct MyView: View {
///         var body: some View {
///             TimelineView(.explicit(dates)) { context in
///                 Text(context.date.description)
///             }
///         }
///     }
///
/// The timeline view updates its content on exactly the dates that
/// you specify, until it runs out of dates, after which it stops changing.
/// If the dates you provide are in the past, the timeline view updates
/// exactly once with the last entry. If you only provide dates in the
/// future, the timeline view renders with the current date until the first
/// date arrives. If you provide one or more dates in the past and one or
/// more in the future, the view renders the most recent past date,
/// refreshing normally on all subsequent dates.
///
/// - Parameter dates: The sequence of dates at which a timeline view
///   updates. Use a monotonically increasing sequence of dates,
///   and ensure that at least one is in the future.
public static func explicit<S>(_ dates: S) -> ExplicitTimelineSchedule<S> where Self == ExplicitTimelineSchedule<S>, S : Sequence, S.Element == Date
}
/// A mode of operation for timeline schedule updates.
///
/// A ``TimelineView`` provides a mode when calling its schedule's
/// ``TimelineSchedule/entries(from:mode:)`` method.
/// The view chooses a mode based on the state of the system.
/// For example, a watchOS view might request a lower frequency
/// of updates, using the ``lowFrequency`` mode, when the user
/// lowers their wrist.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public enum TimelineScheduleMode : Sendable {
/// A mode that produces schedule updates at the schedule's natural cadence.
case normal
/// A mode that produces schedule updates at a reduced rate.
///
/// In this mode, the schedule should generate only
/// "major" updates, if possible. For example, a timeline providing
/// updates to a timer might restrict updates to once a minute while in
/// this mode.
case lowFrequency
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TimelineScheduleMode, b: TimelineScheduleMode) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineScheduleMode : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineScheduleMode : Hashable {
}
/// A view that updates according to a schedule that you provide.
///
/// A timeline view acts as a container with no appearance of its own. Instead,
/// it redraws the content it contains at scheduled points in time.
/// For example, you can update the face of an analog timer once per second:
///
///     TimelineView(.periodic(from: startDate, by: 1)) { context in
///         AnalogTimerView(date: context.date)
///     }
///
/// The closure that creates the content receives an input of type ``Context``
/// that you can use to customize the content's appearance. The context includes
/// the ``Context/date`` that triggered the update. In the example above,
/// the timeline view sends that date to an analog timer that you create so the
/// timer view knows how to draw the hands on its face.
///
/// The context also includes a ``Context/cadence-swift.property``
/// property that you can use to hide unnecessary detail. For example, you
/// can use the cadence to decide when it's appropriate to display the
/// timer's second hand:
///
///     TimelineView(.periodic(from: startDate, by: 1.0)) { context in
///         AnalogTimerView(
///             date: context.date,
///             showSeconds: context.cadence <= .seconds)
///     }
///
/// The system might use a cadence that's slower than the schedule's
/// update rate. For example, a view on watchOS might remain visible when the
/// user lowers their wrist, but update less frequently, and thus require
/// less detail.
///
/// You can define a custom schedule by creating a type that conforms to the
/// ``TimelineSchedule`` protocol, or use one of the built-in schedule types:
/// * Use an ``TimelineSchedule/everyMinute`` schedule to update at the
///   beginning of each minute.
/// * Use a ``TimelineSchedule/periodic(from:by:)`` schedule to update
///   periodically with a custom start time and interval between updates.
/// * Use an ``TimelineSchedule/explicit(_:)`` schedule when you need a finite number, or
///   irregular set of updates.
///
/// For a schedule containing only dates in the past,
/// the timeline view shows the last date in the schedule.
/// For a schedule containing only dates in the future,
/// the timeline draws its content using the current date
/// until the first scheduled date arrives.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct TimelineView<Schedule, Content> where Schedule : TimelineSchedule {
/// Information passed to a timeline view's content callback.
///
/// The context includes both the ``date`` from the schedule that triggered
/// the callback, and a ``cadence-swift.property`` that you can use
/// to customize the appearance of your view. For example, you might choose
/// to display the second hand of an analog clock only when the cadence is
/// ``Cadence-swift.enum/seconds`` or faster.
public struct Context {
/// A rate at which timeline views can receive updates.
///
/// Use the cadence presented to content in a ``TimelineView`` to hide
/// information that updates faster than the view's current update rate.
/// For example, you could hide the millisecond component of a digital
/// timer when the cadence is ``seconds`` or ``minutes``.
///
/// Because this enumeration conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Comparable>
/// protocol, you can compare cadences with relational operators.
/// Slower cadences have higher values, so you could perform the check
/// described above with the following comparison:
///
///     let hideMilliseconds = cadence > .live
///
public enum Cadence : Comparable, Sendable {
/// Updates the view continuously.
case live
/// Updates the view approximately once per second.
case seconds
/// Updates the view approximately once per minute.
case minutes
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TimelineView<Schedule, Content>.Context.Cadence, b: TimelineView<Schedule, Content>.Context.Cadence) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func < (a: TimelineView<Schedule, Content>.Context.Cadence, b: TimelineView<Schedule, Content>.Context.Cadence) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// The date from the schedule that triggered the current view update.
///
/// The first time a ``TimelineView`` closure receives this date, it
/// might be in the past. For example, if you create an
/// ``TimelineSchedule/everyMinute`` schedule at `10:09:55`, the
/// schedule creates entries `10:09:00`, `10:10:00`, `10:11:00`, and so
/// on. In response, the timeline view performs an initial update
/// immediately, at `10:09:55`, but the context contains the `10:09:00`
/// date entry. Subsequent entries arrive at their corresponding times.
public let date: Date
/// The rate at which the timeline updates the view.
///
/// Use this value to hide information that updates faster than the
/// view's current update rate. For example, you could hide the
/// millisecond component of a digital timer when the cadence is
/// anything slower than ``Cadence-swift.enum/live``.
///
/// Because the ``Cadence-swift.enum`` enumeration conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Comparable>
/// protocol, you can compare cadences with relational operators.
/// Slower cadences have higher values, so you could perform the check
/// described above with the following comparison:
///
///     let hideMilliseconds = cadence > .live
///
public let cadence: TimelineView<Schedule, Content>.Context.Cadence
}
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineView : View where Content : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
/// Creates a new timeline view that uses the given schedule.
///
/// - Parameters:
///   - schedule: A schedule that produces a sequence of dates that
///     indicate the instances when the view should update.
///     Use a type that conforms to ``TimelineSchedule``, like
///     ``TimelineSchedule/everyMinute``, or a custom timeline schedule
///     that you define.
///   - content: A closure that generates view content at the moments
///     indicated by the schedule. The closure takes an input of type
///     ``TimelineViewDefaultContext`` that includes the date from the schedule that
///     prompted the update, as well as a ``Context/Cadence-swift.enum``
///     value that the view can use to customize its appearance.
public init(_ schedule: Schedule, @ViewBuilder content: @escaping (TimelineViewDefaultContext) -> Content)
/// Creates a new timeline view that uses the given schedule.
///
/// - Parameters:
///   - schedule: A schedule that produces a sequence of dates that
///     indicate the instances when the view should update.
///     Use a type that conforms to ``TimelineSchedule``, like
///     ``TimelineSchedule/everyMinute``, or a custom timeline schedule
///     that you define.
///   - content: A closure that generates view content at the moments
///     indicated by the schedule. The closure takes an input of type
///     ``Context`` that includes the date from the schedule that
///     prompted the update, as well as a ``Context/Cadence-swift.enum``
///     value that the view can use to customize its appearance.
@available(iOS, deprecated, introduced: 15.0, message: "Use TimelineViewDefaultContext for the type of the context parameter passed into TimelineView's content closure to resolve this warning. The new version of this initializer, using TimelineViewDefaultContext, improves compilation performance by using an independent generic type signature, which helps avoid unintended cyclical type dependencies.")
@available(macOS, deprecated, introduced: 12.0, message: "Use TimelineViewDefaultContext for the type of the context parameter passed into TimelineView's content closure to resolve this warning. The new version of this initializer, using TimelineViewDefaultContext, improves compilation performance by using an independent generic type signature, which helps avoid unintended cyclical type dependencies.")
@available(watchOS, deprecated, introduced: 8.0, message: "Use TimelineViewDefaultContext for the type of the context parameter passed into TimelineView's content closure to resolve this warning. The new version of this initializer, using TimelineViewDefaultContext, improves compilation performance by using an independent generic type signature, which helps avoid unintended cyclical type dependencies.")
@available(tvOS, deprecated, introduced: 15.0, message: "Use TimelineViewDefaultContext for the type of the context parameter passed into TimelineView's content closure to resolve this warning. The new version of this initializer, using TimelineViewDefaultContext, improves compilation performance by using an independent generic type signature, which helps avoid unintended cyclical type dependencies.")
@available(visionOS, deprecated, introduced: 1.0, message: "Use TimelineViewDefaultContext for the type of the context parameter passed into TimelineView's content closure to resolve this warning. The new version of this initializer, using TimelineViewDefaultContext, improves compilation performance by using an independent generic type signature, which helps avoid unintended cyclical type dependencies.")
public init(_ schedule: Schedule, @ViewBuilder content: @escaping (TimelineView<Schedule, Content>.Context) -> Content)
}
@available(iOS 16.0, watchOS 8.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
extension TimelineView.Context {
/// Resets any pre-rendered views the system has from the timeline.
///
/// When entering Always On Display, the system might pre-render frames. If the
/// content of these frames must change in a way that isn't reflected by
/// the schedule or the timeline view's current bindings --- for example, because
/// the user changes the title of a future calendar event --- call this method to
/// request that the frames be regenerated.
public func invalidateTimelineContent()
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension TimelineView.Context.Cadence : Hashable {
}
/// Information passed to a timeline view's content callback.
///
/// The context includes both the date from the schedule that triggered
/// the callback, and a cadence that you can use to customize the appearance of
/// your view. For example, you might choose to display the second hand of an
/// analog clock only when the cadence is
/// ``TimelineView/Context/Cadence-swift.enum/seconds`` or faster.
///
/// > Note: This type alias uses a specific concrete instance of
/// ``TimelineView/Context`` that all timeline views can use.
/// It does this to prevent introducing an unnecessary generic parameter
/// dependency on the context type.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public typealias TimelineViewDefaultContext = TimelineView<EveryMinuteTimelineSchedule, Never>.Context
/// A style that reflects the current tint color.
///
/// You can set the tint color with the ``View/tint(_:)-93mfq`` modifier. If no
/// explicit tint is set, the tint is derived from the app's accent color.
///
/// You can also use ``ShapeStyle/tint`` to construct this style.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct TintShapeStyle : ShapeStyle {
/// Creates a tint shape style.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A label style that shows both the title and icon of the label using a
/// system-standard layout.
///
/// You can also use ``LabelStyle/titleAndIcon`` to construct this style.
@available(iOS 14.5, macOS 11.3, tvOS 14.5, watchOS 7.4, *)
public struct TitleAndIconLabelStyle : LabelStyle {
/// Creates a label style that shows both the title and icon of the label
/// using a system-standard layout.
public init()
/// Creates a view that represents the body of a label.
///
/// The system calls this method for each ``Label`` instance in a view
/// hierarchy where this style is the current label style.
///
/// - Parameter configuration: The properties of the label.
public func makeBody(configuration: TitleAndIconLabelStyle.Configuration) -> some View
/// A view that represents the body of a label.
public typealias Body = some View
}
/// A label style that only displays the title of the label.
///
/// You can also use ``LabelStyle/titleOnly`` to construct this style.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct TitleOnlyLabelStyle : LabelStyle {
/// Creates a title-only label style.
public init()
/// Creates a view that represents the body of a label.
///
/// The system calls this method for each ``Label`` instance in a view
/// hierarchy where this style is the current label style.
///
/// - Parameter configuration: The properties of the label.
public func makeBody(configuration: TitleOnlyLabelStyle.Configuration) -> some View
/// A view that represents the body of a label.
public typealias Body = some View
}
/// A control that toggles between on and off states.
///
/// You create a toggle by providing an `isOn` binding and a label. Bind `isOn`
/// to a Boolean property that determines whether the toggle is on or off. Set
/// the label to a view that visually describes the purpose of switching between
/// toggle states. For example:
///
///     @State private var vibrateOnRing = false
///
///     var body: some View {
///         Toggle(isOn: $vibrateOnRing) {
///             Text("Vibrate on Ring")
///         }
///     }
///
/// For the common case of ``Label`` based labels, you can use the convenience
/// initializer that takes a title string (or localized string key) and the
/// name of a system image:
///
///     @State private var vibrateOnRing = true
///
///     var body: some View {
///         Toggle(
///             "Vibrate on Ring",
///             systemImage: "dot.radiowaves.left.and.right",
///             isOn: $vibrateOnRing
///         )
///     }
///
/// For text-only labels, you can use the convenience initializer that takes
/// a title string (or localized string key) as its first parameter, instead
/// of a trailing closure:
///
///     @State private var vibrateOnRing = true
///
///     var body: some View {
///         Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
///     }
///
/// ### Styling toggles
///
/// Toggles use a default style that varies based on both the platform and
/// the context. For more information, read about the ``ToggleStyle/automatic``
/// toggle style.
///
/// You can customize the appearance and interaction of toggles by applying
/// styles using the ``View/toggleStyle(_:)`` modifier. You can apply built-in
/// styles, like ``ToggleStyle/switch``, to either a toggle, or to a view
/// hierarchy that contains toggles:
///
///     VStack {
///         Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
///         Toggle("Vibrate on Silent", isOn: $vibrateOnSilent)
///     }
///     .toggleStyle(.switch)
///
/// You can also define custom styles by creating a type that conforms to the
/// ``ToggleStyle`` protocol.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Toggle<Label> : View where Label : View {
/// Creates a toggle that displays a custom label.
///
/// - Parameters:
///   - isOn: A binding to a property that determines whether the toggle is on
///     or off.
///   - label: A view that describes the purpose of the toggle.
public init(isOn: Binding<Bool>, @ViewBuilder label: () -> Label)
/// Creates a toggle representing a collection of values with a custom label.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle(sources: $alarms, isOn: \.isOn) {
///         Text("Enable all alarms")
///     }
///
/// - Parameters:
///   - sources: A collection of values used as the source for rendering the
///     Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
///   - label: A view that describes the purpose of the toggle.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(sources: C, isOn: KeyPath<C.Element, Binding<Bool>>, @ViewBuilder label: () -> Label) where C : RandomAccessCollection
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@MainActor public var body: some View { get }
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Toggle where Label == ToggleStyleConfiguration.Label {
/// Creates a toggle based on a toggle style configuration.
///
/// You can use this initializer within the
/// ``ToggleStyle/makeBody(configuration:)`` method of a ``ToggleStyle`` to
/// create an instance of the styled toggle. This is useful for custom
/// toggle styles that only modify the current toggle style, as opposed to
/// implementing a brand new style.
///
/// For example, the following style adds a red border around the toggle,
/// but otherwise preserves the toggle's current style:
///
///     struct RedBorderToggleStyle: ToggleStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Toggle(configuration)
///                 .padding()
///                 .border(.red)
///         }
///     }
///
/// - Parameter configuration: The properties of the toggle, including a
///   label and a binding to the toggle's state.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public init(_ configuration: ToggleStyleConfiguration)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Toggle where Label == Text {
/// Creates a toggle that generates its label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// To initialize a toggle with a string variable, use
/// ``Toggle/init(_:isOn:)-2qurm`` instead.
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init(_ titleKey: LocalizedStringKey, isOn: Binding<Bool>)
/// Creates a toggle that generates its label from a string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// To initialize a toggle with a localized string key, use
/// ``Toggle/init(_:isOn:)-8qx3l`` instead.
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init<S>(_ title: S, isOn: Binding<Bool>) where S : StringProtocol
/// Creates a toggle representing a collection of values that generates its
/// label from a localized string key.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - sources: A collection of values used as the source for rendering the
///     Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(_ titleKey: LocalizedStringKey, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where C : RandomAccessCollection
/// Creates a toggle representing a collection of values that generates its
/// label from a string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - sources: A collection of values used as the source for rendering
///     the Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<S, C>(_ title: S, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where S : StringProtocol, C : RandomAccessCollection
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Toggle where Label == Label<Text, Image> {
/// Creates a toggle that generates its label from a localized string key
/// and system image.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// To initialize a toggle with a string variable, use
/// ``Toggle/init(_:isOn:)-2qurm`` instead.
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - systemImage: The name of the image resource to lookup.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init(_ titleKey: LocalizedStringKey, systemImage: String, isOn: Binding<Bool>)
/// Creates a toggle that generates its label from a string and
/// system image.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// To initialize a toggle with a localized string key, use
/// ``Toggle/init(_:isOn:)-8qx3l`` instead.
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - systemImage: The name of the image resource to lookup.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init<S>(_ title: S, systemImage: String, isOn: Binding<Bool>) where S : StringProtocol
/// Creates a toggle representing a collection of values that generates its
/// label from a localized string key and system image.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - systemImage: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for rendering the
///     Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<C>(_ titleKey: LocalizedStringKey, systemImage: String, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where C : RandomAccessCollection
/// Creates a toggle representing a collection of values that generates its
/// label from a string.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - systemImage: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for rendering
///     the Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public init<S, C>(_ title: S, systemImage: String, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where S : StringProtocol, C : RandomAccessCollection
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Toggle where Label == Label<Text, Image> {
/// Creates a toggle that generates its label from a localized string key
/// and image resource.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// To initialize a toggle with a string variable, use
/// ``Toggle/init(_:isOn:)-2qurm`` instead.
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - image: The name of the image resource to lookup.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init(_ titleKey: LocalizedStringKey, image: ImageResource, isOn: Binding<Bool>)
/// Creates a toggle that generates its label from a string and
/// image resource.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// To initialize a toggle with a localized string key, use
/// ``Toggle/init(_:isOn:)-8qx3l`` instead.
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - image: The name of the image resource to lookup.
///   - isOn: A binding to a property that indicates whether the toggle is
///    on or off.
public init<S>(_ title: S, image: ImageResource, isOn: Binding<Bool>) where S : StringProtocol
/// Creates a toggle representing a collection of values that generates its
/// label from a localized string key and image resource.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See
/// `Text` for more information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - titleKey: The key for the toggle's localized title, that describes
///     the purpose of the toggle.
///   - image: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for rendering the
///     Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
public init<C>(_ titleKey: LocalizedStringKey, image: ImageResource, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where C : RandomAccessCollection
/// Creates a toggle representing a collection of values that generates its
/// label from a string and image resource.
///
/// This initializer creates a ``Text`` view on your behalf, and treats the
/// title similar to ``Text/init(_:)-9d1g4``. See `Text` for more
/// information about localizing strings.
///
/// The following example creates a single toggle that represents
/// the state of multiple alarms:
///
///     struct Alarm: Hashable, Identifiable {
///         var id = UUID()
///         var isOn = false
///         var name = ""
///     }
///
///     @State private var alarms = [
///         Alarm(isOn: true, name: "Morning"),
///         Alarm(isOn: false, name: "Evening")
///     ]
///
///     Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)
///
/// - Parameters:
///   - title: A string that describes the purpose of the toggle.
///   - image: The name of the image resource to lookup.
///   - sources: A collection of values used as the source for rendering
///     the Toggle's state.
///   - isOn: The key path of the values that determines whether the toggle
///     is on, mixed or off.
public init<S, C>(_ title: S, image: ImageResource, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where S : StringProtocol, C : RandomAccessCollection
}
/// The appearance and behavior of a toggle.
///
/// To configure the style for a single ``Toggle`` or for all toggle instances
/// in a view hierarchy, use the ``View/toggleStyle(_:)`` modifier. You can
/// specify one of the built-in toggle styles, like ``ToggleStyle/switch`` or
/// ``ToggleStyle/button``:
///
///     Toggle(isOn: $isFlagged) {
///         Label("Flag", systemImage: "flag.fill")
///     }
///     .toggleStyle(.button)
///
/// Alternatively, you can create and apply a custom style.
///
/// ### Custom styles
///
/// To create a custom style, declare a type that conforms to the `ToggleStyle`
/// protocol and implement the required ``ToggleStyle/makeBody(configuration:)``
/// method. For example, you can define a checklist toggle style:
///
///     struct ChecklistToggleStyle: ToggleStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             // Return a view that has checklist appearance and behavior.
///         }
///     }
///
/// Inside the method, use the `configuration` parameter, which is an instance
/// of the ``ToggleStyleConfiguration`` structure, to get the label and
/// a binding to the toggle state. To see examples of how to use these items
/// to construct a view that has the appearance and behavior of a toggle, see
/// ``ToggleStyle/makeBody(configuration:)``.
///
/// To provide easy access to the new style, declare a corresponding static
/// variable in an extension to `ToggleStyle`:
///
///     extension ToggleStyle where Self == ChecklistToggleStyle {
///         static var checklist: ChecklistToggleStyle { .init() }
///     }
///
/// You can then use your custom style:
///
///     Toggle(activity.name, isOn: $activity.isComplete)
///         .toggleStyle(.checklist)
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ToggleStyle {
/// A view that represents the appearance and interaction of a toggle.
///
/// SwiftUI infers this type automatically based on the ``View``
/// instance that you return from your implementation of the
/// ``makeBody(configuration:)`` method.
associatedtype Body : View
/// Creates a view that represents the body of a toggle.
///
/// Implement this method when you define a custom toggle style that
/// conforms to the ``ToggleStyle`` protocol. Use the `configuration`
/// input --- a ``ToggleStyleConfiguration`` instance --- to access the
/// toggle's label and state. Return a view that has the appearance and
/// behavior of a toggle. For example you can create a toggle that displays
/// a label and a circle that's either empty or filled with a checkmark:
///
///     struct ChecklistToggleStyle: ToggleStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Button {
///                 configuration.isOn.toggle()
///             } label: {
///                 HStack {
///                     Image(systemName: configuration.isOn
///                             ? "checkmark.circle.fill"
///                             : "circle")
///                     configuration.label
///                 }
///             }
///             .tint(.primary)
///             .buttonStyle(.borderless)
///         }
///     }
///
/// The `ChecklistToggleStyle` toggle style provides a way to both observe
/// and modify the toggle state: the circle fills for the on state, and
/// users can tap or click the toggle to change the state. By using a
/// customized ``Button`` to compose the toggle's body, SwiftUI
/// automatically provides the behaviors that users expect from a
/// control that has button-like characteristics.
///
/// You can present a collection of toggles that use this style in a stack:
///
/// ![A screenshot of three items stacked vertically. All have a circle
/// followed by a label. The first has the label Walk the dog, and the
/// circle is filled. The second has the label Buy groceries, and the
/// circle is filled. The third has the label Call Mom, and the cirlce is
/// empty.](ToggleStyle-makeBody-1-iOS)
///
/// When updating a view hierarchy, the system calls your implementation
/// of the `makeBody(configuration:)` method for each ``Toggle`` instance
/// that uses the associated style.
///
/// ### Modify the current style
///
/// Rather than create an entirely new style, you can alternatively
/// modify a toggle's current style. Use the ``Toggle/init(_:)``
/// initializer inside the `makeBody(configuration:)` method to create
/// and modify a toggle based on a `configuration` value. For example,
/// you can create a style that adds padding and a red border to the
/// current style:
///
///     struct RedBorderToggleStyle: ToggleStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Toggle(configuration)
///                 .padding()
///                 .border(.red)
///         }
///     }
///
/// If you create a `redBorder` static variable from this style,
/// you can apply the style to toggles that already use another style, like
/// the built-in ``ToggleStyle/switch`` and ``ToggleStyle/button`` styles:
///
///     Toggle("Switch", isOn: $isSwitchOn)
///         .toggleStyle(.redBorder)
///         .toggleStyle(.switch)
///
///     Toggle("Button", isOn: $isButtonOn)
///         .toggleStyle(.redBorder)
///         .toggleStyle(.button)
///
/// Both toggles appear with the usual styling, each with a red border:
///
/// ![A screenshot of a switch toggle with a red border, and a button
/// toggle with a red border.](ToggleStyle-makeBody-2-iOS)
///
/// Apply the custom style closer to the toggle than the
/// modified style because SwiftUI evaluates style view modifiers in order
/// from outermost to innermost. If you apply the styles in the other
/// order, the red border style doesn't have an effect, because the
/// built-in styles override it completely.
///
/// - Parameter configuration: The properties of the toggle, including a
///   label and a binding to the toggle's state.
/// - Returns: A view that has behavior and appearance that enables it
///   to function as a ``Toggle``.
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body
/// The properties of a toggle instance.
///
/// You receive a `configuration` parameter of this type --- which is an
/// alias for the ``ToggleStyleConfiguration`` type --- when you implement
/// the required ``makeBody(configuration:)`` method in a custom toggle
/// style implementation.
typealias Configuration = ToggleStyleConfiguration
}
@available(iOS 15.0, macOS 12.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension ToggleStyle where Self == ButtonToggleStyle {
/// A toggle style that displays as a button with its label as the title.
///
/// Apply this style to a ``Toggle`` or to a view hierarchy that contains
/// toggles using the ``View/toggleStyle(_:)`` modifier:
///
///     Toggle(isOn: $isFlagged) {
///         Label("Flag", systemImage: "flag.fill")
///     }
///     .toggleStyle(.button)
///
/// The style produces a button with a label that describes the purpose
/// of the toggle. The user taps or clicks the button to change the
/// toggle's state. The button indicates the `on` state by filling in the
/// background with its tint color. You can change the tint color using
/// the ``View/tint(_:)-93mfq`` modifier. SwiftUI uses this style as the
/// default for toggles that appear in a toolbar.
///
/// The following table shows the toggle in both the `off` and `on` states,
/// respectively:
///
///   | Platform    | Appearance |
///   |-------------|------------|
///   | iOS, iPadOS | ![A screenshot of two buttons with a flag icon and the word flag inside. The first button isn't highlighted; the second one is.](ToggleStyle-button-1-iOS) |
///   | macOS       | ![A screenshot of two buttons with a flag icon and the word flag inside. The first button isn't highlighted; the second one is.](ToggleStyle-button-1-macOS) |
///
/// A ``Label`` instance is a good choice for a button toggle's label.
/// Based on the context, SwiftUI decides whether to display both the title
/// and icon, as in the example above, or just the icon, like when the
/// toggle appears in a toolbar. You can also control the label's style
/// by adding a ``View/labelStyle(_:)`` modifier. In any case, SwiftUI
/// always uses the title to identify the control using VoiceOver.
public static var button: ButtonToggleStyle { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ToggleStyle where Self == DefaultToggleStyle {
/// The default toggle style.
///
/// Use this ``ToggleStyle`` to let SwiftUI pick a suitable style for
/// the current platform and context. Toggles use the `automatic` style
/// by default, but you might need to set it explicitly using the
/// ``View/toggleStyle(_:)`` modifier to override another style
/// in the environment. For example, you can request automatic styling for
/// a toggle in an ``HStack`` that's otherwise configured to use the
/// ``ToggleStyle/button`` style:
///
///     HStack {
///         Toggle(isOn: $isShuffling) {
///             Label("Shuffle", systemImage: "shuffle")
///         }
///         Toggle(isOn: $isRepeating) {
///             Label("Repeat", systemImage: "repeat")
///         }
///
///         Divider()
///
///         Toggle("Enhance Sound", isOn: $isEnhanced)
///             .toggleStyle(.automatic) // Set the style automatically here.
///     }
///     .toggleStyle(.button) // Use button style for toggles in the stack.
///
/// ### Platform defaults
///
/// The `automatic` style produces an appearance that varies by platform,
/// using the following styles in most contexts:
///
/// | Platform    | Default style                            |
/// |-------------|------------------------------------------|
/// | iOS, iPadOS | ``ToggleStyle/switch``                   |
/// | macOS       | ``ToggleStyle/checkbox``                 |
/// | tvOS        | A tvOS-specific button style (see below) |
/// | watchOS     | ``ToggleStyle/switch``                   |
///
/// The default style for tvOS behaves like a button. However,
/// unlike the ``ToggleStyle/button`` style that's available in some other
/// platforms, the tvOS toggle takes as much horizontal space as its parent
/// offers, and displays both the toggle's label and a text field that
/// indicates the toggle's state. You typically collect tvOS toggles into
/// a ``List``:
///
///     List {
///         Toggle("Show Lyrics", isOn: $isShowingLyrics)
///         Toggle("Shuffle", isOn: $isShuffling)
///         Toggle("Repeat", isOn: $isRepeating)
///     }
///
/// ![A screenshot of three buttons labeled Show Lyrics, Shuffle, and
/// Repeat, stacked vertically. The first is highlighted. The second is
/// on, while the others are off.](ToggleStyle-automatic-2-tvOS)
///
/// ### Contextual defaults
///
/// A toggle's automatic appearance varies in certain contexts:
///
/// * A toggle that appears as part of the content that you provide to one
///   of the toolbar modifiers, like ``View/toolbar(content:)-5w0tj``, uses
///   the ``ToggleStyle/button`` style by default.
///
/// * A toggle in a ``Menu`` uses a style that you can't create explicitly:
///     ```
///     Menu("Playback") {
///         Toggle("Show Lyrics", isOn: $isShowingLyrics)
///         Toggle("Shuffle", isOn: $isShuffling)
///         Toggle("Repeat", isOn: $isRepeating)
///     }
///     ```
///   SwiftUI shows the toggle's label with a checkmark that appears only
///   in the `on` state:
///
///   | Platform    | Appearance |
///   |-------------|------------|
///   | iOS, iPadOS | ![A screenshot of a Playback menu in iOS showing three menu items with the labels Repeat, Shuffle, and Show Lyrics. The shuffle item has a checkmark to its left, while the other two items have a blank space to their left.](ToggleStyle-automatic-1-iOS) |
///   | macOS       | ![A screenshot of a Playback menu in macOS showing three menu items with the labels Repeat, Shuffle, and Show Lyrics. The shuffle item has a checkmark to its left, while the other two items have a blank space to their left.](ToggleStyle-automatic-1-macOS) |
public static var automatic: DefaultToggleStyle { get }
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@available(tvOS, unavailable)
extension ToggleStyle where Self == SwitchToggleStyle {
/// A toggle style that displays a leading label and a trailing switch.
///
/// Apply this style to a ``Toggle`` or to a view hierarchy that contains
/// toggles using the ``View/toggleStyle(_:)`` modifier:
///
///     Toggle("Enhance Sound", isOn: $isEnhanced)
///         .toggleStyle(.switch)
///
/// The style produces a label that describes the purpose of the toggle
/// and a switch that shows the toggle's state. The user taps or clicks
/// the switch to change the toggle's state. The default appearance is
/// similar across platforms, although the way you use switches in your
/// user interface varies a little, as described in the respective Human
/// Interface Guidelines sections:
///
/// | Platform    | Appearance | Human Interface Guidelines |
/// |-------------|------------|----------------------------|
/// | iOS, iPadOS | ![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is green. The toggle and its text appear in a rounded rectangle, and are aligned with opposite edges of the rectangle.](ToggleStyle-switch-1-iOS) | [Switches](https://developer.apple.com/design/human-interface-guidelines/ios/controls/switches/) |
/// | macOS       | ![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is blue. The toggle and its text are adjacent to each other.](ToggleStyle-switch-1-macOS) | [Switches](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/switches/)
/// | watchOS     | ![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is green. The toggle and its text appear in a rounded rectangle, and are aligned with opposite edges of the rectangle.](ToggleStyle-switch-1-watchOS) | [Toggles and Switches](https://developer.apple.com/design/human-interface-guidelines/watchos/elements/toggles-and-switches/) |
///
/// In iOS, iPadOS, and watchOS, the label and switch fill as much
/// horizontal space as the toggle's parent offers by aligning the label's
/// leading edge and the switch's trailing edge with the containing view's
/// respective leading and trailing edges. In macOS, the style uses a
/// minimum of horizontal space by aligning the trailing edge of the label
/// with the leading edge of the switch. SwiftUI helps you to manage the
/// spacing and alignment when this style appears in a ``Form``.
///
/// SwiftUI uses this style as the default for iOS, iPadOS, and watchOS in
/// most contexts when you don't set a style, or when you apply
/// the ``ToggleStyle/automatic`` style.
public static var `switch`: SwitchToggleStyle { get }
}
/// The properties of a toggle instance.
///
/// When you define a custom toggle style by creating a type that conforms to
/// the ``ToggleStyle`` protocol, you implement the
/// ``ToggleStyle/makeBody(configuration:)`` method. That method takes a
/// `ToggleStyleConfiguration` input that has the information you need
/// to define the behavior and appearance of a ``Toggle``.
///
/// The configuration structure's ``label-swift.property`` reflects the
/// toggle's content, which might be the value that you supply to the
/// `label` parameter of the ``Toggle/init(isOn:label:)`` initializer.
/// Alternatively, it could be another view that SwiftUI builds from an
/// initializer that takes a string input, like ``Toggle/init(_:isOn:)-8qx3l``.
/// In either case, incorporate the label into the toggle's view to help
/// the user understand what the toggle does. For example, the built-in
/// ``ToggleStyle/switch`` style horizontally stacks the label with the
/// control element.
///
/// The structure's ``isOn`` property provides a ``Binding`` to the state
/// of the toggle. Adjust the appearance of the toggle based on this value.
/// For example, the built-in ``ToggleStyle/button`` style fills the button's
/// background when the property is `true`, but leaves the background empty
/// when the property is `false`. Change the value when the user performs
/// an action that's meant to change the toggle, like the button does when
/// tapped or clicked by the user.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct ToggleStyleConfiguration {
/// A type-erased label of a toggle.
///
/// SwiftUI provides a value of this type --- which is a ``View`` type ---
/// as the ``label-swift.property`` to your custom toggle style
/// implementation. Use the label to help define the appearance of the
/// toggle.
public struct Label : View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A view that describes the effect of switching the toggle between states.
///
/// Use this value in your implementation of the
/// ``ToggleStyle/makeBody(configuration:)`` method when defining a custom
/// ``ToggleStyle``. Access it through the that method's `configuration`
/// parameter.
///
/// Because the label is a ``View``, you can incorporate it into the
/// view hierarchy that you return from your style definition. For example,
/// you can combine the label with a circle image in an ``HStack``:
///
///     HStack {
///         Image(systemName: configuration.isOn
///             ? "checkmark.circle.fill"
///             : "circle")
///         configuration.label
///     }
///
public let label: ToggleStyleConfiguration.Label
/// A binding to a state property that indicates whether the toggle is on.
///
/// Because this value is a ``Binding``, you can both read and write it
/// in your implementation of the ``ToggleStyle/makeBody(configuration:)``
/// method when defining a custom ``ToggleStyle``. Access it through
/// that method's `configuration` parameter.
///
/// Read this value to set the appearance of the toggle. For example, you
/// can choose between empty and filled circles based on the `isOn` value:
///
///     Image(systemName: configuration.isOn
///         ? "checkmark.circle.fill"
///         : "circle")
///
/// Write this value when the user takes an action that's meant to change
/// the state of the toggle. For example, you can toggle it inside the
/// `action` closure of a ``Button`` instance:
///
///     Button {
///         configuration.isOn.toggle()
///     } label: {
///         // Draw the toggle.
///     }
///
@Binding public var isOn: Bool { get nonmutating set }
public var $isOn: Binding<Bool> { get }
/// Whether the ``Toggle`` is currently in a mixed state.
///
/// Use this property to determine whether the toggle style should render
/// a mixed state presentation. A mixed state corresponds to an underlying
/// collection with a mix of true and false Bindings.
/// To toggle the state, use the ``Bool.toggle()`` method on the ``isOn``
/// binding.
///
/// In the following example, a custom style uses the `isMixed` property
/// to render the correct toggle state using symbols:
///
///     struct SymbolToggleStyle: ToggleStyle {
///         func makeBody(configuration: Configuration) -> some View {
///             Button {
///                 configuration.isOn.toggle()
///             } label: {
///                 Image(
///                     systemName: configuration.isMixed
///                     ? "minus.circle.fill" : configuration.isOn
///                     ? "checkmark.circle.fill" : "circle.fill")
///                 configuration.label
///             }
///         }
///     }
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public var isMixed: Bool
}
/// A built-in set of commands for manipulating window toolbars.
///
/// These commands are optional and can be explicitly requested by passing a
/// value of this type to the ``Scene/commands(content:)`` modifier.
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct ToolbarCommands : Commands {
/// A new value describing the built-in toolbar-related commands.
public init()
/// The contents of the command hierarchy.
///
/// For any commands that you create, provide a computed `body` property
/// that defines the scene as a composition of other scenes. You can
/// assemble a command hierarchy from built-in commands that SwiftUI
/// provides, as well as other commands that you've defined.
public var body: some Commands { get }
/// The type of commands that represents the body of this command hierarchy.
///
/// When you create custom commands, Swift infers this type from your
/// implementation of the required ``SwiftUI/Commands/body-swift.property``
/// property.
public typealias Body = some Commands
}
/// Conforming types represent items that can be placed in various locations
/// in a toolbar.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol ToolbarContent {
/// The type of content representing the body of this toolbar content.
associatedtype Body : ToolbarContent
/// The composition of content that comprise the toolbar content.
@ToolbarContentBuilder var body: Self.Body { get }
}
/// Constructs a toolbar item set from multi-expression closures.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@resultBuilder public struct ToolbarContentBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : ToolbarContent
public static func buildBlock<Content>(_ content: Content) -> some ToolbarContent where Content : ToolbarContent
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : CustomizableToolbarContent
public static func buildBlock<Content>(_ content: Content) -> some CustomizableToolbarContent where Content : CustomizableToolbarContent
}
extension ToolbarContentBuilder {
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildIf<Content>(_ content: Content?) -> Content? where Content : ToolbarContent
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildIf<Content>(_ content: Content?) -> Content? where Content : CustomizableToolbarContent
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : ToolbarContent, FalseContent : ToolbarContent
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : CustomizableToolbarContent, FalseContent : CustomizableToolbarContent
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : ToolbarContent, FalseContent : ToolbarContent
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : CustomizableToolbarContent, FalseContent : CustomizableToolbarContent
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static func buildLimitedAvailability<Content>(_ content: Content) -> some ToolbarContent where Content : ToolbarContent
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public static func buildLimitedAvailability<Content>(_ content: Content) -> some CustomizableToolbarContent where Content : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent, C5 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent, C5 : ToolbarContent, C6 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent, C5 : ToolbarContent, C6 : ToolbarContent, C7 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent, C5 : ToolbarContent, C6 : ToolbarContent, C7 : ToolbarContent, C8 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some ToolbarContent where C0 : ToolbarContent, C1 : ToolbarContent, C2 : ToolbarContent, C3 : ToolbarContent, C4 : ToolbarContent, C5 : ToolbarContent, C6 : ToolbarContent, C7 : ToolbarContent, C8 : ToolbarContent, C9 : ToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent, C5 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent, C5 : CustomizableToolbarContent, C6 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent, C5 : CustomizableToolbarContent, C6 : CustomizableToolbarContent, C7 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent, C5 : CustomizableToolbarContent, C6 : CustomizableToolbarContent, C7 : CustomizableToolbarContent, C8 : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarContentBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some CustomizableToolbarContent where C0 : CustomizableToolbarContent, C1 : CustomizableToolbarContent, C2 : CustomizableToolbarContent, C3 : CustomizableToolbarContent, C4 : CustomizableToolbarContent, C5 : CustomizableToolbarContent, C6 : CustomizableToolbarContent, C7 : CustomizableToolbarContent, C8 : CustomizableToolbarContent, C9 : CustomizableToolbarContent
}
/// The customization behavior of customizable toolbar content.
///
/// Customizable toolbar content support different types of customization
/// behaviors. For example, some customizable content may not be removed by
/// the user. Some content may be placed in a toolbar that supports
/// customization overall, but not for that particular content.
///
/// Use this type in conjunction with the
/// ``CustomizableToolbarContent/customizationBehavior(_:)`` modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ToolbarCustomizationBehavior : Sendable {
/// The default customization behavior.
///
/// Items with this behavior start in the toolbar and can be
/// moved or removed from the toolbar by the user.
public static var `default`: ToolbarCustomizationBehavior { get }
/// The reorderable customization behavior.
///
/// Items with this behavior start in the toolbar and can be moved within
/// the toolbar by the user, but can not be removed from the toolbar.
public static var reorderable: ToolbarCustomizationBehavior { get }
/// The disabled customization behavior.
///
/// Items with this behavior may not be removed or moved by the user.
/// They will be placed before other customizatable items. Use this
/// behavior for the most important items that users need for the app
/// to do common functionality.
public static var disabled: ToolbarCustomizationBehavior { get }
}
/// Options that influence the default customization behavior of
/// customizable toolbar content.
///
/// Use this type in conjunction with the
/// ``CustomizableToolbarContent/defaultCustomization(_:options:)`` modifier.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ToolbarCustomizationOptions : OptionSet, Sendable {
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
/// Configures default customizable toolbar content to always be
/// present in the toolbar.
///
/// In iOS, default customizable toolbar content have the option of always
/// being available in the toolbar regardless of the customization status
/// of the user. These items will always be in the overflow menu of the
/// toolbar. Users can customize whether the items are present as controls
/// in the toolbar itself but will still always be able to access the item
/// if they remove it from the toolbar itself.
///
/// Consider using this for items that users should always be able to
/// access, but may not be important enough to always occupy space in
/// the toolbar itself.
public static var alwaysAvailable: ToolbarCustomizationOptions { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = ToolbarCustomizationOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = ToolbarCustomizationOptions
}
/// A kind of toolbar item a `View` adds by default.
///
/// `View`s can add toolbar items clients may wish to remove or customize. A
/// default item kind can be passed to the ``View/toolbar(removing:)`` modifier
/// to remove the item. Documentation on the `View` placing the default item
/// should reference the `ToolbarDefaultItemKind` used to remove the item.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ToolbarDefaultItemKind {
/// The sidebar toggle toolbar item a `NavigationSplitView` adds by default.
public static let sidebarToggle: ToolbarDefaultItemKind
}
/// A model that represents an item which can be placed in the toolbar
/// or navigation bar.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ToolbarItem<ID, Content> : ToolbarContent where Content : View {
/// The type of content representing the body of this toolbar content.
public typealias Body = Never
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarItem where ID == () {
/// Creates a toolbar item with the specified placement and content.
///
/// - Parameters:
///   - placement: Which section of the toolbar
///     the item should be placed in.
///   - content: The content of the item.
public init(placement: ToolbarItemPlacement = .automatic, @ViewBuilder content: () -> Content)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarItem : CustomizableToolbarContent where ID == String {
/// Creates a toolbar item with the specified placement and content,
/// which allows for user customization.
///
/// - Parameters:
///   - id: A unique identifier for this item.
///   - placement: Which section of the toolbar
///     the item should be placed in.
///   - content: The content of the item.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public init(id: String, placement: ToolbarItemPlacement = .automatic, @ViewBuilder content: () -> Content)
/// Creates a toolbar item with the specified placement and content,
/// which allows for user customization.
///
/// - Parameters:
///   - id: A unique identifier for this item.
///   - placement: Which section of the toolbar
///     the item should be placed in.
///   - showsByDefault: Whether the item appears by default in the toolbar,
///     or only shows if the user explicitly adds it via customization.
///   - content: The content of the item.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use the CustomizableToolbarContent/defaultCustomization(_:options) modifier with a value of .hidden")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use the CustomizableToolbarContent/defaultCustomization(_:options) modifier with a value of .hidden")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Use the CustomizableToolbarContent/defaultCustomization(_:options) modifier with a value of .hidden")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use the CustomizableToolbarContent/defaultCustomization(_:options) modifier with a value of .hidden")
public init(id: String, placement: ToolbarItemPlacement = .automatic, showsByDefault: Bool, @ViewBuilder content: () -> Content)
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ToolbarItem : Identifiable where ID : Hashable {
/// The stable identity of the entity associated with this instance.
public var id: ID { get }
}
/// A model that represents a group of `ToolbarItem`s which can be placed in
/// the toolbar or navigation bar.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ToolbarItemGroup<Content> : ToolbarContent where Content : View {
/// Creates a toolbar item group with a specified placement and content.
///
/// - Parameters:
///  - placement: Which section of the toolbar all of its vended
///    `ToolbarItem`s should be placed in.
///  - content: The content of the group. Each view specified in the
///    `ViewBuilder` will be given its own `ToolbarItem` in the toolbar.
public init(placement: ToolbarItemPlacement = .automatic, @ViewBuilder content: () -> Content)
/// The type of content representing the body of this toolbar content.
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ToolbarItemGroup {
/// Creates a toolbar item group with the specified placement, content,
/// and a label describing that content.
///
/// A toolbar item group provided a label wraps its content within a
/// ``ControlGroup`` which allows the content to collapse down into a
/// menu that presents its content based on available space.
///
/// - Parameters:
///   - placement: Which section of the toolbar
///     the item should be placed in.
///   - content: The content of the item.
///   - label: The label describing the content of the item.
public init<C, L>(placement: ToolbarItemPlacement = .automatic, @ViewBuilder content: () -> C, @ViewBuilder label: () -> L) where Content == LabeledToolbarItemGroupContent<C, L>, C : View, L : View
}
/// A structure that defines the placement of a toolbar item.
///
/// There are two types of placements:
/// - Semantic placements, such as ``ToolbarItemPlacement/principal`` and
///   ``ToolbarItemPlacement/navigation``, denote the intent of the
///   item being added. SwiftUI determines the appropriate placement for
///   the item based on this intent and its surrounding context, like the
///   current platform.
/// - Positional placements, such as
///   ``ToolbarItemPlacement/navigationBarLeading``, denote a precise
///   placement for the item, usually for a particular platform.
///
/// In iOS, iPadOS, and macOS, the system uses the space available to the
/// toolbar when determining how many items to render in the toolbar. If not
/// all items fit in the available space, an overflow menu may be created
/// and remaining items placed in that menu.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct ToolbarItemPlacement {
/// The system places the item automatically, depending on many factors
/// including the platform, size class, or presence of other items.
///
/// In macOS and in Mac Catalyst apps, the system places items in the
/// current toolbar section in order of leading to trailing. On watchOS,
/// only the first item appears, pinned beneath the navigation bar.
///
/// In iPadOS, the system places items in the center of the navigation bar
/// if the navigation bar supports customization. Otherwise, it places
/// items in the trailing position of the navigation bar.
///
/// In iOS, and tvOS, the system places items in the trailing
/// position of the navigation bar.
///
/// In iOS, iPadOS, and macOS, the system uses the space available to the
/// toolbar when determining how many items to render in the toolbar. If not
/// all items fit in the available space, an overflow menu may be created
/// and remaining items placed in that menu.
public static let automatic: ToolbarItemPlacement
/// The system places the item in the principal item section.
///
/// Principal actions are key units of functionality that receive prominent
/// placement. For example, the location field for a web browser is a
/// principal item.
///
/// In macOS and in Mac Catalyst apps, the system places the principal item
/// in the center of the toolbar.
///
/// In iOS, iPadOS, and tvOS, the system places the principal item in the
/// center of the navigation bar. This item takes precedent over a title
/// specified through ``View/navigationTitle``.
@available(watchOS, unavailable)
public static let principal: ToolbarItemPlacement
/// The item represents a navigation action.
///
/// Navigation actions allow the user to move between contexts.
/// For example, the forward and back buttons of a web browser
/// are navigation actions.
///
/// In macOS and in Mac Catalyst apps, the system places navigation items
/// in the leading edge of the toolbar ahead of the inline title if that is
/// present in the toolbar.
///
/// In iOS, iPadOS, and tvOS, navigation items appear in the leading
/// edge of the navigation bar. If a system navigation item such as a back
/// button is present in a compact width, it instead appears in
/// the ``ToolbarItemPlacement/primaryAction`` placement.
@available(watchOS, unavailable)
public static let navigation: ToolbarItemPlacement
/// The item represents a primary action.
///
/// A primary action is a more frequently used action for the current
/// context. For example, a button the user clicks or taps to compose a new
/// message in a chat app.
///
/// In macOS and in Mac Catalyst apps, the location for the primary action
/// is the leading edge of the toolbar.
///
/// In iOS, iPadOS, and tvOS, the location for the primary action is
/// the trailing edge of the navigation bar.
///
/// In watchOS the system places the primary action beneath the
/// navigation bar; the user reveals the action by scrolling.
public static let primaryAction: ToolbarItemPlacement
/// The item represents a secondary action.
///
/// A secondary action is a frequently used action for the current context
/// but is not a requirement for the current context to function.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static let secondaryAction: ToolbarItemPlacement
/// The item represents a change in status for the current context.
///
/// Status items are informational in nature, and don't represent an
/// action that can be taken by the user. For example, a message that
/// indicates the time of the last communication with the server to check
/// for new messages.
///
/// In macOS and in Mac Catalyst apps, the system places status items in
/// the center of the toolbar.
///
/// In iOS and iPadOS, the system places status items in the center of the
/// bottom toolbar.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static let status: ToolbarItemPlacement
/// The item represents a confirmation action for a modal interface.
///
/// Use confirmation actions to receive user confirmation of a
/// particular action. An example of a confirmation action would be
/// an action with the label "Add" to add a new event to the calendar.
///
/// In macOS and in Mac Catalyst apps, the system places
/// `confirmationAction` items on the trailing edge
/// in the trailing-most position of the sheet and gain the apps accent
/// color as a background color.
///
/// In iOS, iPadOS, and tvOS, the system places `confirmationAction` items
/// in the same location as a ``ToolbarItemPlacement/primaryAction``
/// placement.
///
/// In watchOS, the system places `confirmationAction` items in the
/// trailing edge of the navigation bar.
public static let confirmationAction: ToolbarItemPlacement
/// The item represents a cancellation action for a modal interface.
///
/// Cancellation actions dismiss the modal interface without taking any
/// action, usually by tapping or clicking a Cancel button.
///
/// In macOS and in Mac Catalyst apps, the system places
/// `cancellationAction` items on the trailing edge of the sheet but
/// places them before any ``confirmationAction`` items.
///
/// In iOS, iPadOS, tvOS, and watchOS, the system places
/// `cancellationAction` items on the leading edge of the navigation bar.
public static let cancellationAction: ToolbarItemPlacement
/// The item represents a destructive action for a modal interface.
///
/// Destructive actions represent the opposite of a confirmation action.
/// For example, a button labeled "Don't Save" that allows the user to
/// discard unsaved changes to a document before quitting.
///
/// In macOS and in Mac Catalyst apps, the system places `destructiveAction`
/// items in the leading edge of the sheet and gives them a special
/// appearance to caution against accidental use.
///
/// In iOS, tvOS, and watchOS, the system places `destructiveAction` items
/// in the trailing edge of the navigation bar.
public static let destructiveAction: ToolbarItemPlacement
/// The item is placed in the keyboard section.
///
/// On iOS, keyboard items are above the software keyboard when present,
/// or at the bottom of the screen when a hardware keyboard is attached.
///
/// On macOS, keyboard items will be placed inside the Touch Bar.
///
/// A `FocusedValue`can be used to adjust the content of the keyboard bar
/// based on the currently focused view. In the example below, the keyboard
/// bar gains additional buttons only when the appropriate `TextField` is
/// focused.
///
///     enum Field {
///         case suit
///         case rank
///     }
///
///     struct KeyboardBarDemo : View {
///         @FocusedValue(\.field) var field: Field?
///
///         var body: some View {
///             HStack {
///                 TextField("Suit", text: $suitText)
///                     .focusedValue(\.field, .suit)
///                 TextField("Rank", text: $rankText)
///                     .focusedValue(\.field, .rank)
///             }
///             .toolbar {
///                 ToolbarItemGroup(placement: .keyboard) {
///                     if field == .suit {
///                         Button("♣️", action: {})
///                         Button("♥️", action: {})
///                         Button("♠️", action: {})
///                         Button("♦️", action: {})
///                     }
///                     DoneButton()
///                 }
///             }
///         }
///     }
///
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static let keyboard: ToolbarItemPlacement
/// Places the item in the leading edge of the top bar.
///
/// On watchOS, iOS, and tvOS, the top bar is the navigation bar.
@available(iOS 14.0, tvOS 14.0, watchOS 10.0, *)
@_backDeploy(before: iOS 17.0, tvOS 17.0)
@available(macOS, unavailable)
public static var topBarLeading: ToolbarItemPlacement { get }
/// Places the item in the trailing edge of the top bar.
///
/// On watchOS, iOS, and tvOS, the top bar is the navigation bar.
@available(iOS 14.0, tvOS 14.0, watchOS 10.0, *)
@_backDeploy(before: iOS 17.0, tvOS 17.0)
@available(macOS, unavailable)
public static var topBarTrailing: ToolbarItemPlacement { get }
/// Places the item in the leading edge of the navigation bar.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "use topBarLeading instead")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "use topBarLeading instead")
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use topBarLeading instead")
public static let navigationBarLeading: ToolbarItemPlacement
/// Places the item in the trailing edge of the navigation bar.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "use topBarTrailing instead")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "use topBarTrailing instead")
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use topBarTrailing instead")
public static let navigationBarTrailing: ToolbarItemPlacement
/// Places the item in the bottom toolbar.
@available(watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public static let bottomBar: ToolbarItemPlacement
}
/// The placement of a toolbar.
///
/// Use this type in conjunction with modifiers like
/// ``View/toolbarBackground(_:for:)-5ybst`` and ``View/toolbar(_:for:)`` to
/// customize the appearance of different bars managed by SwiftUI. Not all bars
/// support all types of customizations.
///
/// See ``ToolbarItemPlacement`` to learn about the different regions of these
/// toolbars that you can place your own controls into.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ToolbarPlacement {
/// The primary toolbar.
///
/// Depending on the context, this may refer to the navigation bar of an
/// app on iOS, or watchOS, the tab bar of an app on tvOS, or the window
/// toolbar of an app on macOS.
public static var automatic: ToolbarPlacement { get }
/// The bottom toolbar of an app.
@available(watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public static var bottomBar: ToolbarPlacement { get }
/// The navigation bar of an app.
@available(macOS, unavailable)
public static var navigationBar: ToolbarPlacement { get }
/// The tab bar of an app.
@available(macOS, unavailable)
@available(watchOS, unavailable)
public static var tabBar: ToolbarPlacement { get }
}
/// The purpose of content that populates the toolbar.
///
/// A toolbar role provides a description of the purpose of content that
/// populates the toolbar. The purpose of the content influences how a toolbar
/// renders its content. For example, a ``ToolbarRole/browser`` will
/// automatically leading align the title of a toolbar in iPadOS.
///
/// Provide this type to the ``View/toolbarRole(_:)`` modifier:
///
///     ContentView()
///         .navigationTitle("Browser")
///         .toolbarRole(.browser)
///         .toolbar {
///             ToolbarItem(placement: .primaryAction) {
///                 AddButton()
///             }
///          }
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ToolbarRole : Sendable {
/// The automatic role.
///
/// In iOS, tvOS, and watchOS this resolves to the
/// ``ToolbarRole/navigationStack`` role. In macOS, this resolves to the
/// ``ToolbarRole/editor`` role.
public static var automatic: ToolbarRole { get }
/// The navigationStack role.
///
/// Use this role for content that can be pushed and popped.
@available(macOS, unavailable)
public static var navigationStack: ToolbarRole { get }
/// The browser role.
///
/// Use this role for content that can be navigated forwards
/// and backwards. In iPadOS, this will leading align the navigation title
/// and allow for toolbar items to occupy the center of the navigation bar.
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static var browser: ToolbarRole { get }
/// The editor role.
///
/// Use this role for a toolbar that primarily displays controls
/// geared towards editing document-like content. In iPadOS, this will
/// leading align the navigation title, allow for toolbar items to occupy
/// the center of the navigation bar, and provide a custom appearance
/// for any back button present in the toolbar.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static var editor: ToolbarRole { get }
}
/// A type that defines the behavior of title of a toolbar.
///
/// Use the ``View/toolbarTitleDisplayMode(_:)`` modifier to configure
/// the title display behavior of your toolbar:
///
///     NavigationStack {
///         ContentView()
///             .toolbarTitleDisplayMode(.inlineLarge)
///     }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ToolbarTitleDisplayMode {
/// The automatic mode.
///
/// For root content in a navigation stack in iOS, iPadOS, or tvOS
/// this behavior will:
///   - Default to ``ToolbarTitleDisplayMode/large``
///     when a navigation title is configured.
///   - Default to ``ToolbarTitleDisplayMode/inline``
///     when no navigation title is provided.
///
/// In all platforms, content pushed onto a navigation stack will use the
/// behavior of the content already on the navigation stack. This
/// has no effect in macOS.
public static var automatic: ToolbarTitleDisplayMode { get }
/// The large mode.
///
/// In iOS, and watchOS, this displays the toolbar title below the
/// content of the navigation bar when scrollable content is scrolled
/// to the top and transitions to the center of the toolbar as
/// content is scrolled.
@available(macOS, unavailable)
@available(tvOS, unavailable)
public static var large: ToolbarTitleDisplayMode { get }
/// The inline large mode.
///
/// In iOS, this behavior displays the title as large inside the toolbar
/// and moves any leading or centered toolbar items into the overflow menu
/// of the toolbar. This has no effect in macOS.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static var inlineLarge: ToolbarTitleDisplayMode { get }
/// The inline mode.
///
/// In iOS, tvOS, and watchOS this mode displays the title with a
/// smaller size in the middle of the toolbar. This has no effect
/// in macOS.
public static var inline: ToolbarTitleDisplayMode { get }
}
/// The title menu of a toolbar.
///
/// A title menu represents common functionality that can be done on the
/// content represented by your app's toolbar or navigation title. This
/// menu may be populated from your app's commands like
/// ``CommandGroupPlacement/saveItem`` or
/// ``CommandGroupPlacement/printItem``.
///
///     ContentView()
///         .toolbar {
///             ToolbarTitleMenu()
///         }
///
/// You can provide your own set of actions to override this behavior.
///
///     ContentView()
///         .toolbar {
///             ToolbarTitleMenu {
///                 DuplicateButton()
///                 PrintButton()
///             }
///         }
///
/// In iOS and iPadOS, this will construct a menu that can be presented by
/// tapping the navigation title in the app's navigation bar.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
public struct ToolbarTitleMenu<Content> : ToolbarContent, CustomizableToolbarContent where Content : View {
/// Creates a toolbar title menu where actions are inferred from your
/// apps commands.
public init() where Content == EmptyView
/// Creates a toolbar title menu.
///
/// - Parameter content: The content of the toolbar title menu.
public init(@ViewBuilder content: () -> Content)
/// The type of content representing the body of this toolbar content.
public typealias Body = Never
}
/// The context of the current state-processing update.
///
/// Use a transaction to pass an animation between views in a view hierarchy.
///
/// The root transaction for a state change comes from the binding that changed,
/// plus any global values set by calling ``withTransaction(_:_:)`` or
/// ``withAnimation(_:_:)``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct Transaction {
/// Creates a transaction.
@inlinable public init()
/// Accesses the transaction value associated with a custom key.
///
/// Create custom transaction values by defining a key that conforms to the
/// ``TransactionKey`` protocol, and then using that key with the subscript
/// operator of the ``Transaction`` structure to get and set a value for
/// that key:
///
///     private struct MyTransactionKey: TransactionKey {
///         static let defaultValue = false
///     }
///
///     extension Transaction {
///         var myCustomValue: Bool {
///             get { self[MyTransactionKey.self] }
///             set { self[MyTransactionKey.self] = newValue }
///         }
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public subscript<K>(key: K.Type) -> K.Value where K : TransactionKey
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Transaction {
/// The behavior for how windows will dismiss programmatically when used in
/// conjunction with ``DismissWindowAction``.
///
/// The default value is `.interactive`.
///
/// You can use this property to dismiss windows which may be showing a
/// modal presentation by using the `.destructive` value:
///
///     struct DismissWindowButton: View {
///         @Environment(\.dismissWindow) private var dismissWindow
///
///         var body: some View {
///             Button("Close Auxiliary Window") {
///                 withTransaction(\.dismissBehavior, .destructive) {
///                     dismissWindow(id: "auxiliary")
///                 }
///             }
///         }
///     }
public var dismissBehavior: DismissBehavior
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transaction {
/// Adds a completion to run when the animations created with this
/// transaction are all complete.
///
/// The completion callback will always be fired exactly one time. If no
/// animations are created by the changes in `body`, then the callback will
/// be called immediately after `body`.
public mutating func addAnimationCompletion(criteria: AnimationCompletionCriteria = .logicallyComplete, _ completion: @escaping () -> Void)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Transaction {
/// A Boolean value that indicates whether the transaction originated from
/// an action that produces a sequence of values.
///
/// This value is `true` if a continuous action created the transaction, and
/// is `false` otherwise. Continuous actions include things like dragging a
/// slider or pressing and holding a stepper, as opposed to tapping a
/// button.
public var isContinuous: Bool
}
extension Transaction {
/// The preferred alignment of the view within a scroll view's visible
/// region when scrolling to a view.
///
/// Use this API in conjunction with a
/// ``ScrollViewProxy/scrollTo(_:anchor)`` or when updating the binding
/// provided to a ``View/scrollPosition(id:anchor:)``.
///
///     @Binding var position: Item.ID?
///
///     var body: some View {
///         ScrollView {
///             LazyVStack {
///                 ForEach(items) { item in
///                     ItemView(item)
///                 }
///             }
///             .scrollTargetLayout()
///         }
///         .scrollPosition(id: $position)
///         .safeAreaInset(edge: .bottom) {
///             Button("Scroll To Bottom") {
///                 withAnimation {
///                     withTransaction(\.scrollTargetAnchor, .bottom) {
///                         position = items.last?.id
///                     }
///                 }
///             }
///         }
///     }
///
/// When used with the ``View/scrollPosition(id:anchor:)`` modifier,
/// this value will be preferred over the anchor specified in the
/// modifier for the current transaction.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var scrollTargetAnchor: UnitPoint?
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transaction {
/// Whether this transaction will track the velocity of any animatable
/// properties that change.
///
/// This property can be enabled in an interactive context to track velocity
/// during a user interaction so that when the interaction ends, an
/// animation can use the accumulated velocities to create animations that
/// preserve them. This tracking is mutually exclusive with an animation
/// being used during a view change, since if there is an animation, it is
/// responsible for managing its own velocity.
///
/// Gesture onChanged and updating callbacks automatically set this property
/// to true.
///
/// This example shows an interaction which applies changes, tracking
/// velocity until the final change, which applies an animation (which will
/// start with the velocity that was tracked during the previous changes).
/// These changes could come from a server or from an interactive control
/// like a slider.
///
///     func receiveChange(change: ChangeInfo) {
///         var transaction = Transaction()
///         if change.isFinal {
///             transaction.animation = .spring
///         } else {
///             transaction.tracksVelocity = true
///         }
///         withTransaction(transaction) {
///             state.applyChange(change)
///         }
///     }
public var tracksVelocity: Bool
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Transaction {
/// Creates a transaction and assigns its animation property.
///
/// - Parameter animation: The animation to perform when the current state
///   changes.
public init(animation: Animation?)
/// The animation, if any, associated with the current state change.
public var animation: Animation?
/// A Boolean value that indicates whether views should disable animations.
///
/// This value is `true` during the initial phase of a two-part transition
/// update, to prevent ``View/animation(_:)`` from inserting new animations
/// into the transaction.
public var disablesAnimations: Bool
}
/// A key for accessing values in a transaction.
///
/// You can create custom transaction values by extending the ``Transaction``
/// structure with new properties.
/// First declare a new transaction key type and specify a value for the
/// required ``defaultValue`` property:
///
///     private struct MyTransactionKey: TransactionKey {
///         static let defaultValue = false
///     }
///
/// The Swift compiler automatically infers the associated ``Value`` type as the
/// type you specify for the default value. Then use the key to define a new
/// transaction value property:
///
///     extension Transaction {
///         var myCustomValue: Bool {
///             get { self[MyTransactionKey.self] }
///             set { self[MyTransactionKey.self] = newValue }
///         }
///     }
///
/// Clients of your transaction value never use the key directly.
/// Instead, they use the key path of your custom transaction value property.
/// To set the transaction value for a change, wrap that change in a call to
/// `withTransaction`:
///
///     withTransaction(\.myCustomValue, true) {
///         isActive.toggle()
///     }
///
/// To set it for a view and all its subviews, add the
/// ``View/transaction(value:_:)`` view modifier to that view:
///
///     MyView()
///         .transaction(\.myCustomValue, true)
///
/// To use the value from inside `MyView` or one of its descendants, use the
/// ``View/transaction(_:)`` view modifier:
///
///     MyView()
///         .transaction { transaction in
///             if transaction.myCustomValue {
///                 transaction.animation = .default.repeatCount(3)
///             }
///         }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol TransactionKey {
/// The associated type representing the type of the transaction key's
/// value.
associatedtype Value
/// The default value for the transaction key.
static var defaultValue: Self.Value { get }
}
/// A shape with an affine transform applied to it.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct TransformedShape<Content> : Shape where Content : Shape {
public var shape: Content
public var transform: CGAffineTransform
@inlinable public init(shape: Content, transform: CGAffineTransform)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// An indication of how to style a shape.
///
/// SwiftUI looks at a shape's role when deciding how to apply a
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a
/// default implementation with a value of ``ShapeRole/fill``. If you
/// create a composite shape, you can provide an override of this property
/// to return another value, if appropriate.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public static var role: ShapeRole { get }
/// Returns the behavior this shape should use for different layout
/// directions.
///
/// If the layoutDirectionBehavior for a Shape is one that mirrors, the
/// shape's path will be mirrored horizontally when in the specified layout
/// direction. When mirrored, the individual points of the path will be
/// transformed.
///
/// Defaults to `.mirrors` when deploying on iOS 17.0, macOS 14.0,
/// tvOS 17.0, watchOS 10.0 and later, and to `.fixed` if not.
/// To mirror a path when deploying to earlier releases, either use
/// `View.flipsForRightToLeftLayoutDirection` for a filled or stroked
/// shape or conditionally mirror the points in the path of the shape.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public var layoutDirectionBehavior: LayoutDirectionBehavior { get }
/// The type defining the data to animate.
public typealias AnimatableData = Content.AnimatableData
/// The data to animate.
public var animatableData: TransformedShape<Content>.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
/// A description of view changes to apply when a view is added to and removed
/// from the view hierarchy.
///
/// A transition should generally be made by applying one or more modifiers to
/// the `content`. For symmetric transitions, the `isIdentity` property on
/// `phase` can be used to change the properties of modifiers. For asymmetric
/// transitions, the phase itself can be used to change those properties.
/// Transitions should not use any identity-affecting changes like `.id`, `if`,
/// and `switch` on the `content`, since doing so would reset the state of the
/// view they're applied to, causing wasted work and potentially surprising
/// behavior when it appears and disappears.
///
/// The following code defines a transition that can be used to change the
/// opacity and rotation when a view appears and disappears.
///
///     struct RotatingFadeTransition: Transition {
///         func body(content: Content, phase: TransitionPhase) -> some View {
///             content
///               .opacity(phase.isIdentity ? 1.0 : 0.0)
///               .rotationEffect(phase.rotation)
///         }
///     }
///     extension TransitionPhase {
///         fileprivate var rotation: Angle {
///             switch self {
///             case .willAppear: return .degrees(30)
///             case .identity: return .zero
///             case .didDisappear: return .degrees(-30)
///             }
///         }
///     }
///
/// - See Also: `TransitionPhase`
/// - See Also: `AnyTransition`
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol Transition {
/// The type of view representing the body.
associatedtype Body : View
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
@ViewBuilder func body(content: Self.Content, phase: TransitionPhase) -> Self.Body
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
static var properties: TransitionProperties { get }
/// The content view type passed to `body()`.
typealias Content = PlaceholderContentView<Self>
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == SlideTransition {
/// A transition that inserts by moving in from the leading edge, and
/// removes by moving out towards the trailing edge.
///
/// - SeeAlso: `AnyTransition.move(edge:)`
public static var slide: SlideTransition { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == SymbolEffectTransition {
/// Creates a transition that applies the provided effect to symbol
/// images within the inserted or removed view hierarchy. Other
/// views are unaffected by this transition.
///
/// - Parameter effect: the symbol effect value.
///
/// - Returns: a new transition.
public static func symbolEffect<T>(_ effect: T, options: SymbolEffectOptions = .default) -> SymbolEffectTransition where T : SymbolEffect, T : TransitionSymbolEffect
/// A transition that applies the default symbol effect transition
/// to symbol images within the inserted or removed view hierarchy.
/// Other views are unaffected by this transition.
public static var symbolEffect: SymbolEffectTransition { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == PushTransition {
/// Creates a transition that when added to a view will animate the
/// view's insertion by moving it in from the specified edge while
/// fading it in, and animate its removal by moving it out towards
/// the opposite edge and fading it out.
///
/// - Parameters:
///   - edge: the edge from which the view will be animated in.
///
/// - Returns: A transition that animates a view by moving and
///   fading it.
public static func push(from edge: Edge) -> Self
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == OffsetTransition {
/// Returns a transition that offset the view by the specified amount.
public static func offset(_ offset: CGSize) -> Self
/// Returns a transition that offset the view by the specified x and y
/// values.
public static func offset(x: CGFloat = 0, y: CGFloat = 0) -> Self
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == ScaleTransition {
/// Returns a transition that scales the view.
public static var scale: ScaleTransition { get }
/// Returns a transition that scales the view by the specified amount.
public static func scale(_ scale: Double, anchor: UnitPoint = .center) -> Self
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == OpacityTransition {
/// A transition from transparent to opaque on insertion, and from opaque to
/// transparent on removal.
public static var opacity: OpacityTransition { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition {
public func combined<T>(with other: T) -> some Transition where T : Transition
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition {
/// Returns the properties this transition type has.
///
/// Defaults to `TransitionProperties()`.
public static var properties: TransitionProperties { get }
public func apply<V>(content: V, phase: TransitionPhase) -> some View where V : View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == IdentityTransition {
/// A transition that returns the input view, unmodified, as the output
/// view.
public static var identity: IdentityTransition { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition where Self == MoveTransition {
/// Returns a transition that moves the view away, towards the specified
/// edge of the view.
public static func move(edge: Edge) -> Self
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Transition {
/// Attaches an animation to this transition.
public func animation(_ animation: Animation?) -> some Transition
}
/// An indication of which the current stage of a transition.
///
/// When a view is appearing with a transition, the transition will first be
/// shown with the `willAppear` phase, then will be immediately moved to the
/// `identity` phase. When a view is being removed, its transition is changed
/// from the `identity` phase to the `didDisappear` phase. If a view is removed
/// while it is still transitioning in, then its phase will change to
/// `didDisappear`. If a view is re-added while it is transitioning out, its
/// phase will change back to `identity`.
///
/// In the `identity` phase, transitions should generally not make any visual
/// change to the view they are applied to, since the transition's view
/// modifications in the `identity` phase will be applied to the view as long as
/// it is visible. In the `willAppear` and `didDisappear` phases, transitions
/// should apply a change that will be animated to create the transition. If no
/// animatable change is applied, then the transition will be a no-op.
///
/// - See Also: `Transition`
/// - See Also: `AnyTransition`
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@frozen public enum TransitionPhase {
/// The transition is being applied to a view that is about to be inserted
/// into the view hierarchy.
///
/// In this phase, a transition should show the appearance that will be
/// animated from to make the appearance transition.
case willAppear
/// The transition is being applied to a view that is in the view hierarchy.
///
/// In this phase, a transition should show its steady state appearance,
/// which will generally not make any visual change to the view.
case identity
/// The transition is being applied to a view that has been requested to be
/// removed from the view hierarchy.
///
/// In this phase, a transition should show the appearance that will be
/// animated to to make the disappearance transition.
case didDisappear
/// A Boolean that indicates whether the transition should have an identity
/// effect, i.e. not change the appearance of its view.
///
/// This is true in the `identity` phase.
public var isIdentity: Bool { get }
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TransitionPhase, b: TransitionPhase) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension TransitionPhase {
/// A value that can be used to multiply effects that are applied
/// differently depending on the phase.
///
/// - Returns: Zero when in the `identity` case, -1.0 for `willAppear`,
///   and 1.0 for `didDisappear`.
public var value: Double { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension TransitionPhase : Equatable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension TransitionPhase : Hashable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension TransitionPhase : Sendable {
}
/// The properties a `Transition` can have.
///
/// A transition can have properties that specify high level information about
/// it. This can determine how a transition interacts with other features like
/// Accessibility settings.
///
/// - See Also: `Transition`
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct TransitionProperties : Sendable {
public init(hasMotion: Bool = true)
/// Whether the transition includes motion.
///
/// When this behavior is included in a transition, that transition will be
/// replaced by opacity when Reduce Motion is enabled.
///
/// Defaults to `true`.
public var hasMotion: Bool
}
/// A type of table column content that creates table columns created from a
/// Swift tuple of table columns.
///
/// Don't use this type directly; instead, SwiftUI uses this type as the return value
/// from the various `buildBlock` methods in ``TableColumnBuilder``. The size of
/// the tuple corresponds to how many columns you create in the `columns`
/// closure you provide to the ``Table`` initializer.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@frozen public struct TupleTableColumnContent<RowValue, Sort, T> : TableColumnContent where RowValue : Identifiable, Sort : SortComparator {
/// The type of value of rows presented by this column content.
public typealias TableRowValue = RowValue
/// The type of sort comparator associated with this table column content.
public typealias TableColumnSortComparator = Sort
/// The value of a row presented by this column content.
public var value: T
/// The type of content representing the body of this table column content.
public typealias TableColumnBody = Never
}
/// A type of table column content that creates table rows created from a
/// Swift tuple of table rows.
///
/// Don't use this type directly; instead, SwiftUI uses this type as the return value
/// from the various `buildBlock` methods in ``TableRowBuilder``. The size of
/// the tuple corresponds to how many columns you create in the `rows`
/// closure you provide to the ``Table`` initializer.
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@frozen public struct TupleTableRowContent<Value, T> : TableRowContent where Value : Identifiable {
/// The type of value represented by this table row content.
public typealias TableRowValue = Value
public var value: T
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
}
/// A View created from a swift tuple of View values.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct TupleView<T> : View {
public var value: T
@inlinable public init(_ value: T)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// Defines how typesetting language is determined for text.
///
/// Use a modifier like ``View/typesettingLanguage(_:isEnabled:)-4ldzm``
/// to specify the typesetting language.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct TypesettingLanguage : Sendable, Equatable {
/// Automatic language behavior.
///
/// When determining the language to use for typesetting the current UI
/// language and preferred languages will be considiered. For example, if
/// the current UI locale is for English and Thai is included in the
/// preferred languages then line heights will be taller to accommodate the
/// taller glyphs used by Thai.
public static let automatic: TypesettingLanguage
/// Use explicit language.
///
/// An explicit language will be used for typesetting. For example, if used
/// with Thai language the line heights will be as tall as needed to
/// accommodate Thai.
///
/// - Parameters:
///   - language: The language to use for typesetting.
/// - Returns: A `TypesettingLanguage`.
public static func explicit(_ language: Locale.Language) -> TypesettingLanguage
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: TypesettingLanguage, b: TypesettingLanguage) -> Bool
}
/// A property wrapper type that you use to create a UIKit app delegate.
///
/// To handle app delegate callbacks in an app that uses the
/// SwiftUI life cycle, define a type that conforms to the
/// <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate>
/// protocol, and implement the delegate methods that you need. For example,
/// you can implement the
/// <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/1622958-application>
/// method to handle remote notification registration:
///
///     class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
///         func application(
///             _ application: UIApplication,
///             didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
///         ) {
///             // Record the device token.
///         }
///     }
///
/// Then use the `UIApplicationDelegateAdaptor` property wrapper inside your
/// ``App`` declaration to tell SwiftUI about the delegate type:
///
///     @main
///     struct MyApp: App {
///         @UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate
///
///         var body: some Scene { ... }
///     }
///
/// SwiftUI instantiates the delegate and calls the delegate's
/// methods in response to life cycle events. Define the delegate adaptor
/// only in your ``App`` declaration, and only once for a given app. If
/// you declare it more than once, SwiftUI generates a runtime error.
///
/// If your app delegate conforms to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol, as in the example above, then SwiftUI puts the delegate it
/// creates into the ``Environment``. You can access the delegate from
/// any scene or view in your app using the ``EnvironmentObject`` property
/// wrapper:
///
///     @EnvironmentObject private var appDelegate: MyAppDelegate
///
/// This enables you to use the dollar sign (`$`) prefix to get a binding to
/// published properties that you declare in the delegate. For more information,
/// see ``projectedValue``.
///
/// > Important: Manage an app's life cycle events without using an app
/// delegate whenever possible. For example, prefer to handle changes
/// in ``ScenePhase`` instead of relying on delegate callbacks, like
/// <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/1622921-application>.
///
/// ### Scene delegates
///
/// Some iOS apps define a
/// <doc://com.apple.documentation/documentation/UIKit/UIWindowSceneDelegate>
/// to handle scene-based events, like app shortcuts:
///
///     class MySceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
///         func windowScene(
///             _ windowScene: UIWindowScene,
///             performActionFor shortcutItem: UIApplicationShortcutItem
///         ) async -> Bool {
///             // Do something with the shortcut...
///
///             return true
///         }
///     }
///
/// You can provide this kind of delegate to a SwiftUI app by returning the
/// scene delegate's type from the
/// <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/3197905-application>
/// method inside your app delegate:
///
///     extension MyAppDelegate {
///         func application(
///             _ application: UIApplication,
///             configurationForConnecting connectingSceneSession: UISceneSession,
///             options: UIScene.ConnectionOptions
///         ) -> UISceneConfiguration {
///
///             let configuration = UISceneConfiguration(
///                                     name: nil,
///                                     sessionRole: connectingSceneSession.role)
///             if connectingSceneSession.role == .windowApplication {
///                 configuration.delegateClass = MySceneDelegate.self
///             }
///             return configuration
///         }
///     }
///
/// When you configure the
/// <doc://com.apple.documentation/documentation/UIKit/UISceneConfiguration>
/// instance, you only need to indicate the delegate class, and not a scene
/// class or storyboard. SwiftUI creates and manages the delegate instance,
/// and sends it any relevant delegate callbacks.
///
/// As with the app delegate, if you make your scene delegate an observable
/// object, SwiftUI automatically puts it in the ``Environment``, from where
/// you can access it with the ``EnvironmentObject`` property wrapper, and
/// create bindings to its published properties.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor @propertyWrapper public struct UIApplicationDelegateAdaptor<DelegateType> : DynamicProperty where DelegateType : NSObject, DelegateType : UIApplicationDelegate {
/// The underlying app delegate.
@MainActor public var wrappedValue: DelegateType { get }
/// Creates a UIKit app delegate adaptor.
///
/// Call this initializer indirectly by creating a property with the
/// ``UIApplicationDelegateAdaptor`` property wrapper from inside your
/// ``App`` declaration:
///
///     @main
///     struct MyApp: App {
///         @UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate
///
///         var body: some Scene { ... }
///     }
///
/// SwiftUI initializes the delegate and manages its lifetime, calling upon
/// it to handle application delegate callbacks.
///
/// If you want SwiftUI to put the instantiated delegate in the
/// ``Environment``, make sure the delegate class also conforms to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol. That causes SwiftUI to invoke the ``init(_:)-8vsx1``
/// initializer rather than this one.
///
/// - Parameter delegateType: The type of application delegate that you
///   define in your app, which conforms to the
///   <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate>
///   protocol.
@MainActor public init(_ delegateType: DelegateType.Type = DelegateType.self)
}
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIApplicationDelegateAdaptor where DelegateType : ObservableObject {
/// Creates a UIKit app delegate adaptor using a delegate that's
/// an observable object.
///
/// Call this initializer indirectly by creating a property with the
/// ``UIApplicationDelegateAdaptor`` property wrapper from inside your
/// ``App`` declaration:
///
///     @main
///     struct MyApp: App {
///         @UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate
///
///         var body: some Scene { ... }
///     }
///
/// SwiftUI initializes the delegate and manages its lifetime, calling it
/// as needed to handle application delegate callbacks.
///
/// SwiftUI invokes this method when your app delegate conforms to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol. In this case, SwiftUI automatically places the delegate in the
/// ``Environment``. You can access such a delegate from any scene or
/// view in your app using the ``EnvironmentObject`` property wrapper:
///
///     @EnvironmentObject private var appDelegate: MyAppDelegate
///
/// If your delegate isn't an observable object, SwiftUI invokes the
/// ``init(_:)-59sfu`` initializer rather than this one, and doesn't
/// put the delegate instance in the environment.
///
/// - Parameter delegateType: The type of application delegate that you
///   define in your app, which conforms to the
///   <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate>
///   and
///   <doc://com.apple.documentation/documentation/Combine/ObservableObject>
///   protocols.
@MainActor public init(_ delegateType: DelegateType.Type = DelegateType.self)
/// A projection of the observed object that provides bindings to its
/// properties.
///
/// Use the projected value to get a binding to a value that the delegate
/// publishes. Access the projected value by prefixing the name of the
/// delegate instance with a dollar sign (`$`). For example, you might
/// publish a Boolean value in your application delegate:
///
///     class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
///         @Published var isEnabled = false
///
///         // ...
///     }
///
/// If you declare the delegate in your ``App`` using the
/// ``UIApplicationDelegateAdaptor`` property wrapper, you can get
/// the delegate that SwiftUI instantiates from the environment and
/// access a binding to its published values from any view in your app:
///
///     struct MyView: View {
///         @EnvironmentObject private var appDelegate: MyAppDelegate
///
///         var body: some View {
///             Toggle("Enabled", isOn: $appDelegate.isEnabled)
///         }
///     }
///
@MainActor public var projectedValue: ObservedObject<DelegateType>.Wrapper { get }
}
@available(iOS 17.0, tvOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIApplicationDelegateAdaptor where DelegateType : Observable {
/// Creates a UIKit app delegate adaptor using an observable delegate.
///
/// Call this initializer indirectly by creating a property with the
/// ``UIApplicationDelegateAdaptor`` property wrapper from inside your
/// ``App`` declaration:
///
///     @main
///     struct MyApp: App {
///         @UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate
///
///         var body: some Scene { ... }
///     }
///
/// SwiftUI initializes the delegate and manages its lifetime, calling it
/// as needed to handle application delegate callbacks.
///
/// SwiftUI invokes this method when your app delegate conforms to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol. In this case, SwiftUI automatically places the delegate in the
/// ``Environment``. You can access such a delegate from any scene or
/// view in your app using the ``Environment`` property wrapper:
///
///     @Environment(MyAppDelegate.self) private var appDelegate
///
/// If your delegate isn't observable, SwiftUI invokes the
/// ``init(_:)-59sfu`` initializer rather than this one, and doesn't
/// put the delegate instance in the environment.
///
/// - Parameter delegateType: The type of application delegate that you
///   define in your app, which conforms to the
///   <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate>
///   and
///   <doc://com.apple.documentation/documentation/Observation/Observable>
///   protocols.
@MainActor public init(_ delegateType: DelegateType.Type = DelegateType.self)
}
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIApplicationDelegateAdaptor : Sendable {
}
/// A content configuration suitable for hosting a hierarchy of SwiftUI views.
///
/// Use a value of this type, which conforms to the
/// <doc://com.apple.documentation/documentation/UIKit/UIContentConfiguration>
/// protocol, with a
/// <doc://com.apple.documentation/documentation/UIKit/UICollectionViewCell> or
/// <doc://com.apple.documentation/documentation/UIKit/UITableViewCell> to host
/// a hierarchy of SwiftUI views in a collection or table view, respectively.
/// For example, the following shows a stack with an image and text inside the
/// cell:
///
///     myCell.contentConfiguration = UIHostingConfiguration {
///         HStack {
///             Image(systemName: "star").foregroundStyle(.purple)
///             Text("Favorites")
///             Spacer()
///         }
///     }
///
/// You can also customize the background of the containing cell. The following
/// example draws a blue background:
///
///     myCell.contentConfiguration = UIHostingConfiguration {
///         HStack {
///             Image(systemName: "star").foregroundStyle(.purple)
///             Text("Favorites")
///             Spacer()
///         }
///     }
///     .background {
///         Color.blue
///     }
///
/// When used in a list layout, certain APIs are bridged automatically, like
/// swipe actions and separator alignment. The following example shows a
/// trailing yellow star swipe action:
///
///     cell.contentConfiguration = UIHostingConfiguration {
///         HStack {
///             Image(systemName: "airplane")
///             Text("Flight 123")
///             Spacer()
///         }
///         .swipeActions {
///             Button { ... } label: {
///                 Label("Favorite", systemImage: "star")
///             }
///             .tint(.yellow)
///         }
///     }
///
@available(iOS 16.0, tvOS 16.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public struct UIHostingConfiguration<Content, Background> : UIContentConfiguration where Content : View, Background : View {
/// Sets the background contents for the hosting configuration's enclosing
/// cell.
///
/// The following example sets a custom view to the background of the cell:
///
///     UIHostingConfiguration {
///         Text("My Contents")
///     }
///     .background {
///         MyBackgroundView()
///     }
///
/// - Parameter background: The contents of the SwiftUI hierarchy to be
///   shown inside the background of the cell.
public func background<B>(@ViewBuilder content: () -> B) -> UIHostingConfiguration<Content, B> where B : View
/// Sets the background contents for the hosting configuration's enclosing
/// cell.
///
/// The following example sets a custom view to the background of the cell:
///
///     UIHostingConfiguration {
///         Text("My Contents")
///     }
///     .background(Color.blue)
///
/// - Parameter style: The shape style to be used as the background of the
///   cell.
public func background<S>(_ style: S) -> UIHostingConfiguration<Content, _UIHostingConfigurationBackgroundView<S>> where S : ShapeStyle
/// Sets the margins around the content of the configuration.
///
/// Use this modifier to replace the default margins applied to the root of
/// the configuration. The following example creates 20 points of space
/// between the content and the background on the horizontal edges.
///
///     UIHostingConfiguration {
///         Text("My Contents")
///     }
///     .margins(.horizontal, 20.0)
///
/// - Parameters:
///    - edges: The edges to apply the insets. Any edges not specified will
///      use the system default values. The default value is
///      ``Edge/Set/all``.
///    - length: The amount to apply.
public func margins(_ edges: Edge.Set = .all, _ length: CGFloat) -> UIHostingConfiguration<Content, Background>
/// Sets the margins around the content of the configuration.
///
/// Use this modifier to replace the default margins applied to the root of
/// the configuration. The following example creates 10 points of space
/// between the content and the background on the leading edge and 20 points
/// of space on the trailing edge:
///
///     UIHostingConfiguration {
///         Text("My Contents")
///     }
///     .margins(.horizontal, 20.0)
///
/// - Parameters:
///    - edges: The edges to apply the insets. Any edges not specified will
///      use the system default values. The default value is
///      ``Edge/Set/all``.
///    - insets: The insets to apply.
public func margins(_ edges: Edge.Set = .all, _ insets: EdgeInsets) -> UIHostingConfiguration<Content, Background>
/// Sets the minimum size for the configuration.
///
/// Use this modifier to indicate that a configuration's associated cell can
/// be resized to a specific minimum. The following example allows the cell
/// to be compressed to zero size:
///
///     UIHostingConfiguration {
///         Text("My Contents")
///     }
///     .minSize(width: 0, height: 0)
///
/// - Parameter width: The value to use for the width dimension. A value of
///   `nil` indicates that the system default should be used.
/// - Parameter height: The value to use for the height dimension. A value
///   of `nil` indicates that the system default should be used.
public func minSize(width: CGFloat? = nil, height: CGFloat? = nil) -> UIHostingConfiguration<Content, Background>
/// Sets the minimum size for the configuration.
///
/// Use the version with parameters instead.
@available(*, deprecated, message: "Please pass one or more parameters.")
public func minSize() -> UIHostingConfiguration<Content, Background>
@MainActor public func makeContentView() -> UIView & UIContentView
public func updated(for state: UIConfigurationState) -> UIHostingConfiguration<Content, Background>
}
@available(iOS 16.0, tvOS 16.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIHostingConfiguration where Background == EmptyView {
/// Creates a hosting configuration with the given contents.
///
/// - Parameter content: The contents of the SwiftUI hierarchy to be shown
///   inside the cell.
public init(@ViewBuilder content: () -> Content)
}
/// A UIKit view controller that manages a SwiftUI view hierarchy.
///
/// Create a `UIHostingController` object when you want to integrate SwiftUI
/// views into a UIKit view hierarchy. At creation time, specify the SwiftUI
/// view you want to use as the root view for this view controller; you can
/// change that view later using the ``SwiftUI/UIHostingController/rootView``
/// property. Use the hosting controller like you would any other view
/// controller, by presenting it or embedding it as a child view controller
/// in your interface.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor open class UIHostingController<Content> : UIViewController where Content : View {
@MainActor override dynamic open var undoManager: UndoManager? { get }
@MainActor override dynamic open var keyCommands: [UIKeyCommand]? { get }
/// Creates a hosting controller object that wraps the specified SwiftUI
/// view.
///
/// - Parameter rootView: The root view of the SwiftUI view hierarchy that
///   you want to manage using the hosting view controller.
///
/// - Returns: A `UIHostingController` object initialized with the
///   specified SwiftUI view.
@MainActor public init(rootView: Content)
/// Creates a hosting controller object from an archive and the specified
/// SwiftUI view.
/// - Parameters:
///   - coder: The decoder to use during initialization.
///   - rootView: The root view of the SwiftUI view hierarchy that you want
///     to manage using this view controller.
///
/// - Returns: A `UIViewController` object that you can present from your
///   interface.
@MainActor public init?(coder aDecoder: NSCoder, rootView: Content)
/// Creates a hosting controller object from the contents of the specified
/// archive.
///
/// The default implementation of this method throws an exception. To create
/// your view controller from an archive, override this method and
/// initialize the superclass using the ``init(coder:rootView:)`` method
/// instead.
///
/// -Parameter coder: The decoder to use during initialization.
@MainActor required dynamic public init?(coder aDecoder: NSCoder)
@MainActor override dynamic open func loadView()
/// Notifies the view controller that its view is about to be added to a
/// view hierarchy.
///
/// SwiftUI calls this method before adding the hosting controller's root
/// view to the view hierarchy. You can override this method to perform
/// custom tasks associated with the appearance of the view. If you
/// override this method, you must call `super` at some point in your
/// implementation.
///
/// - Parameter animated: If `true`, the view is being added
///   using an animation.
@MainActor override dynamic open func viewWillAppear(_ animated: Bool)
@MainActor override dynamic open func viewIsAppearing(_ animated: Bool)
/// Notifies the view controller that its view has been added to a
/// view hierarchy.
///
/// SwiftUI calls this method after adding the hosting controller's root
/// view to the view hierarchy. You can override this method to perform
/// custom tasks associated with the appearance of the view. If you
/// override this method, you must call `super` at some point in your
/// implementation.
///
/// - Parameter animated: If `true`, the view is being added
///   using an animation.
@MainActor override dynamic open func viewDidAppear(_ animated: Bool)
/// Notifies the view controller that its view will be removed from a
/// view hierarchy.
///
/// SwiftUI calls this method before removing the hosting controller's root
/// view from the view hierarchy. You can override this method to perform
/// custom tasks associated with the disappearance of the view. If you
/// override this method, you must call `super` at some point in your
/// implementation.
///
/// - Parameter animated: If `true`, the view is being removed
///   using an animation.
@MainActor override dynamic open func viewWillDisappear(_ animated: Bool)
@MainActor override dynamic open func viewDidDisappear(_ animated: Bool)
@MainActor override dynamic open func viewWillLayoutSubviews()
@MainActor override dynamic open var isModalInPresentation: Bool
/// The root view of the SwiftUI view hierarchy managed by this view
/// controller.
@MainActor public var rootView: Content
/// The options for how the hosting controller tracks changes to the size
/// of its SwiftUI content.
///
/// The default value is the empty set.
@available(iOS 16.0, tvOS 16.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor public var sizingOptions: UIHostingControllerSizingOptions
/// Calculates and returns the most appropriate size for the current view.
///
/// - Parameter size: The proposed new size for the view.
///
/// - Returns: The size that offers the best fit for the root view and its
///   contents.
@MainActor public func sizeThatFits(in size: CGSize) -> CGSize
@MainActor override dynamic open func preferredContentSizeDidChange(forChildContentContainer container: UIContentContainer)
/// The preferred status bar style for the view controller.
@MainActor override dynamic open var preferredStatusBarStyle: UIStatusBarStyle { get }
/// A Boolean value that indicates whether the view controller prefers the
/// status bar to be hidden or shown.
@MainActor override dynamic open var prefersStatusBarHidden: Bool { get }
/// The animation style to use when hiding or showing the status bar for
/// this view controller.
@MainActor override dynamic open var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { get }
@MainActor override dynamic open var childForStatusBarStyle: UIViewController? { get }
@MainActor override dynamic open var childForStatusBarHidden: UIViewController? { get }
@MainActor override dynamic open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
@MainActor override dynamic open func willMove(toParent parent: UIViewController?)
@MainActor override dynamic open func didMove(toParent parent: UIViewController?)
/// Sets the screen edge from which you want your gesture to take
/// precedence over the system gesture.
@MainActor override dynamic open var preferredScreenEdgesDeferringSystemGestures: UIRectEdge { get }
@MainActor override dynamic open var childForScreenEdgesDeferringSystemGestures: UIViewController? { get }
/// A Boolean value that indicates whether the view controller prefers the
/// home indicator to be hidden or shown.
@MainActor override dynamic open var prefersHomeIndicatorAutoHidden: Bool { get }
@MainActor override dynamic open var childForHomeIndicatorAutoHidden: UIViewController? { get }
@MainActor override dynamic open func target(forAction action: Selector, withSender sender: Any?) -> Any?
}
extension UIHostingController {
/// The safe area regions that this view controller adds to its view.
///
/// An example of when this is appropriate to use is when hosting content
/// that you know should never be affected by the safe area, such as a
/// custom scrollable container. Disabling a safe area region omits it from
/// the SwiftUI layout system altogether.
///
/// The default value is ``SafeAreaRegions.all``.
@available(iOS 16.4, tvOS 16.4, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor public var safeAreaRegions: SafeAreaRegions
}
/// Options for how a hosting controller tracks its content's size.
@available(iOS 16.0, tvOS 16.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public struct UIHostingControllerSizingOptions : OptionSet, Sendable {
/// The raw value.
public let rawValue: Int
/// Creates a new option set from a raw value.
public init(rawValue: Int)
/// The hosting controller tracks its content's ideal size in its
/// preferred content size.
///
/// Use this option when using a hosting controller with a container view
/// controller that requires up-to-date knowledge of the hosting
/// controller's ideal size.
///
/// - Note: This option comes with a performance cost because it
///   asks for the ideal size of the content using the
///   ``ProposedViewSize/unspecified`` size proposal.
public static let preferredContentSize: UIHostingControllerSizingOptions
/// The hosting controller's view automatically invalidate its intrinsic
/// content size when its ideal size changes.
///
/// Use this option when the hosting controller's view is being laid out
/// with Auto Layout.
///
/// - Note: This option comes with a performance cost because it
///   asks for the ideal size of the content using the
///   ``ProposedViewSize/unspecified`` size proposal.
public static let intrinsicContentSize: UIHostingControllerSizingOptions
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = UIHostingControllerSizingOptions
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = UIHostingControllerSizingOptions
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int
}
/// An environment key that is bridged to a UIKit trait.
///
/// Use this protocol to allow the same underlying data to be accessed using an
/// environment key in SwiftUI and trait in UIKit. As the bridging is
/// bidirectional, values written to the trait in UIKit can be read using the
/// environment key in SwiftUI, and values written to the environment key in
/// SwiftUI can be read from the trait in UIKit.
///
/// Given a custom UIKit trait named `MyTrait` with `myTrait` properties on
/// both `UITraitCollection` and `UIMutableTraits`:
///
///     struct MyTrait: UITraitDefinition {
///         static let defaultValue = "Default value"
///     }
///
///     extension UITraitCollection {
///         var myTrait: String {
///             self[MyTrait.self]
///         }
///     }
///
///     extension UIMutableTraits {
///         var myTrait: String {
///             get { self[MyTrait.self] }
///             set { self[MyTrait.self] = newValue }
///         }
///     }
///
/// You can declare an environment key to represent the same data:
///
///     struct MyEnvironmentKey: EnvironmentKey {
///         static let defaultValue = "Default value"
///     }
///
/// Bridge the environment key and the trait by conforming to the
/// `UITraitBridgedEnvironmentKey` protocol, providing implementations
/// of ``read(from:)`` and ``write(to:value:)`` to losslessly convert
/// the environment value from and to the corresponding trait value:
///
///     extension MyEnvironmentKey: UITraitBridgedEnvironmentKey {
///         static func read(
///             from traitCollection: UITraitCollection
///         ) -> String {
///             traitCollection.myTrait
///         }
///
///         static func write(
///             to mutableTraits: inout UIMutableTraits, value: String
///         ) {
///             mutableTraits.myTrait = value
///         }
///     }
///
@available(iOS 17.0, tvOS 17.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public protocol UITraitBridgedEnvironmentKey : EnvironmentKey {
/// Reads the trait value from the trait collection, and returns
/// the equivalent environment value.
///
/// - Parameter traitCollection: The trait collection to read from.
static func read(from traitCollection: UITraitCollection) -> Self.Value
static func write(to mutableTraits: inout UIMutableTraits, value: Self.Value)
}
/// A view that represents a UIKit view controller.
///
/// Use a ``UIViewControllerRepresentable`` instance to create and manage a
/// <doc://com.apple.documentation/documentation/UIKit/UIViewController> object in your
/// SwiftUI interface. Adopt this protocol in one of your app's custom
/// instances, and use its methods to create, update, and tear down your view
/// controller. The creation and update processes parallel the behavior of
/// SwiftUI views, and you use them to configure your view controller with your
/// app's current state information. Use the teardown process to remove your
/// view controller cleanly from your SwiftUI. For example, you might use the
/// teardown process to notify other objects that the view controller is
/// disappearing.
///
/// To add your view controller into your SwiftUI interface, create your
/// ``UIViewControllerRepresentable`` instance and add it to your SwiftUI
/// interface. The system calls the methods of your custom instance at
/// appropriate times.
///
/// The system doesn't automatically communicate changes occurring within your
/// view controller to other parts of your SwiftUI interface. When you want your
/// view controller to coordinate with other SwiftUI views, you must provide a
/// ``NSViewControllerRepresentable/Coordinator`` instance to facilitate those
/// interactions. For example, you use a coordinator to forward target-action
/// and delegate messages from your view controller to any SwiftUI views.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public protocol UIViewControllerRepresentable : View where Self.Body == Never {
/// The type of view controller to present.
associatedtype UIViewControllerType : UIViewController
/// Creates the view controller object and configures its initial state.
///
/// You must implement this method and use it to create your view controller
/// object. Create the view controller using your app's current data and
/// contents of the `context` parameter. The system calls this method only
/// once, when it creates your view controller for the first time. For all
/// subsequent updates, the system calls the
/// ``UIViewControllerRepresentable/updateUIViewController(_:context:)``
/// method.
///
/// - Parameter context: A context structure containing information about
///   the current state of the system.
///
/// - Returns: Your UIKit view controller configured with the provided
///   information.
@MainActor func makeUIViewController(context: Self.Context) -> Self.UIViewControllerType
/// Updates the state of the specified view controller with new information
/// from SwiftUI.
///
/// When the state of your app changes, SwiftUI updates the portions of your
/// interface affected by those changes. SwiftUI calls this method for any
/// changes affecting the corresponding UIKit view controller. Use this
/// method to update the configuration of your view controller to match the
/// new state information provided in the `context` parameter.
///
/// - Parameters:
///   - uiViewController: Your custom view controller object.
///   - context: A context structure containing information about the current
///     state of the system.
@MainActor func updateUIViewController(_ uiViewController: Self.UIViewControllerType, context: Self.Context)
/// Cleans up the presented view controller (and coordinator) in
/// anticipation of their removal.
///
/// Use this method to perform additional clean-up work related to your
/// custom view controller. For example, you might use this method to remove
/// observers or update other parts of your SwiftUI interface.
///
/// - Parameters:
///   - uiViewController: Your custom view controller object.
///   - coordinator: The custom coordinator instance you use to communicate
///     changes back to SwiftUI. If you do not use a custom coordinator, the
///     system provides a default instance.
@MainActor static func dismantleUIViewController(_ uiViewController: Self.UIViewControllerType, coordinator: Self.Coordinator)
/// A type to coordinate with the view controller.
associatedtype Coordinator = Void
/// Creates the custom instance that you use to communicate changes from
/// your view controller to other parts of your SwiftUI interface.
///
/// Implement this method if changes to your view controller might affect
/// other parts of your app. In your implementation, create a custom Swift
/// instance that can communicate with other parts of your interface. For
/// example, you might provide an instance that binds its variables to
/// SwiftUI properties, causing the two to remain synchronized. If your view
/// controller doesn't interact with other parts of your app, providing a
/// coordinator is unnecessary.
///
/// SwiftUI calls this method before calling the
/// ``UIViewControllerRepresentable/makeUIViewController(context:)`` method.
/// The system provides your coordinator either directly or as part of a
/// context structure when calling the other methods of your representable
/// instance.
@MainActor func makeCoordinator() -> Self.Coordinator
/// Given a proposed size, returns the preferred size of the composite view.
///
/// This method may be called more than once with different proposed sizes
/// during the same layout pass. SwiftUI views choose their own size, so one
/// of the values returned from this function will always be used as the
/// actual size of the composite view.
///
/// - Parameters:
///   - proposal: The proposed size for the view controller.
///   - uiViewController: Your custom view controller object.
///   - context: A context structure containing information about the
///     current state of the system.
///
/// - Returns: The composite size of the represented view controller.
///   Returning a value of `nil` indicates that the system should use the
///   default sizing algorithm.
@available(iOS 16.0, tvOS 16.0, *)
@MainActor func sizeThatFits(_ proposal: ProposedViewSize, uiViewController: Self.UIViewControllerType, context: Self.Context) -> CGSize?
typealias Context = UIViewControllerRepresentableContext<Self>
@available(iOS 17.0, tvOS 17.0, *)
typealias LayoutOptions
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension UIViewControllerRepresentable where Self.Coordinator == () {
/// Creates the custom instance that you use to communicate changes from
/// your view controller to other parts of your SwiftUI interface.
///
/// Implement this method if changes to your view controller might affect
/// other parts of your app. In your implementation, create a custom Swift
/// instance that can communicate with other parts of your interface. For
/// example, you might provide an instance that binds its variables to
/// SwiftUI properties, causing the two to remain synchronized. If your view
/// controller doesn't interact with other parts of your app, providing a
/// coordinator is unnecessary.
///
/// SwiftUI calls this method before calling the
/// ``UIViewControllerRepresentable/makeUIViewController(context:)`` method.
/// The system provides your coordinator either directly or as part of a
/// context structure when calling the other methods of your representable
/// instance.
public func makeCoordinator() -> Self.Coordinator
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension UIViewControllerRepresentable {
/// Given a proposed size, returns the preferred size of the composite view.
///
/// This method may be called more than once with different proposed sizes
/// during the same layout pass. SwiftUI views choose their own size, so one
/// of the values returned from this function will always be used as the
/// actual size of the composite view.
///
/// - Parameters:
///   - proposal: The proposed size for the view controller.
///   - uiViewController: Your custom view controller object.
///   - context: A context structure containing information about the
///     current state of the system.
///
/// - Returns: The composite size of the represented view controller.
///   Returning a value of `nil` indicates that the system should use the
///   default sizing algorithm.
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
public func sizeThatFits(_ proposal: ProposedViewSize, uiViewController: Self.UIViewControllerType, context: Self.Context) -> CGSize?
/// Cleans up the presented view controller (and coordinator) in
/// anticipation of their removal.
///
/// Use this method to perform additional clean-up work related to your
/// custom view controller. For example, you might use this method to remove
/// observers or update other parts of your SwiftUI interface.
///
/// - Parameters:
///   - uiViewController: Your custom view controller object.
///   - coordinator: The custom coordinator instance you use to communicate
///     changes back to SwiftUI. If you do not use a custom coordinator, the
///     system provides a default instance.
public static func dismantleUIViewController(_ uiViewController: Self.UIViewControllerType, coordinator: Self.Coordinator)
/// Declares the content and behavior of this view.
public var body: Never { get }
}
/// Contextual information about the state of the system that you use to create
/// and update your UIKit view controller.
///
/// A ``UIViewControllerRepresentableContext`` structure contains details about
/// the current state of the system. When creating and updating your view
/// controller, the system creates one of these structures and passes it to the
/// appropriate method of your custom ``UIViewControllerRepresentable``
/// instance. Use the information in this structure to configure your view
/// controller. For example, use the provided environment values to configure
/// the appearance of your view controller and views. Don't create this
/// structure yourself.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor public struct UIViewControllerRepresentableContext<Representable> where Representable : UIViewControllerRepresentable {
/// The view's associated coordinator.
@MainActor public let coordinator: Representable.Coordinator
/// The current transaction.
@MainActor public var transaction: Transaction { get }
/// Environment values that describe the current state of the system.
///
/// Use the environment values to configure the state of your UIKit view
/// controller when creating or updating it.
@MainActor public var environment: EnvironmentValues { get }
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIViewControllerRepresentableContext : Sendable {
}
/// A wrapper for a UIKit view that you use to integrate that view into your
/// SwiftUI view hierarchy.
///
/// Use a ``UIViewRepresentable`` instance to create and manage a
/// <doc://com.apple.documentation/documentation/UIKit/UIView> object in your SwiftUI
/// interface. Adopt this protocol in one of your app's custom instances, and
/// use its methods to create, update, and tear down your view. The creation and
/// update processes parallel the behavior of SwiftUI views, and you use them to
/// configure your view with your app's current state information. Use the
/// teardown process to remove your view cleanly from your SwiftUI. For example,
/// you might use the teardown process to notify other objects that the view is
/// disappearing.
///
/// To add your view into your SwiftUI interface, create your
/// ``UIViewRepresentable`` instance and add it to your SwiftUI interface. The
/// system calls the methods of your representable instance at appropriate times
/// to create and update the view. The following example shows the inclusion of
/// a custom `MyRepresentedCustomView` structure in the view hierarchy.
///
///     struct ContentView: View {
///        var body: some View {
///           VStack {
///              Text("Global Sales")
///              MyRepresentedCustomView()
///           }
///        }
///     }
///
/// The system doesn't automatically communicate changes occurring within your
/// view to other parts of your SwiftUI interface. When you want your view to
/// coordinate with other SwiftUI views, you must provide a
/// ``NSViewControllerRepresentable/Coordinator`` instance to facilitate those
/// interactions. For example, you use a coordinator to forward target-action
/// and delegate messages from your view to any SwiftUI views.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public protocol UIViewRepresentable : View where Self.Body == Never {
/// The type of view to present.
associatedtype UIViewType : UIView
/// Creates the view object and configures its initial state.
///
/// You must implement this method and use it to create your view object.
/// Configure the view using your app's current data and contents of the
/// `context` parameter. The system calls this method only once, when it
/// creates your view for the first time. For all subsequent updates, the
/// system calls the ``UIViewRepresentable/updateUIView(_:context:)``
/// method.
///
/// - Parameter context: A context structure containing information about
///   the current state of the system.
///
/// - Returns: Your UIKit view configured with the provided information.
@MainActor func makeUIView(context: Self.Context) -> Self.UIViewType
/// Updates the state of the specified view with new information from
/// SwiftUI.
///
/// When the state of your app changes, SwiftUI updates the portions of your
/// interface affected by those changes. SwiftUI calls this method for any
/// changes affecting the corresponding UIKit view. Use this method to
/// update the configuration of your view to match the new state information
/// provided in the `context` parameter.
///
/// - Parameters:
///   - uiView: Your custom view object.
///   - context: A context structure containing information about the current
///     state of the system.
@MainActor func updateUIView(_ uiView: Self.UIViewType, context: Self.Context)
/// Cleans up the presented UIKit view (and coordinator) in anticipation of
/// their removal.
///
/// Use this method to perform additional clean-up work related to your
/// custom view. For example, you might use this method to remove observers
/// or update other parts of your SwiftUI interface.
///
/// - Parameters:
///   - uiView: Your custom view object.
///   - coordinator: The custom coordinator instance you use to communicate
///     changes back to SwiftUI. If you do not use a custom coordinator, the
///     system provides a default instance.
@MainActor static func dismantleUIView(_ uiView: Self.UIViewType, coordinator: Self.Coordinator)
/// A type to coordinate with the view.
associatedtype Coordinator = Void
/// Creates the custom instance that you use to communicate changes from
/// your view to other parts of your SwiftUI interface.
///
/// Implement this method if changes to your view might affect other parts
/// of your app. In your implementation, create a custom Swift instance that
/// can communicate with other parts of your interface. For example, you
/// might provide an instance that binds its variables to SwiftUI
/// properties, causing the two to remain synchronized. If your view doesn't
/// interact with other parts of your app, providing a coordinator is
/// unnecessary.
///
/// SwiftUI calls this method before calling the
/// ``UIViewRepresentable/makeUIView(context:)`` method. The system provides
/// your coordinator either directly or as part of a context structure when
/// calling the other methods of your representable instance.
@MainActor func makeCoordinator() -> Self.Coordinator
/// Given a proposed size, returns the preferred size of the composite view.
///
/// This method may be called more than once with different proposed sizes
/// during the same layout pass. SwiftUI views choose their own size, so one
/// of the values returned from this function will always be used as the
/// actual size of the composite view.
///
/// - Parameters:
///   - proposal: The proposed size for the view.
///   - uiView: Your custom view object.
///   - context: A context structure containing information about the
///     current state of the system.
///
/// - Returns: The composite size of the represented view controller.
///   Returning a value of `nil` indicates that the system should use the
///   default sizing algorithm.
@available(iOS 16.0, tvOS 16.0, *)
@MainActor func sizeThatFits(_ proposal: ProposedViewSize, uiView: Self.UIViewType, context: Self.Context) -> CGSize?
typealias Context = UIViewRepresentableContext<Self>
@available(iOS 17.0, tvOS 17.0, *)
typealias LayoutOptions
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension UIViewRepresentable where Self.Coordinator == () {
/// Creates the custom instance that you use to communicate changes from
/// your view to other parts of your SwiftUI interface.
///
/// Implement this method if changes to your view might affect other parts
/// of your app. In your implementation, create a custom Swift instance that
/// can communicate with other parts of your interface. For example, you
/// might provide an instance that binds its variables to SwiftUI
/// properties, causing the two to remain synchronized. If your view doesn't
/// interact with other parts of your app, providing a coordinator is
/// unnecessary.
///
/// SwiftUI calls this method before calling the
/// ``UIViewRepresentable/makeUIView(context:)`` method. The system provides
/// your coordinator either directly or as part of a context structure when
/// calling the other methods of your representable instance.
public func makeCoordinator() -> Self.Coordinator
}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
extension UIViewRepresentable {
/// Cleans up the presented UIKit view (and coordinator) in anticipation of
/// their removal.
///
/// Use this method to perform additional clean-up work related to your
/// custom view. For example, you might use this method to remove observers
/// or update other parts of your SwiftUI interface.
///
/// - Parameters:
///   - uiView: Your custom view object.
///   - coordinator: The custom coordinator instance you use to communicate
///     changes back to SwiftUI. If you do not use a custom coordinator, the
///     system provides a default instance.
public static func dismantleUIView(_ uiView: Self.UIViewType, coordinator: Self.Coordinator)
/// Given a proposed size, returns the preferred size of the composite view.
///
/// This method may be called more than once with different proposed sizes
/// during the same layout pass. SwiftUI views choose their own size, so one
/// of the values returned from this function will always be used as the
/// actual size of the composite view.
///
/// - Parameters:
///   - proposal: The proposed size for the view.
///   - uiView: Your custom view object.
///   - context: A context structure containing information about the
///     current state of the system.
///
/// - Returns: The composite size of the represented view controller.
///   Returning a value of `nil` indicates that the system should use the
///   default sizing algorithm.
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@available(macOS, unavailable)
public func sizeThatFits(_ proposal: ProposedViewSize, uiView: Self.UIViewType, context: Self.Context) -> CGSize?
/// Declares the content and behavior of this view.
public var body: Never { get }
}
/// Contextual information about the state of the system that you use to create
/// and update your UIKit view.
///
/// A ``UIViewRepresentableContext`` structure contains details about the
/// current state of the system. When creating and updating your view, the
/// system creates one of these structures and passes it to the appropriate
/// method of your custom ``UIViewRepresentable`` instance. Use the information
/// in this structure to configure your view. For example, use the provided
/// environment values to configure the appearance of your view. Don't create
/// this structure yourself.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@MainActor public struct UIViewRepresentableContext<Representable> where Representable : UIViewRepresentable {
/// The view's associated coordinator.
@MainActor public let coordinator: Representable.Coordinator
/// The current transaction.
@MainActor public var transaction: Transaction { get }
/// The current environment.
///
/// Use the environment values to configure the state of your view when
/// creating or updating it.
@MainActor public var environment: EnvironmentValues { get }
}
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension UIViewRepresentableContext : Sendable {
}
/// A rectangular shape with rounded corners with different values, aligned
/// inside the frame of the view containing it.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct UnevenRoundedRectangle : Shape {
/// The radii of each corner of the rounded rectangle.
public var cornerRadii: RectangleCornerRadii
/// The style of corners drawn by the rounded rectangle.
public var style: RoundedCornerStyle
/// Creates a new rounded rectangle shape with uneven corners.
///
/// - Parameters:
///   - cornerRadii: the radii of each corner.
///   - style: the style of corners drawn by the shape.
@inlinable public init(cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous)
/// Creates a new rounded rectangle shape with uneven corners.
public init(topLeadingRadius: CGFloat = 0, bottomLeadingRadius: CGFloat = 0, bottomTrailingRadius: CGFloat = 0, topTrailingRadius: CGFloat = 0, style: RoundedCornerStyle = .continuous)
/// Describes this shape as a path within a rectangular frame of reference.
///
/// - Parameter rect: The frame of reference for describing this shape.
///
/// - Returns: A path that describes this shape.
public func path(in rect: CGRect) -> Path
/// The data to animate.
public var animatableData: RectangleCornerRadii.AnimatableData
/// The type defining the data to animate.
public typealias AnimatableData = RectangleCornerRadii.AnimatableData
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension UnevenRoundedRectangle : InsettableShape {
/// Returns `self` inset by `amount`.
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape
/// The type of the inset shape.
public typealias InsetShape = some InsettableShape
}
/// A  function defined by a two-dimensional curve that maps an input
/// progress in the range [0,1] to an output progress that is also in the
/// range [0,1]. By changing the shape of the curve, the effective speed
/// of an animation or other interpolation can be changed.
///
/// The horizontal (x) axis defines the input progress: a single input
/// progress value in the range [0,1] must be provided when evaluating a
/// curve.
///
/// The vertical (y) axis maps to the output progress: when a curve is
/// evaluated, the y component of the point that intersects the input progress
/// is returned.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct UnitCurve {
/// Creates a new curve using bezier control points.
///
/// The x components of the control points are clamped to the range [0,1] when
/// the curve is evaluated.
///
/// - Parameters:
///   - startControlPoint: The cubic Bézier control point associated with
///     the curve's start point at (0, 0). The tangent vector from the
///     start point to its control point defines the initial velocity of
///     the timing function.
///   - endControlPoint: The cubic Bézier control point associated with the
///     curve's end point at (1, 1). The tangent vector from the end point
///     to its control point defines the final velocity of the timing
///     function.
public static func bezier(startControlPoint: UnitPoint, endControlPoint: UnitPoint) -> UnitCurve
/// Returns the output value (y component) of the curve at the given time.
///
/// - Parameters:
///   - time: The input progress (x component). The provided value is
///     clamped to the range [0,1].
///
/// - Returns: The output value (y component) of the curve at the given
///   progress.
public func value(at progress: Double) -> Double
/// Returns the rate of change (first derivative) of the output value of
/// the curve at the given time.
///
/// - Parameters:
///   - progress: The input progress (x component). The provided value is
///     clamped to the range [0,1].
///
/// - Returns: The velocity of the output value (y component) of the curve
///   at the given time.
public func velocity(at progress: Double) -> Double
/// Returns a copy of the curve with its x and y components swapped.
///
/// The inverse can be used to solve a curve in reverse: given a
/// known output (y) value, the corresponding input (x) value can be found
/// by using `inverse`:
///
///     let curve = UnitCurve.easeInOut
///
///     /// The input time for which an easeInOut curve returns 0.6.
///     let inputTime = curve.inverse.evaluate(at: 0.6)
///
public var inverse: UnitCurve { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension UnitCurve : Sendable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension UnitCurve : Hashable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: UnitCurve, b: UnitCurve) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension UnitCurve {
/// A bezier curve that starts out slowly, speeds up over the middle, then
/// slows down again as it approaches the end.
///
/// The start and end control points are located at (x: 0.42, y: 0) and
/// (x: 0.58, y: 1).
@available(*, deprecated, message: "Use easeInOut instead")
public static let easeInEaseOut: UnitCurve
/// A bezier curve that starts out slowly, speeds up over the middle, then
/// slows down again as it approaches the end.
///
/// The start and end control points are located at (x: 0.42, y: 0) and
/// (x: 0.58, y: 1).
public static let easeInOut: UnitCurve
/// A bezier curve that starts out slowly, then speeds up as it finishes.
///
/// The start and end control points are located at (x: 0.42, y: 0) and
/// (x: 1, y: 1).
public static let easeIn: UnitCurve
/// A bezier curve that starts out quickly, then slows down as it
/// approaches the end.
///
/// The start and end control points are located at (x: 0, y: 0) and
/// (x: 0.58, y: 1).
public static let easeOut: UnitCurve
/// A curve that starts out slowly, then speeds up as it finishes.
///
/// The shape of the curve is equal to the fourth (bottom right) quadrant
/// of a unit circle.
public static let circularEaseIn: UnitCurve
/// A circular curve that starts out quickly, then slows down as it
/// approaches the end.
///
/// The shape of the curve is equal to the second (top left) quadrant of
/// a unit circle.
public static let circularEaseOut: UnitCurve
/// A circular curve that starts out slowly, speeds up over the middle,
/// then slows down again as it approaches the end.
///
/// The shape of the curve is defined by a piecewise combination of
/// `circularEaseIn` and `circularEaseOut`.
public static let circularEaseInOut: UnitCurve
/// A linear curve.
///
/// As the linear curve is a straight line from (0, 0) to (1, 1),
/// the output progress is always equal to the input progress, and
/// the velocity is always equal to 1.0.
public static let linear: UnitCurve
}
/// A normalized 2D point in a view's coordinate space.
///
/// Use a unit point to represent a location in a view without having to know
/// the view's rendered size. The point stores a value in each dimension that
/// indicates the fraction of the view's size in that dimension --- measured
/// from the view's origin --- where the point appears. For example, you can
/// create a unit point that represents the center of any view by using the
/// value `0.5` for each dimension:
///
///     let unitPoint = UnitPoint(x: 0.5, y: 0.5)
///
/// To project the unit point into the rendered view's coordinate space,
/// multiply each component of the unit point with the corresponding
/// component of the view's size:
///
///     let projectedPoint = CGPoint(
///         x: unitPoint.x * size.width,
///         y: unitPoint.y * size.height
///     )
///
/// You can perform this calculation yourself if you happen to know a view's
/// size, or if you want to use the unit point for some custom purpose, but
/// SwiftUI typically does this for you to carry out operations that
/// you request, like when you:
///
/// * Transform a shape using a shape modifier. For example, to rotate a
///   shape with ``Shape/rotation(_:anchor:)``, you indicate an anchor point
///   that you want to rotate the shape around.
/// * Override the alignment of the view in a ``Grid`` cell using the
///   ``View/gridCellAnchor(_:)`` view modifier. The grid aligns the projection
///   of a unit point onto the view with the projection of the same unit point
///   onto the cell.
/// * Create a gradient that has a center, or start and stop points, relative
///   to the shape that you are styling. See the gradient methods in
///   ``ShapeStyle``.
///
/// You can create custom unit points with explicit values, like the example
/// above, or you can use one of the built-in unit points that SwiftUI provides,
/// like ``zero``, ``center``, or ``topTrailing``. The built-in values
/// correspond to the alignment positions of the similarly named, built-in
/// ``Alignment`` types.
///
/// > Note: A unit point with one or more components outside the range `[0, 1]`
/// projects to a point outside of the view.
///
/// ### Layout direction
///
/// When a person configures their device to use a left-to-right language like
/// English, the system places the view's origin in its top-left corner,
/// with positive x toward the right and positive y toward the bottom of the
/// view. In a right-to-left environment, the origin moves to the upper-right
/// corner, and the positive x direction changes to be toward the left. You
/// don't typically need to do anything to handle this change, because SwiftUI
/// applies the change to all aspects of the system. For example, see the
/// discussion about layout direction in ``HorizontalAlignment``.
///
/// It’s important to test your app for the different locales that you
/// distribute your app in. For more information about the localization process,
/// see <doc://com.apple.documentation/documentation/Xcode/localization>.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct UnitPoint : Hashable {
/// The normalized distance from the origin to the point in the horizontal
/// direction.
public var x: CGFloat
/// The normalized distance from the origin to the point in the vertical
/// dimension.
public var y: CGFloat
/// Creates a unit point at the origin.
///
/// A view's origin appears in the top-left corner in a left-to-right
/// language environment, with positive x toward the right. It appears in
/// the top-right corner in a right-to-left language, with positive x toward
/// the left. Positive y is always toward the bottom of the view.
@inlinable public init()
/// Creates a unit point with the specified horizontal and vertical offsets.
///
/// Values outside the range `[0, 1]` project to points outside of a view.
///
/// - Parameters:
///   - x: The normalized distance from the origin to the point in the
///     horizontal direction.
///   - y: The normalized distance from the origin to the point in the
///     vertical direction.
@inlinable public init(x: CGFloat, y: CGFloat)
/// The origin of a view.
///
/// A view's origin appears in the top-left corner in a left-to-right
/// language environment, with positive x toward the right. It appears in
/// the top-right corner in a right-to-left language, with positive x toward
/// the left. Positive y is always toward the bottom of the view.
public static let zero: UnitPoint
/// A point that's centered in a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/center`` alignment.
public static let center: UnitPoint
/// A point that's centered vertically on the leading edge of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/leading`` alignment.
/// The leading edge appears on the left in a left-to-right language
/// environment and on the right in a right-to-left environment.
public static let leading: UnitPoint
/// A point that's centered vertically on the trailing edge of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/trailing`` alignment.
/// The trailing edge appears on the right in a left-to-right language
/// environment and on the left in a right-to-left environment.
public static let trailing: UnitPoint
/// A point that's centered horizontally on the top edge of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/top`` alignment.
public static let top: UnitPoint
/// A point that's centered horizontally on the bottom edge of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/bottom`` alignment.
public static let bottom: UnitPoint
/// A point that's in the top, leading corner of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/topLeading`` alignment.
/// The leading edge appears on the left in a left-to-right language
/// environment and on the right in a right-to-left environment.
public static let topLeading: UnitPoint
/// A point that's in the top, trailing corner of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/topTrailing`` alignment.
/// The trailing edge appears on the right in a left-to-right language
/// environment and on the left in a right-to-left environment.
public static let topTrailing: UnitPoint
/// A point that's in the bottom, leading corner of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/bottomLeading`` alignment.
/// The leading edge appears on the left in a left-to-right language
/// environment and on the right in a right-to-left environment.
public static let bottomLeading: UnitPoint
/// A point that's in the bottom, trailing corner of a view.
///
/// This point occupies the position where the horizontal and vertical
/// alignment guides intersect for ``Alignment/bottomTrailing`` alignment.
/// The trailing edge appears on the right in a left-to-right language
/// environment and on the left in a right-to-left environment.
public static let bottomTrailing: UnitPoint
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: UnitPoint, b: UnitPoint) -> Bool
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension UnitPoint : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGFloat, CGFloat>
/// The data to animate.
public var animatableData: UnitPoint.AnimatableData
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension UnitPoint : Sendable {
}
/// A set of values that indicate the visual size available to the view.
///
/// You receive a size class value when you read either the
/// ``EnvironmentValues/horizontalSizeClass`` or
/// ``EnvironmentValues/verticalSizeClass`` environment value. The value tells
/// you about the amount of space available to your views in a given
/// direction. You can read the size class like any other of the
/// ``EnvironmentValues``, by creating a property with the ``Environment``
/// property wrapper:
///
///     @Environment(\.horizontalSizeClass) private var horizontalSizeClass
///     @Environment(\.verticalSizeClass) private var verticalSizeClass
///
/// SwiftUI sets the size class based on several factors, including:
///
/// * The current device type.
/// * The orientation of the device.
/// * The appearance of Slide Over and Split View on iPad.
///
/// Several built-in views change their behavior based on the size class.
/// For example, a ``NavigationView`` presents a multicolumn view when
/// the horizontal size class is ``UserInterfaceSizeClass/regular``,
/// but a single column otherwise. You can also adjust the appearance of
/// custom views by reading the size class and conditioning your views.
/// If you do, be prepared to handle size class changes while
/// your app runs, because factors like device orientation can change at
/// runtime.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum UserInterfaceSizeClass : Sendable {
/// The compact size class.
case compact
/// The regular size class.
case regular
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: UserInterfaceSizeClass, b: UserInterfaceSizeClass) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
extension UserInterfaceSizeClass {
/// Creates a SwiftUI size class from the specified UIKit size class.
@available(iOS 14.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public init?(_ uiUserInterfaceSizeClass: UIUserInterfaceSizeClass)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension UserInterfaceSizeClass : Equatable {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension UserInterfaceSizeClass : Hashable {
}
/// A view that arranges its subviews in a vertical line.
///
/// Unlike ``LazyVStack``, which only renders the views when your app needs to
/// display them, a `VStack` renders the views all at once, regardless
/// of whether they are on- or offscreen. Use the regular `VStack` when you have
/// a small number of subviews or don't want the delayed rendering behavior
/// of the "lazy" version.
///
/// The following example shows a simple vertical stack of 10 text views:
///
///     var body: some View {
///         VStack(
///             alignment: .leading,
///             spacing: 10
///         ) {
///             ForEach(
///                 1...10,
///                 id: \.self
///             ) {
///                 Text("Item \($0)")
///             }
///         }
///     }
///
/// ![Ten text views, named Item 1 through Item 10, arranged in a
/// vertical line.](SwiftUI-VStack-simple.png)
///
/// > Note: If you need a vertical stack that conforms to the ``Layout``
/// protocol, like when you want to create a conditional layout using
/// ``AnyLayout``, use ``VStackLayout`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct VStack<Content> : View where Content : View {
/// Creates an instance with the given spacing and horizontal alignment.
///
/// - Parameters:
///   - alignment: The guide for aligning the subviews in this stack. This
///     guide has the same vertical screen coordinate for every subview.
///   - spacing: The distance between adjacent subviews, or `nil` if you
///     want the stack to choose a default distance for each pair of
///     subviews.
///   - content: A view builder that creates the content of this stack.
@inlinable public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// A vertical container that you can use in conditional layouts.
///
/// This layout container behaves like a ``VStack``, but conforms to the
/// ``Layout`` protocol so you can use it in the conditional layouts that you
/// construct with ``AnyLayout``. If you don't need a conditional layout, use
/// ``VStack`` instead.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct VStackLayout : Layout {
/// The horizontal alignment of subviews.
public var alignment: HorizontalAlignment
/// The distance between adjacent subviews.
///
/// Set this value to `nil` to use default distances between subviews.
public var spacing: CGFloat?
/// Creates a vertical stack with the specified spacing and horizontal
/// alignment.
///
/// - Parameters:
///     - alignment: The guide for aligning the subviews in this stack. It
///       has the same horizontal screen coordinate for all subviews.
///     - spacing: The distance between adjacent subviews. Set this value
///       to `nil` to use default distances between subviews.
@inlinable public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil)
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// Cached values associated with the layout instance.
///
/// If you create a cache for your custom layout, you can use
/// a type alias to define this type as your data storage type.
/// Alternatively, you can refer to the data storage type directly in all
/// the places where you work with the cache.
///
/// See ``makeCache(subviews:)-23agy`` for more information.
public typealias Cache
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension VStackLayout : Sendable {
}
/// A type that can serve as the animatable data of an animatable type.
///
/// `VectorArithmetic` extends the `AdditiveArithmetic` protocol with scalar
/// multiplication and a way to query the vector magnitude of the value. Use
/// this type as the `animatableData` associated type of a type that conforms to
/// the ``Animatable`` protocol.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol VectorArithmetic : AdditiveArithmetic {
/// Multiplies each component of this value by the given value.
mutating func scale(by rhs: Double)
/// Returns the dot-product of this vector arithmetic instance with itself.
var magnitudeSquared: Double { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension VectorArithmetic {
/// Returns a value with each component of this value multiplied by the
/// given value.
public func scaled(by rhs: Double) -> Self
/// Interpolates this value with `other` by the specified `amount`.
///
/// This is equivalent to `self = self + (other - self) * amount`.
public mutating func interpolate(towards other: Self, amount: Double)
/// Returns this value interpolated with `other` by the specified `amount`.
///
/// This result is equivalent to `self + (other - self) * amount`.
public func interpolated(towards other: Self, amount: Double) -> Self
}
/// An alignment position along the vertical axis.
///
/// Use vertical alignment guides to position views
/// relative to one another vertically, like when you place views side-by-side
/// in an ``HStack`` or when you create a row of views in a ``Grid`` using
/// ``GridRow``. The following example demonstrates common built-in
/// vertical alignments:
///
/// ![Five rows of content. Each row contains text inside
/// a box with horizontal lines to the left and the right of the box. The
/// lines are aligned vertically with the text in a different way for each
/// row, corresponding to the content of the text in that row. The text strings
/// are, in order, top, center, bottom, first text baseline, and last text
/// baseline.](VerticalAlignment-1-iOS)
///
/// You can generate the example above by creating a series of rows
/// implemented as horizontal stacks, where you configure each stack with a
/// different alignment guide:
///
///     private struct VerticalAlignmentGallery: View {
///         var body: some View {
///             VStack(spacing: 30) {
///                 row(alignment: .top, text: "Top")
///                 row(alignment: .center, text: "Center")
///                 row(alignment: .bottom, text: "Bottom")
///                 row(alignment: .firstTextBaseline, text: "First Text Baseline")
///                 row(alignment: .lastTextBaseline, text: "Last Text Baseline")
///             }
///         }
///
///         private func row(alignment: VerticalAlignment, text: String) -> some View {
///             HStack(alignment: alignment, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text(text).font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
///
/// During layout, SwiftUI aligns the views inside each stack by bringing
/// together the specified guides of the affected views. SwiftUI calculates
/// the position of a guide for a particular view based on the characteristics
/// of the view. For example, the ``VerticalAlignment/center`` guide appears
/// at half the height of the view. You can override the guide calculation for a
/// particular view using the ``View/alignmentGuide(_:computeValue:)-6y3u2``
/// view modifier.
///
/// ### Text baseline alignment
///
/// Use the ``VerticalAlignment/firstTextBaseline`` or
/// ``VerticalAlignment/lastTextBaseline`` guide to match the bottom of either
/// the top- or bottom-most line of text that a view contains, respectively.
/// Text baseline alignment excludes the parts of characters that descend
/// below the baseline, like the tail on lower case g and j:
///
///     row(alignment: .firstTextBaseline, text: "fghijkl")
///
/// If you use a text baseline alignment on a view that contains no text,
/// SwiftUI applies the equivalent of ``VerticalAlignment/bottom`` alignment
/// instead. For the row in the example above, SwiftUI matches the bottom of
/// the horizontal lines with the baseline of the text:
///
/// ![A string containing the lowercase letters f, g, h, i, j, and
/// k. The string is inside a box, and horizontal lines appear to the left and
/// to the right of the box. The lines align with the bottom of the text,
/// excluding the descenders of letters g and j, which extend below the
/// baseline.](VerticalAlignment-2-iOS)
///
/// Aligning a text view to its baseline rather than to the bottom of its frame
/// produces the best layout effect in many cases, like when creating forms.
/// For example, you can align the baseline of descriptive text in
/// one ``GridRow`` cell with the baseline of a text field, or the label
/// of a checkbox, in another cell in the same row.
///
/// ### Custom alignment guides
///
/// You can create a custom vertical alignment guide by first creating a type
/// that conforms to the ``AlignmentID`` protocol, and then using that type to
/// initalize a new static property on `VerticalAlignment`:
///
///     private struct FirstThirdAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.height / 3
///         }
///     }
///
///     extension VerticalAlignment {
///         static let firstThird = VerticalAlignment(FirstThirdAlignment.self)
///     }
///
/// You implement the ``AlignmentID/defaultValue(in:)`` method to calculate
/// a default value for the custom alignment guide. The method receives a
/// ``ViewDimensions`` instance that you can use to calculate a
/// value based on characteristics of the view. The example above places
/// the guide at one-third of the height of the view as measured from the
/// view's origin.
///
/// You can then use the custom alignment guide like any built-in guide. For
/// example, you can use it as the `alignment` parameter to an ``HStack``,
/// or to alter the guide calculation for a specific view using the
/// ``View/alignmentGuide(_:computeValue:)-6y3u2`` view modifier.
///
/// ### Composite alignment
///
/// Combine a `VerticalAlignment` with a ``HorizontalAlignment`` to create a
/// composite ``Alignment`` that indicates both vertical and horizontal
/// positioning in one value. For example, you could combine your custom
/// `firstThird` vertical alignment from the previous section with a built-in
/// ``HorizontalAlignment/center`` horizontal alignment to use in a ``ZStack``:
///
///     struct LayeredHorizontalStripes: View {
///         var body: some View {
///             ZStack(alignment: Alignment(horizontal: .center, vertical: .firstThird)) {
///                 horizontalStripes(color: .blue)
///                     .frame(width: 180, height: 90)
///                 horizontalStripes(color: .green)
///                     .frame(width: 70, height: 60)
///             }
///         }
///
///         private func horizontalStripes(color: Color) -> some View {
///             VStack(spacing: 1) {
///                 ForEach(0..<3) { _ in color }
///             }
///         }
///     }
///
/// The example above uses widths and heights that generate two mismatched
/// sets of three vertical stripes. The ``ZStack`` centers the two sets
/// horizontally and aligns them vertically one-third from the top
/// of each set. This aligns the bottom edges of the top stripe from each set:
///
/// ![Two sets of three vertically stacked rectangles. The first
/// set is blue. The second set of rectangles are green, smaller, and layered
/// on top of the first set. The two sets are centered horizontally, but align
/// vertically at the bottom edge of each set's top-most
/// rectangle.](VerticalAlignment-3-iOS)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct VerticalAlignment : Equatable {
/// Creates a custom vertical alignment of the specified type.
///
/// Use this initializer to create a custom vertical alignment. Define
/// an ``AlignmentID`` type, and then use that type to create a new
/// static property on ``VerticalAlignment``:
///
///     private struct FirstThirdAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.height / 3
///         }
///     }
///
///     extension VerticalAlignment {
///         static let firstThird = VerticalAlignment(FirstThirdAlignment.self)
///     }
///
/// Every vertical alignment instance that you create needs a unique
/// identifier. For more information, see ``AlignmentID``.
///
/// - Parameter id: The type of an identifier that uniquely identifies a
///   vertical alignment.
public init(_ id: AlignmentID.Type)
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: VerticalAlignment, b: VerticalAlignment) -> Bool
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension VerticalAlignment {
/// Merges a sequence of explicit alignment values produced by
/// this instance.
///
/// For most alignment types, this method returns the mean of all non-`nil`
/// values. However, some types use other rules. For example,
/// ``VerticalAlignment/firstTextBaseline`` returns the minimum value,
/// while ``VerticalAlignment/lastTextBaseline`` returns the maximum value.
public func combineExplicit<S>(_ values: S) -> CGFloat? where S : Sequence, S.Element == CGFloat?
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension VerticalAlignment {
/// A guide that marks the top edge of the view.
///
/// Use this guide to align the top edges of views:
///
/// ![A box that contains the word, Top. A horizontal
/// line appears on either side of the box. The lines align vertically
/// with the top edge of the box.](VerticalAlignment-top-1-iOS)
///
/// The following code generates the image above using an ``HStack``:
///
///     struct VerticalAlignmentTop: View {
///         var body: some View {
///             HStack(alignment: .top, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text("Top").font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
///
public static let top: VerticalAlignment
/// A guide that marks the vertical center of the view.
///
/// Use this guide to align the centers of views:
///
/// ![A box that contains the word, Center. A horizontal
/// line appears on either side of the box. The lines align vertically
/// with the center of the box.](VerticalAlignment-center-1-iOS)
///
/// The following code generates the image above using an ``HStack``:
///
///     struct VerticalAlignmentCenter: View {
///         var body: some View {
///             HStack(alignment: .center, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text("Center").font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
///
public static let center: VerticalAlignment
/// A guide that marks the bottom edge of the view.
///
/// Use this guide to align the bottom edges of views:
///
/// ![A box that contains the word, Bottom. A horizontal
/// line appears on either side of the box. The lines align vertically
/// with the bottom edge of the box.](VerticalAlignment-bottom-1-iOS)
///
/// The following code generates the image above using an ``HStack``:
///
///     struct VerticalAlignmentBottom: View {
///         var body: some View {
///             HStack(alignment: .bottom, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text("Bottom").font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
///
public static let bottom: VerticalAlignment
/// A guide that marks the top-most text baseline in a view.
///
/// Use this guide to align with the baseline of the top-most text in a
/// view. The guide aligns with the bottom of a view that contains no text:
///
/// ![A box that contains the text, First Text Baseline.
/// A horizontal line appears on either side of the box. The lines align
/// vertically with the baseline of the first line of
/// text.](VerticalAlignment-firstTextBaseline-1-iOS)
///
/// The following code generates the image above using an ``HStack``:
///
///     struct VerticalAlignmentFirstTextBaseline: View {
///         var body: some View {
///             HStack(alignment: .firstTextBaseline, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text("First Text Baseline").font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
public static let firstTextBaseline: VerticalAlignment
/// A guide that marks the bottom-most text baseline in a view.
///
/// Use this guide to align with the baseline of the bottom-most text in a
/// view. The guide aligns with the bottom of a view that contains no text.
///
/// ![A box that contains the text, Last Text Baseline.
/// A horizontal line appears on either side of the box. The lines align
/// vertically with the baseline of the last line of
/// text.](VerticalAlignment-lastTextBaseline-1-iOS)
///
/// The following code generates the image above using an ``HStack``:
///
///     struct VerticalAlignmentLastTextBaseline: View {
///         var body: some View {
///             HStack(alignment: .lastTextBaseline, spacing: 0) {
///                 Color.red.frame(height: 1)
///                 Text("Last Text Baseline").font(.title).border(.gray)
///                 Color.red.frame(height: 1)
///             }
///         }
///     }
///
public static let lastTextBaseline: VerticalAlignment
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension VerticalAlignment : Sendable {
}
/// An edge on the vertical axis.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public enum VerticalEdge : Int8, CaseIterable, Codable {
/// The top edge.
case top
/// The bottom edge.
case bottom
/// An efficient set of `VerticalEdge`s.
@frozen public struct Set : OptionSet {
/// The element type of the option set.
///
/// To inherit all the default implementations from the `OptionSet` protocol,
/// the `Element` type must be `Self`, the default.
public typealias Element = VerticalEdge.Set
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public let rawValue: Int8
/// Creates a new option set from the given raw value.
///
/// This initializer always succeeds, even if the value passed as `rawValue`
/// exceeds the static properties declared as part of the option set. This
/// example creates an instance of `ShippingOptions` with a raw value beyond
/// the highest element, with a bit mask that effectively contains all the
/// declared static members.
///
///     let extraOptions = ShippingOptions(rawValue: 255)
///     print(extraOptions.isStrictSuperset(of: .all))
///     // Prints "true"
///
/// - Parameter rawValue: The raw value of the option set to create. Each bit
///   of `rawValue` potentially represents an element of the option set,
///   though raw values may include bits that are not defined as distinct
///   values of the `OptionSet` type.
public init(rawValue: Int8)
/// A set containing only the top vertical edge.
public static let top: VerticalEdge.Set
/// A set containing only the bottom vertical edge.
public static let bottom: VerticalEdge.Set
/// A set containing the top and bottom vertical edges.
public static let all: VerticalEdge.Set
/// Creates an instance containing just `e`
public init(_ e: VerticalEdge)
/// The type of the elements of an array literal.
public typealias ArrayLiteralElement = VerticalEdge.Set.Element
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
}
/// Creates a new instance with the specified raw value.
///
/// If there is no value of the type that corresponds with the specified raw
/// value, this initializer returns `nil`. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     print(PaperSize(rawValue: "Legal"))
///     // Prints "Optional("PaperSize.Legal")"
///
///     print(PaperSize(rawValue: "Tabloid"))
///     // Prints "nil"
///
/// - Parameter rawValue: The raw value to use for the new instance.
public init?(rawValue: Int8)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [VerticalEdge]
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = Int8
/// A collection of all values of this type.
public static var allCases: [VerticalEdge] { get }
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
///     enum PaperSize: String {
///         case A4, A5, Letter, Legal
///     }
///
///     let selectedSize = PaperSize.Letter
///     print(selectedSize.rawValue)
///     // Prints "Letter"
///
///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
///     // Prints "true"
public var rawValue: Int8 { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension VerticalEdge : Equatable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension VerticalEdge : Hashable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension VerticalEdge : RawRepresentable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension VerticalEdge : Sendable {
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension VerticalEdge.Set : Sendable {
}
/// A type that represents part of your app's user interface and provides
/// modifiers that you use to configure views.
///
/// You create custom views by declaring types that conform to the `View`
/// protocol. Implement the required ``View/body-swift.property`` computed
/// property to provide the content for your custom view.
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// Assemble the view's body by combining one or more of the built-in views
/// provided by SwiftUI, like the ``Text`` instance in the example above, plus
/// other custom views that you define, into a hierarchy of views. For more
/// information about creating custom views, see <doc:Declaring-a-Custom-View>.
///
/// The `View` protocol provides a set of modifiers — protocol
/// methods with default implementations — that you use to configure
/// views in the layout of your app. Modifiers work by wrapping the
/// view instance on which you call them in another view with the specified
/// characteristics, as described in <doc:Configuring-Views>.
/// For example, adding the ``View/opacity(_:)`` modifier to a
/// text view returns a new view with some amount of transparency:
///
///     Text("Hello, World!")
///         .opacity(0.5) // Display partially transparent text.
///
/// The complete list of default modifiers provides a large set of controls
/// for managing views.
/// For example, you can fine tune <doc:View-Layout>,
/// add <doc:View-Accessibility> information,
/// and respond to <doc:View-Input-and-Events>.
/// You can also collect groups of default modifiers into new,
/// custom view modifiers for easy reuse.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol View {
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
associatedtype Body : View
/// The content and behavior of the view.
///
/// When you implement a custom view, you must implement a computed
/// `body` property to provide the content for your view. Return a view
/// that's composed of built-in views that SwiftUI provides, plus other
/// composite views that you've already defined:
///
///     struct MyView: View {
///         var body: some View {
///             Text("Hello, World!")
///         }
///     }
///
/// For more information about composing views and a view hierarchy,
/// see <doc:Declaring-a-Custom-View>.
@ViewBuilder @MainActor var body: Self.Body { get }
}
extension View {
/// Adds a custom large content view to be shown by
/// the large content viewer.
///
/// Rely on the large content viewer only in situations
/// where items must remain small due to unavoidable
/// design constraints. For example, buttons in a tab bar
/// remain small to leave more room for the main app content.
///
/// The following example shows how to add a custom large
/// content view:
///
///     var body: some View {
///         Button(action: newMessage) {
///             Image(systemName: "plus")
///         }
///         .accessibilityShowsLargeContentViewer {
///             Label("New Message", systemImage: "plus")
///         }
///     }
///
/// Don’t use the large content viewer as a replacement for proper
/// Dynamic Type support. For example, Dynamic Type allows items
/// in a list to grow or shrink vertically to accommodate the user’s preferred
/// font size. Rely on the large content viewer only in situations where
/// items must remain small due to unavoidable design constraints.
///
/// For example, views that have their Dynamic Type size constrained
/// with ``View/dynamicTypeSize(_:)-26aj0`` or
/// ``View/dynamicTypeSize(_:)-26aj0`` may require a
/// large content view.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func accessibilityShowsLargeContentViewer<V>(@ViewBuilder _ largeContentView: () -> V) -> some View where V : View
/// Adds a default large content view to be shown by
/// the large content viewer.
///
/// Rely on the large content viewer only in situations
/// where items must remain small due to unavoidable
/// design constraints. For example, buttons in a tab bar
/// remain small to leave more room for the main app content.
///
/// The following example shows how to add a custom large
/// content view:
///
///     var body: some View {
///         Button("New Message", action: newMessage)
///             .accessibilityShowsLargeContentViewer()
///     }
///
/// Don’t use the large content viewer as a replacement for proper
/// Dynamic Type support. For example, Dynamic Type allows items
/// in a list to grow or shrink vertically to accommodate the user’s preferred
/// font size. Rely on the large content viewer only in situations where
/// items must remain small due to unavoidable design constraints.
///
/// For example, views that have their Dynamic Type size constrained
/// with ``View/dynamicTypeSize(_:)-26aj0`` or
/// ``View/dynamicTypeSize(_:)-26aj0`` may require a
/// large content view.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func accessibilityShowsLargeContentViewer() -> some View
}
extension View {
/// Specifies the language for typesetting.
///
/// In some cases `Text` may contain text of a particular language which
/// doesn't match the device UI language. In that case it's useful to
/// specify a language so line height, line breaking and spacing will
/// respect the script used for that language. For example:
///
///     Text(verbatim: "แอปเปิล")
///         .typesettingLanguage(.init(languageCode: .thai))
///
/// Note: this language does not affect text localization.
///
/// - Parameters:
///   - language: The explicit language to use for typesetting.
///   - isEnabled: A Boolean value that indicates whether text langauge is
///     added
/// - Returns: A view with the typesetting language set to the value you
///   supply.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func typesettingLanguage(_ language: Locale.Language, isEnabled: Bool = true) -> some View
/// Specifies the language for typesetting.
///
/// In some cases `Text` may contain text of a particular language which
/// doesn't match the device UI language. In that case it's useful to
/// specify a language so line height, line breaking and spacing will
/// respect the script used for that language. For example:
///
///     Text(verbatim: "แอปเปิล").typesettingLanguage(
///         .explicit(.init(languageCode: .thai)))
///
/// Note: this language does not affect text localized localization.
///
/// - Parameters:
///   - language: The language to use for typesetting.
///   - isEnabled: A Boolean value that indicates whether text language is
///     added
/// - Returns: A view with the typesetting language set to the value you
///   supply.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func typesettingLanguage(_ language: TypesettingLanguage, isEnabled: Bool = true) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets a fixed, preferred width for the column containing this view.
///
/// Apply this modifier to the content of a column in a
/// ``NavigationSplitView`` to specify a fixed preferred width for the
/// column. Use ``View/navigationSplitViewColumnWidth(min:ideal:max:)`` if
/// you need to specify a flexible width.
///
/// The following example shows a three-column navigation split view where
/// the first column has a preferred width of 150 points, and the second
/// column has a flexible, preferred width between 150 and 400 points:
///
///     NavigationSplitView {
///         MySidebar()
///             .navigationSplitViewColumnWidth(150)
///     } contents: {
///         MyContents()
///             .navigationSplitViewColumnWidth(
///                 min: 150, ideal: 200, max: 400)
///     } detail: {
///         MyDetail()
///     }
///
/// Only some platforms enable resizing columns. If
/// you specify a width that the current presentation environment doesn't
/// support, SwiftUI may use a different width for your column.
public func navigationSplitViewColumnWidth(_ width: CGFloat) -> some View
/// Sets a flexible, preferred width for the column containing this view.
///
/// Apply this modifier to the content of a column in a
/// ``NavigationSplitView`` to specify a preferred flexible width for the
/// column. Use ``View/navigationSplitViewColumnWidth(_:)`` if you need to
/// specify a fixed width.
///
/// The following example shows a three-column navigation split view where
/// the first column has a preferred width of 150 points, and the second
/// column has a flexible, preferred width between 150 and 400 points:
///
///     NavigationSplitView {
///         MySidebar()
///             .navigationSplitViewColumnWidth(150)
///     } contents: {
///         MyContents()
///             .navigationSplitViewColumnWidth(
///                 min: 150, ideal: 200, max: 400)
///     } detail: {
///         MyDetail()
///     }
///
/// Only some platforms enable resizing columns. If
/// you specify a width that the current presentation environment doesn't
/// support, SwiftUI may use a different width for your column.
public func navigationSplitViewColumnWidth(min: CGFloat? = nil, ideal: CGFloat, max: CGFloat? = nil) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Links multiple accessibility elements so that the user can quickly
/// navigate from one element to another, even when the elements are not near
/// each other in the accessibility hierarchy.
///
/// This can be useful to allow quickly jumping between content in a list and
/// the same content shown in a detail view, for example. All elements marked
/// with `accessibilityLinkedGroup` with the same namespace and identifier will be
/// linked together.
///
/// - Parameters:
///   - id: A hashable identifier used to separate sets of linked elements
///     within the same namespace. Elements with matching `namespace` and `id`
///     will be linked together.
///   - namespace: The namespace to use to organize linked accessibility
///     elements. All elements marked with `accessibilityLink` in this
///     namespace and with the specified `id` will be linked together.
public func accessibilityLinkedGroup<ID>(id: ID, in namespace: Namespace.ID) -> some View where ID : Hashable
/// Pairs an accessibility element representing a label with the element
/// for the matching content.
///
/// Use `accessibilityLabeledPair` with a role of `AccessibilityLabeledPairRole.label`
/// to identify the label, and a role of `AccessibilityLabeledPairRole.content`
/// to identify the content.
/// This improves the behavior of accessibility features such as VoiceOver
/// when navigating such elements, allowing users to better understand the
/// relationship between them.
///
/// - Parameters:
///   - role: Determines whether this element should be used as the label
///     in the pair, or the content in the pair.
///   - id: The identifier for the label / content pair. Elements with
///     matching identifiers within the same namespace will be paired
///     together.
///   - namespace: The namespace used to organize label and content. Label
///     and content under the same namespace with matching identifiers will
///     be paired together.
public func accessibilityLabeledPair<ID>(role: AccessibilityLabeledPairRole, id: ID, in namespace: Namespace.ID) -> some View where ID : Hashable
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds a reason to apply a redaction to this view hierarchy.
///
/// Adding a redaction is an additive process: any redaction
/// provided will be added to the reasons provided by the parent.
public func redacted(reason: RedactionReasons) -> some View
/// Removes any reason to apply a redaction to this view hierarchy.
public func unredacted() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for lists within this view.
public func listStyle<S>(_ style: S) -> some View where S : ListStyle
}
extension View {
/// Presents an action sheet using the given item as a data source for the
/// sheet's content.
///
/// Use this method when you need to populate the fields of an action sheet
/// with content from a data source. The example below shows a custom data
/// source, `FileDetails`, that provides data to populate the action sheet:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///
///     struct ConfirmFileImport: View {
///         @State private var sheetDetail: FileDetails?
///
///         var body: some View {
///             Button("Show Action Sheet") {
///                 sheetDetail = FileDetails(name: "MyImageFile.png",
///                                           fileType: .png)
///             }
///             .actionSheet(item: $sheetDetail) { detail in
///                 ActionSheet(
///                     title: Text("File Import"),
///                     message: Text("""
///                              Import \(detail.name)?
///                              File Type: \(detail.fileType.description)
///                              """),
///                     buttons: [
///                         .destructive(Text("Import"),
///                                      action: importFile),
///                         .cancel()
///                     ])
///             }
///         }
///
///         func importFile() {
///             // Handle import action.
///         }
///     }
///
/// ![A screenshot showing an action sheet populated using a custom data
/// source that describes a file and file
/// format.](SwiftUI-View-ActionSheetItemContent.png)
///
/// - Parameters:
///   - item: A binding to an optional source of truth for the action
///     sheet. When `item` is non-`nil`, the system passes
///     the contents to the modifier's closure. You use this content
///     to populate the fields of an action sheet that you create that the
///     system displays to the user. If `item` changes, the system
///     dismisses the currently displayed action sheet and replaces it
///     with a new one using the same process.
///   - content: A closure returning the ``ActionSheet`` you create.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting::actions:)`instead.")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
public func actionSheet<T>(item: Binding<T?>, content: (T) -> ActionSheet) -> some View where T : Identifiable
/// Presents an action sheet when a given condition is true.
///
/// In the example below, a button conditionally presents an action sheet
/// depending upon the value of a bound Boolean variable. When the Boolean
/// value is set to `true`, the system displays an action sheet with both
/// destructive and default actions:
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingSheet = false
///         var body: some View {
///             Button("Show Action Sheet", action: {
///                 isShowingSheet = true
///             })
///             .actionSheet(isPresented: $isShowingSheet) {
///                 ActionSheet(
///                     title: Text("Permanently erase the items in the Trash?"),
///                     message: Text("You can't undo this action."),
///                     buttons:[
///                         .destructive(Text("Empty Trash"),
///                                      action: emptyTrashAction),
///                         .cancel()
///                     ]
///                 )}
///         }
///
///         func emptyTrashAction() {
///             // Handle empty trash action.
///         }
///     }
///
/// ![An action sheet with a title and message showing the use of default
/// and destructive button
/// types.](SwiftUI-View-ActionSheetisPresentedContent.png)
///
/// > Note: In regular size classes in iOS, the system renders alert sheets
///    as a popover that the user dismisses by tapping anywhere outside the
///    popover, rather than displaying the default dismiss button.
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the action sheet that you create in the modifier's
///     `content` closure. When the user presses or taps the sheet's default
///     action button the system sets this value to `false` dismissing
///     the sheet.
///   - content: A closure returning the `ActionSheet` to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting::actions:)`instead.")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use `confirmationDialog(title:isPresented:titleVisibility:presenting:actions:)`instead.")
public func actionSheet(isPresented: Binding<Bool>, content: () -> ActionSheet) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel(_ label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel(_ labelKey: LocalizedStringKey) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
public func accessibilityLabel<S>(_ label: S) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies an inset to the rows in a list.
///
/// Use `listRowInsets(_:)` to change the default padding of the content of
/// list items.
///
/// In the example below, the `Flavor` enumeration provides content for list
/// items. The SwiftUI ``ForEach`` structure computes views for each element
/// of the `Flavor` enumeration and extracts the raw value of each of its
/// elements using the resulting text to create each list row item. The
/// `listRowInsets(_:)` modifier then changes the edge insets of each row
/// of the list according to the ``EdgeInsets`` provided:
///
///     struct ContentView: View {
///         enum Flavor: String, CaseIterable, Identifiable {
///             var id: String { self.rawValue }
///             case vanilla, chocolate, strawberry
///         }
///
///         var body: some View {
///             List {
///                 ForEach(Flavor.allCases) {
///                     Text($0.rawValue)
///                         .listRowInsets(.init(top: 0,
///                                              leading: 25,
///                                              bottom: 0,
///                                              trailing: 0))
///                 }
///             }
///         }
///     }
///
/// ![A screenshot showing a list with leading 25 point inset on each
///  row.](SwiftUI-View-ListRowInsets.png)
///
/// - Parameter insets: The ``EdgeInsets`` to apply to the edges of the
///   view.
/// - Returns: A view that uses the given edge insets when used as a list
///   cell.
@inlinable public func listRowInsets(_ insets: EdgeInsets?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Presents an alert to the user.
///
/// Use this method when you need to show an alert that contains
/// information from a binding to an optional data source that you provide.
/// The example below shows a custom data source `FileInfo` whose
/// properties configure the alert's `message` field:
///
///     struct FileInfo: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///
///     struct ConfirmImportAlert: View {
///         @State private var alertDetails: FileInfo?
///         var body: some View {
///             Button("Show Alert") {
///                 alertDetails = FileInfo(name: "MyImageFile.png",
///                                         fileType: .png)
///             }
///             .alert(item: $alertDetails) { details in
///                 Alert(title: Text("Import Complete"),
///                       message: Text("""
///                         Imported \(details.name) \n File
///                         type: \(details.fileType.description).
///                         """),
///                       dismissButton: .default(Text("Dismiss")))
///             }
///         }
///     }
///
///
/// ![An alert showing information from a data source that describes the
/// result of a file import process. The alert displays the name of the
/// file imported, MyImageFile.png and its file type, the PNG image
/// file format along with a default OK button for dismissing the
/// alert.](SwiftUI-View-AlertItemContent.png)
///
/// - Parameters:
///   - item: A binding to an optional source of truth for the alert.
///     if `item` is non-`nil`, the system passes the contents to
///     the modifier's closure. You use this content to populate the fields
///     of an alert that you create that the system displays to the user.
///     If `item` changes, the system dismisses the currently displayed
///     alert and replaces it with a new one using the same process.
///   - content: A closure returning the alert to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
public func alert<Item>(item: Binding<Item?>, content: (Item) -> Alert) -> some View where Item : Identifiable
/// Presents an alert to the user.
///
/// Use this method when you need to show an alert to the user. The example
/// below displays an alert that is shown when the user toggles a
/// Boolean value that controls the presentation of the alert:
///
///     struct OrderCompleteAlert: View {
///         @State private var isPresented = false
///         var body: some View {
///             Button("Show Alert", action: {
///                 isPresented = true
///             })
///             .alert(isPresented: $isPresented) {
///                 Alert(title: Text("Order Complete"),
///                       message: Text("Thank you for shopping with us."),
///                       dismissButton: .default(Text("OK")))
///             }
///         }
///     }
///
/// ![An alert whose title reads Order Complete, with the
/// message, Thank you for shopping with us placed underneath. The alert
/// also includes an OK button for dismissing the
/// alert.](SwiftUI-View-AlertIsPresentedContent.png)
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the alert that you create in the modifier's `content` closure. When the
///      user presses or taps OK the system sets `isPresented` to `false`
///     which dismisses the alert.
///   - content: A closure returning the alert to present.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use `alert(title:isPresented:presenting::actions:) instead.")
public func alert(isPresented: Binding<Bool>, content: () -> Alert) -> some View
}
extension View {
/// Sets the scroll behavior of views scrollable in the provided axes.
///
/// A scrollable view calculates where scroll gestures should end using its
/// deceleration rate and the state of its scroll gesture by default. A
/// scroll behavior allows for customizing this logic. You can provide
/// your own ``ScrollTargetBehavior`` or use one of the built in behaviors
/// provided by SwiftUI.
///
/// ### Paging Behavior
///
/// SwiftUI offers a ``PagingScrollTargetBehavior`` behavior which uses the
/// geometry of the scroll view to decide where to allow scrolls to end.
///
/// In the following example, every view in the lazy stack is flexible
/// in both directions and the scroll view will settle to container aligned
/// boundaries.
///
///     ScrollView {
///         LazyVStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 FullScreenItem(item)
///             }
///         }
///     }
///     .scrollTargetBehavior(.paging)
///
/// ### View Aligned Behavior
///
/// SwiftUI offers a ``ViewAlignedScrollTargetBehavior`` scroll behavior
/// that will always settle on the geometry of individual views.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///     .safeAreaPadding(.horizontal, 20.0)
///
/// You configure which views should be used for settling using the
/// ``View/scrollTargetLayout(isEnabled:)`` modifier. Apply this modifier to
/// a layout container like ``LazyVStack`` or ``HStack`` and each individual
/// view in that layout will be considered for alignment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollTargetBehavior(_ behavior: some ScrollTargetBehavior) -> some View
}
extension View {
/// Configures the outermost layout as a scroll target layout.
///
/// This modifier works together with the
/// ``ViewAlignedScrollTargetBehavior`` to ensure that scroll views align
/// to view based content.
///
/// Apply this modifier to layout containers like ``LazyHStack`` or
/// ``VStack`` within a ``ScrollView`` that contain the main repeating
/// content of your ``ScrollView``.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///
/// Scroll target layouts act as a convenience for applying a
/// ``View/scrollTarget(isEnabled:)`` modifier to each views in
/// the layout.
///
/// A scroll target layout will ensure that any target layout
/// nested within the primary one will not also become a scroll
/// target layout.
///
///     LazyHStack { // a scroll target layout
///         VStack { ... } // not a scroll target layout
///         LazyHStack { ... } // also not a scroll target layout
///     }
///     .scrollTargetLayout()
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollTargetLayout(isEnabled: Bool = true) -> some View
}
extension View {
/// Positions this view within an invisible frame with a size relative
/// to the nearest container.
///
/// Use this modifier to specify a size for a view's width, height,
/// or both that is dependent on the size of the nearest container.
/// Different things can represent a "container" including:
///   - The window presenting a view on iPadOS or macOS, or the
///     screen of a device on iOS.
///   - A column of a NavigationSplitView
///   - A NavigationStack
///   - A tab of a TabView
///   - A scrollable view like ScrollView or List
///
/// The size provided to this modifier is the size of a container like
/// the ones listed above subtraacking any safe area insets that might
/// be applied to that container.
///
/// The following example will have each purple rectangle occupy the full
/// size of the screen on iOS:
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .containerRelativeFrame([.horizontal, .vertical])
///             }
///         }
///     }
///
/// Use the ``View/containerRelativeFrame(_:count:span:spacing:alignment:)``
/// modifier to size a view such that multiple views will be visible in
/// the container. When using this modifier, the count refers to the
/// total number of rows or columns that the length of the container size
/// in a particular axis should be divided into. The span refers to the
/// number of rows or columns that the modified view should actually
/// occupy. Thus the size of the element can be described like so:
///
///     let availableWidth = (containerWidth - (spacing * (count - 1)))
///     let columnWidth = (availableWidth / count)
///     let itemWidth = (columnWidth * span) + ((span - 1) * spacing)
///
/// The following example only uses the nearest container size in the
/// horizontal axis, allowing the vertical axis to be determined using
/// the ``View/aspectRatio(_:contentMode:)-771ow`` modifier.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .aspectRatio(3.0 / 2.0, contentMode: .fit)
///                     .containerRelativeFrame(
///                         .horizontal, count: 4, span: 3, spacing: 10.0)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// Use the ``View/containerRelativeFrame(_:alignment:_:)``
/// modifier to apply your own custom logic to adjust the size
/// of the nearest container for your view. The following example will
/// result in the container frame's width being divided by 3 and using
/// that value as the width of the purple rectangle.
///
///     Rectangle()
///         .fill(.purple)
///         .aspectRatio(1.0, contentMode: .fill)
///         .containerRelativeFrame(
///             .horizontal, alignment: .topLeading
///         ) { length, axis in
///             if axis == .vertical {
///                 return length / 3.0
///             } else {
///                 return length / 5.0
///             }
///         }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func containerRelativeFrame(_ axes: Axis.Set, alignment: Alignment = .center) -> some View
/// Positions this view within an invisible frame with a size relative
/// to the nearest container.
///
/// Use the ``View/containerRelativeFrame(_:alignment:)`` modifier
/// to specify a size for a view's width, height, or both that
/// is dependent on the size of the nearest container. Different
/// things can represent a "container" including:
///   - The window presenting a view on iPadOS or macOS, or the
///     screen of a device on iOS.
///   - A column of a NavigationSplitView
///   - A NavigationStack
///   - A tab of a TabView
///   - A scrollable view like ScrollView or List
///
/// The size provided to this modifier is the size of a container like
/// the ones listed above subtraacking any safe area insets that might
/// be applied to that container.
///
/// The following example will have each purple rectangle occupy the full
/// size of the screen on iOS:
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .containerRelativeFrame([.horizontal, .vertical])
///             }
///         }
///     }
///
/// Use this modifier to size a view such that multiple views will be
/// visible in the container. When using this modifier, the count refers
/// to the total number of rows or columns that the length of the
/// container size in a particular axis should be divided into. The span
/// refers to the number of rows or columns that the modified view
/// should actually occupy. Thus the size of the element can be
/// described like so:
///
///     let availableWidth = (containerWidth - (spacing * (count - 1)))
///     let columnWidth = (availableWidth / count)
///     let itemWidth = (columnWidth * span) + ((span - 1) * spacing)
///
/// The following example only uses the nearest container size in the
/// horizontal axis, allowing the vertical axis to be determined using
/// the ``View/aspectRatio(_:contentMode:)-771ow`` modifier.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .aspectRatio(3.0 / 2.0, contentMode: .fit)
///                     .containerRelativeFrame(
///                         .horizontal, count: 4, span: 3, spacing: 10.0)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// Use the ``View/containerRelativeFrame(_:alignment:_:)``
/// modifier to apply your own custom logic to adjust the size
/// of the nearest container for your view. The following example will
/// result in the container frame's width being divided by 3 and using
/// that value as the width of the purple rectangle.
///
///     Rectangle()
///         .fill(.purple)
///         .aspectRatio(1.0, contentMode: .fill)
///         .containerRelativeFrame(
///             .horizontal, alignment: .topLeading
///         ) { length, axis in
///             if axis == .vertical {
///                 return length / 3.0
///             } else {
///                 return length / 5.0
///             }
///         }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func containerRelativeFrame(_ axes: Axis.Set, count: Int, span: Int = 1, spacing: CGFloat, alignment: Alignment = .center) -> some View
/// Positions this view within an invisible frame with a size relative
/// to the nearest container.
///
/// Use the ``View/containerRelativeFrame(_:alignment:)`` modifier
/// to specify a size for a view's width, height, or both that
/// is dependent on the size of the nearest container. Different
/// things can represent a "container" including:
///   - The window presenting a view on iPadOS or macOS, or the
///     screen of a device on iOS.
///   - A column of a NavigationSplitView
///   - A NavigationStack
///   - A tab of a TabView
///   - A scrollable view like ScrollView or List
///
/// The size provided to this modifier is the size of a container like
/// the ones listed above subtraacking any safe area insets that might
/// be applied to that container.
///
/// The following example will have each purple rectangle occupy the full
/// size of the screen on iOS:
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 0.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .containerRelativeFrame([.horizontal, .vertical])
///             }
///         }
///     }
///
/// Use the ``View/containerRelativeFrame(_:count:spacing:alignment:)``
/// modifier to size a view such that multiple views will be
/// visible in the container. When using this modifier, the count
/// refers to the total number of rows or columns that the length of
/// the container size in a particular axis should be divided into.
/// The span refers to the number of rows or columns that the modified
/// view should actually occupy. Thus the size of the element can
/// be described like so:
///
///     let availableWidth = (containerWidth - (spacing * (count - 1)))
///     let columnWidth = (availableWidth / count)
///     let itemWidth = (columnWidth * span) + ((span - 1) * spacing)
///
/// The following example only uses the nearest container size in the
/// horizontal axis, allowing the vertical axis to be determined using
/// the ``View/aspectRatio(_:contentMode:)-771ow`` modifier.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 Rectangle()
///                     .fill(.purple)
///                     .aspectRatio(3.0 / 2.0, contentMode: .fit)
///                     .containerRelativeFrame(
///                         .horizontal, count: 4, span: 3, spacing: 10.0)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// Use this modifier to apply your own custom logic to adjust the size
/// of the nearest container for your view. The following example will
/// result in the container frame's width being divided by 3 and using
/// that value as the width of the purple rectangle.
///
///     Rectangle()
///         .fill(.purple)
///         .aspectRatio(1.0, contentMode: .fill)
///         .containerRelativeFrame(
///             .horizontal, alignment: .topLeading
///         ) { length, axis in
///             if axis == .vertical {
///                 return length / 3.0
///             } else {
///                 return length / 5.0
///             }
///         }
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func containerRelativeFrame(_ axes: Axis.Set, alignment: Alignment = .center, _ length: @escaping (CGFloat, Axis) -> CGFloat) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Associates a destination view with a presented data type for use within
/// a navigation stack.
///
/// Add this view modifer to a view inside a ``NavigationStack`` to
/// describe the view that the stack displays when presenting
/// a particular kind of data. Use a ``NavigationLink`` to present
/// the data. For example, you can present a `ColorDetail` view for
/// each presentation of a ``Color`` instance:
///
///     NavigationStack {
///         List {
///             NavigationLink("Mint", value: Color.mint)
///             NavigationLink("Pink", value: Color.pink)
///             NavigationLink("Teal", value: Color.teal)
///         }
///         .navigationDestination(for: Color.self) { color in
///             ColorDetail(color: color)
///         }
///         .navigationTitle("Colors")
///     }
///
/// You can add more than one navigation destination modifier to the stack
/// if it needs to present more than one kind of data.
///
/// Do not put a navigation destination modifier inside a "lazy" container,
/// like ``List`` or ``LazyVStack``. These containers create child views
/// only when needed to render on screen. Add the navigation destination
/// modifier outside these containers so that the navigation stack can
/// always see the destination.
///
/// - Parameters:
///   - data: The type of data that this destination matches.
///   - destination: A view builder that defines a view to display
///     when the stack's navigation state contains a value of
///     type `data`. The closure takes one argument, which is the value
///     of the data to present.
public func navigationDestination<D, C>(for data: D.Type, @ViewBuilder destination: @escaping (D) -> C) -> some View where D : Hashable, C : View
/// Associates a destination view with a binding that can be used to push
/// the view onto a ``NavigationStack``.
///
/// In general, favor binding a path to a navigation stack for programmatic
/// navigation. Add this view modifer to a view inside a ``NavigationStack``
/// to programmatically push a single view onto the stack. This is useful
/// for building components that can push an associated view. For example,
/// you can present a `ColorDetail` view for a particular color:
///
///     @State private var showDetails = false
///     var favoriteColor: Color
///
///     NavigationStack {
///         VStack {
///             Circle()
///                 .fill(favoriteColor)
///             Button("Show details") {
///                 showDetails = true
///             }
///         }
///         .navigationDestination(isPresented: $showDetails) {
///             ColorDetail(color: favoriteColor)
///         }
///         .navigationTitle("My Favorite Color")
///     }
///
/// Do not put a navigation destination modifier inside a "lazy" container,
/// like ``List`` or ``LazyVStack``. These containers create child views
/// only when needed to render on screen. Add the navigation destination
/// modifier outside these containers so that the navigation stack can
/// always see the destination.
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that indicates whether
///     `destination` is currently presented.
///   - destination: A view to present.
public func navigationDestination<V>(isPresented: Binding<Bool>, @ViewBuilder destination: () -> V) -> some View where V : View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Associates a destination view with a bound value for use within a
/// navigation stack or navigation split view
///
/// Add this view modifer to a view inside a ``NavigationStack`` or
/// ``NavigationSplitView`` to describe the view that the stack displays
/// when presenting a particular kind of data. Programmatically update
/// the binding to display or remove the view. For example, you can replace
/// the view showing in the detail column of a navigation split view:
///
///     @State private var colorShown: Color?
///
///     NavigationSplitView {
///         List {
///             Button("Mint") { colorShown = .mint }
///             Button("Pink") { colorShown = .pink }
///             Button("Teal") { colorShown = .teal }
///         }
///         .navigationDestination(item: $colorShown) { color in
///             ColorDetail(color: color)
///         }
///     } detail: {
///         Text("Select a color")
///     }
///
/// When the person using the app taps on the Mint button, the mint color
/// shows in the detail and `colorShown` gets the value `Color.mint`. You
/// can reset the navigation split view to show the message "Select a color"
/// by setting `colorShown` back to `nil`.
///
/// You can add more than one navigation destination modifier to the stack
/// if it needs to present more than one kind of data.
///
/// Do not put a navigation destination modifier inside a "lazy" container,
/// like ``List`` or ``LazyVStack``. These containers create child views
/// only when needed to render on screen. Add the navigation destination
/// modifier outside these containers so that the navigation split view can
/// always see the destination.
///
/// - Parameters:
///   - item: A binding to the data presented, or `nil` if nothing is
///     currently presented.
///   - destination: A view builder that defines a view to display
///     when `item` is not `nil`.
public func navigationDestination<D, C>(item: Binding<D?>, @ViewBuilder destination: @escaping (D) -> C) -> some View where D : Hashable, C : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an accessibility adjustable action to the view. Actions allow
/// assistive technologies, such as the VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how an adjustable action to navigate
/// through pages could be added to a view.
///
///     var body: some View {
///         PageControl()
///             .accessibilityAdjustableAction { direction in
///                 switch direction {
///                 case .increment:
///                     // Go to next page
///                 case .decrement:
///                     // Go to previous page
///                 }
///             }
///     }
///
public func accessibilityAdjustableAction(_ handler: @escaping (AccessibilityAdjustmentDirection) -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets an accessibility text content type.
///
/// Use this modifier to set the content type of this accessibility
/// element. Assistive technologies can use this property to choose
/// an appropriate way to output the text. For example, when
/// encountering a source coding context, VoiceOver could
/// choose to speak all punctuation.
///
/// The default content type ``AccessibilityTextContentType/plain``.
///
/// - Parameter value: The accessibility content type from the available
/// ``AccessibilityTextContentType`` options.
public func accessibilityTextContentType(_ value: AccessibilityTextContentType) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets the accessibility level of this heading.
///
/// Use this modifier to set the level of this heading in relation to other headings. The system speaks
/// the level number of levels ``AccessibilityHeadingLevel/h1`` through
///  ``AccessibilityHeadingLevel/h6`` alongside the text.
///
/// The default heading level if you don’t use this modifier
/// is ``AccessibilityHeadingLevel/unspecified``.
///
/// - Parameter level: The heading level to associate with this element
///   from the available ``AccessibilityHeadingLevel`` levels.
public func accessibilityHeading(_ level: AccessibilityHeadingLevel) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the alignment of a text view that contains multiple lines of text.
///
/// Use this modifier to set an alignment for a multiline block of text.
/// For example, the modifier centers the contents of the following
/// ``Text`` view:
///
///     Text("This is a block of text that shows up in a text element as multiple lines.\("\n") Here we have chosen to center this text.")
///         .frame(width: 200)
///         .multilineTextAlignment(.center)
///
/// The text in the above example spans more than one line because:
///
/// * The newline character introduces a line break.
/// * The frame modifier limits the space available to the text view, and
///   by default a text view wraps lines that don't fit in the available
///   width. As a result, the text before the explicit line break wraps to
///   three lines, and the text after uses two lines.
///
/// The modifier applies the alignment to the all the lines of text in
/// the view, regardless of why wrapping occurs:
///
/// ![A block of text that spans 5 lines. The lines of text are center-aligned.](View-multilineTextAlignment-1-iOS)
///
/// The modifier has no effect on a ``Text`` view that contains only one
/// line of text, because a text view has a width that exactly matches the
/// width of its widest line. If you want to align an entire text view
/// rather than its contents, set the aligment of its container, like a
/// ``VStack`` or a frame that you create with the
/// ``View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)``
/// modifier.
///
/// > Note: You can use this modifier to control the alignment of a ``Text``
///   view that you create with the ``Text/init(_:style:)`` initializer
///   to display localized dates and times, including when the view uses
///   only a single line, but only when that view appears in a widget.
///
/// The modifier also affects the content alignment of other text container
/// types, like ``TextEditor`` and ``TextField``. In those cases, the
/// modifier sets the alignment even when the view contains only a single
/// line because view's width isn't dictated by the width of the text it
/// contains.
///
/// The modifier operates by setting the
/// ``EnvironmentValues/multilineTextAlignment`` value in the environment,
/// so it affects all the text containers in the modified view hierarchy.
/// For example, you can apply the modifier to a ``VStack`` to
/// configure all the text views inside the stack.
///
/// - Parameter alignment: A value that you use to align multiple lines of
///   text within a view.
///
/// - Returns: A view that aligns the lines of multiline ``Text`` instances
///   it contains.
@inlinable public func multilineTextAlignment(_ alignment: TextAlignment) -> some View
/// Sets the truncation mode for lines of text that are too long to fit in
/// the available space.
///
/// Use the `truncationMode(_:)` modifier to determine whether text in a
/// long line is truncated at the beginning, middle, or end. Truncation is
/// indicated by adding an ellipsis (…) to the line when removing text to
/// indicate to readers that text is missing.
///
/// In the example below, the bounds of text view constrains the amount of
/// text that the view displays and the `truncationMode(_:)` specifies from
/// which direction and where to display the truncation indicator:
///
///     Text("This is a block of text that will show up in a text element as multiple lines. The text will fill the available space, and then, eventually, be truncated.")
///         .frame(width: 150, height: 150)
///         .truncationMode(.tail)
///
/// ![A screenshot showing the effect of truncation mode on text in a
/// view.](SwiftUI-view-truncationMode.png)
///
/// - Parameter mode: The truncation mode that specifies where to truncate
///   the text within the text view, if needed. You can truncate at the
///   beginning, middle, or end of the text view.
///
/// - Returns: A view that truncates text at different points in a line
///   depending on the mode you select.
@inlinable public func truncationMode(_ mode: Text.TruncationMode) -> some View
/// Sets the amount of space between lines of text in this view.
///
/// Use `lineSpacing(_:)` to set the amount of spacing from the bottom of
/// one line to the top of the next for text elements in the view.
///
/// In the ``Text`` view in the example below, 10 points separate the bottom
/// of one line to the top of the next as the text field wraps inside this
/// view. Applying `lineSpacing(_:)` to a view hierarchy applies the line
/// spacing to all text elements contained in the view.
///
///     Text("This is a string in a TextField with 10 point spacing applied between the bottom of one line and the top of the next.")
///         .frame(width: 200, height: 200, alignment: .leading)
///         .lineSpacing(10)
///
/// ![A screenshot showing the effects of setting line spacing on the text
/// in a view.](SwiftUI-view-lineSpacing.png)
///
/// - Parameter lineSpacing: The amount of space between the bottom of one
///   line and the top of the next line in points.
@inlinable public func lineSpacing(_ lineSpacing: CGFloat) -> some View
/// Sets whether text in this view can compress the space between characters
/// when necessary to fit text in a line.
///
/// Use `allowsTightening(_:)` to enable the compression of inter-character
/// spacing of text in a view to try to fit the text in the view's bounds.
///
/// In the example below, two identically configured text views show the
/// effects of `allowsTightening(_:)` on the compression of the spacing
/// between characters:
///
///     VStack {
///         Text("This is a wide text element")
///             .font(.body)
///             .frame(width: 200, height: 50, alignment: .leading)
///             .lineLimit(1)
///             .allowsTightening(true)
///
///         Text("This is a wide text element")
///             .font(.body)
///             .frame(width: 200, height: 50, alignment: .leading)
///             .lineLimit(1)
///             .allowsTightening(false)
///     }
///
/// ![A screenshot showing the effect of enabling text tightening in a
/// view.](SwiftUI-view-allowsTightening.png)
///
/// - Parameter flag: A Boolean value that indicates whether the space
///   between characters compresses when necessary.
///
/// - Returns: A view that can compress the space between characters when
///   necessary to fit text in a line.
@inlinable public func allowsTightening(_ flag: Bool) -> some View
/// Sets the minimum amount that text in this view scales down to fit in the
/// available space.
///
/// Use the `minimumScaleFactor(_:)` modifier if the text you place in a
/// view doesn't fit and it's okay if the text shrinks to accommodate. For
/// example, a label with a minimum scale factor of `0.5` draws its text in
/// a font size as small as half of the actual font if needed.
///
/// In the example below, the ``HStack`` contains a ``Text`` label with a
/// line limit of `1`, that is next to a ``TextField``. To allow the label
/// to fit into the available space, the `minimumScaleFactor(_:)` modifier
/// shrinks the text as needed to fit into the available space.
///
///     HStack {
///         Text("This is a long label that will be scaled to fit:")
///             .lineLimit(1)
///             .minimumScaleFactor(0.5)
///         TextField("My Long Text Field", text: $myTextField)
///     }
///
/// ![A screenshot showing the effect of setting a minimumScaleFactor on
/// text in a view.](SwiftUI-View-minimumScaleFactor.png)
///
/// - Parameter factor: A fraction between 0 and 1 (inclusive) you use to
///   specify the minimum amount of text scaling that this view permits.
///
/// - Returns: A view that limits the amount of text downscaling.
@inlinable public func minimumScaleFactor(_ factor: CGFloat) -> some View
/// Sets a transform for the case of the text contained in this view when
/// displayed.
///
/// The default value is `nil`, displaying the text without any case
/// changes.
///
/// - Parameter textCase: One of the ``Text/Case`` enumerations; the
///   default is `nil`.
/// - Returns: A view that transforms the case of the text.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@inlinable public func textCase(_ textCase: Text.Case?) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Plays the given keyframes when the given trigger value changes, updating
/// the view using the modifiers you apply in `body`.
///
/// Note that the `content` closure will be updated on every frame while
/// animating, so avoid performing any expensive operations directly within
/// `content`.
///
/// If the trigger value changes while animating, the `keyframes` closure
/// will be called with the current interpolated value, and the keyframes
/// that you return define a new animation that replaces the old one. The
/// previous velocity will be preserved, so cubic or spring keyframes will
/// maintain continuity from the previous animation if they do not specify
/// a custom initial velocity.
///
/// When a keyframe animation finishes, the animator will remain at the
/// end value, which becomes the initial value for the next animation.
///
/// - Parameters:
///   - initialValue: The initial value that the keyframes will animate
///     from.
///   - trigger: A value to observe for changes.
///   - content: A view builder closure that takes two parameters. The first
///     parameter is a proxy value representing the modified view. The
///     second parameter is the interpolated value generated by the
///     keyframes.
///   - keyframes: Keyframes defining how the value changes over time. The
///     current value of the animator is the single argument, which is
///     equal to `initialValue` when the view first appears, then is equal
///     to the end value of the previous keyframe animation on subsequent
///     calls.
public func keyframeAnimator<Value>(initialValue: Value, trigger: some Equatable, @ViewBuilder content: @escaping @Sendable (PlaceholderContentView<Self>, Value) -> some View, @KeyframesBuilder<Value> keyframes: @escaping (Value) -> some Keyframes) -> some View
/// Loops the given keyframes continuously, updating
/// the view using the modifiers you apply in `body`.
///
/// Note that the `content` closure will be updated on every frame while
/// animating, so avoid performing any expensive operations directly within
/// `content`.
///
/// - Parameters:
///   - initialValue: The initial value that the keyframes will animate
///     from.
///   - repeating: Whether the keyframes are currently repeating. If false,
///     the value at the beginning of the keyframe timeline will be
///     provided to the content closure.
///   - content: A view builder closure that takes two parameters. The first
///     parameter is a proxy value representing the modified view. The
///     second parameter is the interpolated value generated by the
///     keyframes.
///   - keyframes: Keyframes defining how the value changes over time. The
///     current value of the animator is the single argument, which is
///     equal to `initialValue` when the view first appears, then is equal
///     to the end value of the previous keyframe animation on subsequent
///     calls.
public func keyframeAnimator<Value>(initialValue: Value, repeating: Bool = true, @ViewBuilder content: @escaping @Sendable (PlaceholderContentView<Self>, Value) -> some View, @KeyframesBuilder<Value> keyframes: @escaping (Value) -> some Keyframes) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@available(visionOS, unavailable)
extension View {
/// Plays the specified `feedback` when the provided `trigger` value
/// changes.
///
/// For example, you could play feedback when a state value changes:
///
///     struct MyView: View {
///         @State private var showAccessory = false
///
///         var body: some View {
///             ContentView()
///                 .sensoryFeedback(.selection, trigger: showAccessory)
///                 .onLongPressGesture {
///                     showAccessory.toggle()
///                 }
///
///             if showAccessory {
///                 AccessoryView()
///             }
///         }
///     }
///
/// - Parameters:
///   - feedback: Which type of feedback to play.
///   - trigger: A value to monitor for changes to determine when to play.
public func sensoryFeedback<T>(_ feedback: SensoryFeedback, trigger: T) -> some View where T : Equatable
/// Plays the specified `feedback` when the provided `trigger` value changes
/// and the `condition` closure returns `true`.
///
/// For example, you could play feedback for certain state transitions:
///
///     struct MyView: View {
///         @State private var phase = Phase.inactive
///
///         var body: some View {
///             ContentView(phase: $phase)
///                 .sensoryFeedback(.selection, trigger: phase) { old, new in
///                     old == .inactive || new == .expanded
///                 }
///         }
///
///         enum Phase {
///             case inactive
///             case preparing
///             case active
///             case expanded
///         }
///     }
///
/// - Parameters:
///   - feedback: Which type of feedback to play.
///   - trigger: A value to monitor for changes to determine when to play.
///   - condition: A closure to determine whether to play the feedback when
///     `trigger` changes.
public func sensoryFeedback<T>(_ feedback: SensoryFeedback, trigger: T, condition: @escaping (_ oldValue: T, _ newValue: T) -> Bool) -> some View where T : Equatable
/// Plays feedback when returned from the `feedback` closure after the
/// provided `trigger` value changes.
///
/// For example, you could play different feedback for different state
/// transitions:
///
///     struct MyView: View {
///         @State private var phase = Phase.inactive
///
///         var body: some View {
///             ContentView(phase: $phase)
///                 .sensoryFeedback(trigger: phase) { old, new in
///                     switch (old, new) {
///                         case (.inactive, _): return .success
///                         case (_, .expanded): return .impact
///                         default: return nil
///                     }
///                 }
///         }
///
///         enum Phase {
///             case inactive
///             case preparing
///             case active
///             case expanded
///         }
///     }
///
/// - Parameters:
///   - trigger: A value to monitor for changes to determine when to play.
///   - feedback: A closure to determine whether to play the feedback and
///     what type of feedback to play when `trigger` changes.
public func sensoryFeedback<T>(trigger: T, _ feedback: @escaping (_ oldValue: T, _ newValue: T) -> SensoryFeedback?) -> some View where T : Equatable
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Defines the destination of a drag-and-drop operation that handles the
/// dropped content with a closure that you specify.
///
/// The drop destination is the same size and position as this view.
///
/// - Parameters:
///   - supportedContentTypes: The uniform type identifiers that describe the
///     types of content this view can accept through drag and drop.
///     If the drag-and-drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - isTargeted: A binding that updates when a drag and drop operation
///     enters or exits the drop target area. The binding's value is `true` when
///     the cursor is inside the area, and `false` when the cursor is outside.
///   - action: A closure that takes the dropped content and responds
///     appropriately. The parameter to `action` contains the dropped
///     items, with types specified by `supportedContentTypes`. Return `true`
///     if the drop operation was successful; otherwise, return `false`.
///
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
public func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping (_ providers: [NSItemProvider]) -> Bool) -> some View
/// Defines the destination of a drag and drop operation that handles the
/// dropped content with a closure that you specify.
///
/// The drop destination is the same size and position as this view.
///
/// - Parameters:
///   - supportedContentTypes: The uniform type identifiers that describe
///     the types of content this view can accept through drag and drop.
///     If the drag and drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - isTargeted: A binding that updates when a drag and drop operation
///     enters or exits the drop target area. The binding's value is `true` when
///     the cursor is inside the area, and `false` when the cursor is outside.
///   - action: A closure that takes the dropped content and responds
///     appropriately. The first parameter to `action` contains the dropped
///     items, with types specified by `supportedContentTypes`. The second
///     parameter contains the drop location in this view's coordinate
///     space. Return `true` if the drop operation was successful;
///     otherwise, return `false`.
///
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
public func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping (_ providers: [NSItemProvider], _ location: CGPoint) -> Bool) -> some View
/// Defines the destination of a drag and drop operation using behavior
/// controlled by the delegate that you provide.
///
/// The drop destination is the same size and position as this view.
///
/// - Parameters:
///   - supportedContentTypes: The uniform type identifiers that describe the
///     types of content this view can accept through drag and drop.
///     If the drag and drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - delegate: A type that conforms to the ``DropDelegate`` protocol. You
///     have comprehensive control over drop behavior when you use a
///     delegate.
///
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
public func onDrop(of supportedContentTypes: [UTType], delegate: DropDelegate) -> some View
}
extension View {
/// Defines the destination of a drag and drop operation that handles the
/// dropped content with a closure that you specify.
///
/// The dropped content can be provided as binary data, file URLs, or file promises.
///
/// The drop destination is the same size and position as this view.
///
///     @State private var isDropTargeted = false
///
///     var body: some View {
///         Color.pink
///             .frame(width: 400, height: 400)
///             .dropDestination(for: String.self) { receivedTitles, location in
///                 animateDrop(at: location)
///                 process(titles: receivedTitles)
///             } isTargeted: {
///                 isDropTargeted = $0
///             }
///     }
///
///     func process(titles: [String]) { ... }
///     func animateDrop(at: CGPoint) { ... }
///
/// - Parameters:
///   - payloadType: The expected type of the dropped models.
///   - action: A closure that takes the dropped content and responds
///     appropriately. The first parameter to `action` contains the dropped
///     items. The second
///     parameter contains the drop location in this view's coordinate
///     space. Return `true` if the drop operation was successful;
///     otherwise, return `false`.
///   - isTargeted: A closure that is called when a drag and drop operation
///     enters or exits the drop target area. The received value is `true` when
///     the cursor is inside the area, and `false` when the cursor is outside.
///
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified type.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func dropDestination<T>(for payloadType: T.Type = T.self, action: @escaping (_ items: [T], _ location: CGPoint) -> Bool, isTargeted: @escaping (Bool) -> Void = { _ in }) -> some View where T : Transferable
}
@available(iOS, introduced: 13.4, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.")
extension View {
/// Defines the destination for a drag and drop operation, using the same
/// size and position as this view, handling dropped content with the given
/// closure.
///
/// - Parameters:
///   - supportedTypes: The uniform type identifiers that describe the
///     types of content this view can accept through drag and drop.
///     If the drag and drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - isTargeted: A binding that updates when a drag and drop operation
///     enters or exits the drop target area. The binding's value is `true`
///     when the cursor is inside the area, and `false` when the cursor is
///     outside.
///   - action: A closure that takes the dropped content and responds
///     appropriately. The parameter to `action` contains the dropped
///     items, with types specified by `supportedTypes`. Return `true`
///     if the drop operation was successful; otherwise, return `false`.
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping (_ providers: [NSItemProvider]) -> Bool) -> some View
/// Defines the destination for a drag and drop operation with the same size
/// and position as this view, handling dropped content and the drop
/// location with the given closure.
///
/// - Parameters:
///   - supportedTypes: The uniform type identifiers that describe the
///     types of content this view can accept through drag and drop.
///     If the drag and drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - isTargeted: A binding that updates when a drag and drop operation
///     enters or exits the drop target area. The binding's value is `true`
///     when the cursor is inside the area, and `false` when the cursor is
///     outside.
///   - action: A closure that takes the dropped content and responds
///     appropriately. The first parameter to `action` contains the dropped
///     items, with types specified by `supportedTypes`. The second
///     parameter contains the drop location in this view's coordinate
///     space. Return `true` if the drop operation was successful;
///     otherwise, return `false`.
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping (_ providers: [NSItemProvider], _ location: CGPoint) -> Bool) -> some View
/// Defines the destination for a drag and drop operation with the same size
/// and position as this view, with behavior controlled by the given
/// delegate.
///
/// - Parameters:
///   - supportedTypes: The uniform type identifiers that describe the
///     types of content this view can accept through drag and drop.
///     If the drag and drop operation doesn't contain any of the supported
///     types, then this drop destination doesn't activate and `isTargeted`
///     doesn't update.
///   - delegate: A type that conforms to the `DropDelegate` protocol. You
///     have comprehensive control over drop behavior when you use a
///     delegate.
/// - Returns: A view that provides a drop destination for a drag
///   operation of the specified types.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Mark the receiver as their content might be invalidated.
///
/// Use this modifier to annotate views that display values that are derived
/// from the current state of your data and might be invalidated in
/// response of, for example, user interaction.
///
/// The view will change its appearance when ``RedactionReasons.invalidated``
/// is present in the environment.
///
/// In an interactive widget a view is invalidated from the moment the user
/// interacts with a control on the widget to the moment when a new timeline
/// update has been presented.
///
/// - Parameters:
///   - invalidatable: Whether the receiver content might be invalidated.
public func invalidatableContent(_ invalidatable: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Controls the display order of overlapping views.
///
/// Use `zIndex(_:)` when you want to control the front-to-back ordering of
/// views.
///
/// In this example there are two overlapping rotated rectangles. The
/// frontmost is represented by the larger index value.
///
///     VStack {
///         Rectangle()
///             .fill(Color.yellow)
///             .frame(width: 100, height: 100, alignment: .center)
///             .zIndex(1) // Top layer.
///
///         Rectangle()
///             .fill(Color.red)
///             .frame(width: 100, height: 100, alignment: .center)
///             .rotationEffect(.degrees(45))
///             // Here a zIndex of 0 is the default making
///             // this the bottom layer.
///     }
///
/// ![A screenshot showing two overlapping rectangles. The frontmost view is
/// represented by the larger zIndex value.](SwiftUI-View-zIndex.png)
///
/// - Parameter value: A relative front-to-back ordering for this view; the
///   default is `0`.
@inlinable public func zIndex(_ value: Double) -> some View
}
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Programmatically presents the find and replace interface for text
/// editor views.
///
/// Add this modifier to a ``TextEditor``, or to a view hierarchy that
/// contains at least one text editor, to control the presentation of
/// the find and replace interface. When you set the `isPresented` binding
/// to `true`, the system shows the interface, and when you set it to
/// `false`, the system hides the interface. The following example shows
/// and hides the interface based on the state of a toolbar button:
///
///     TextEditor(text: $text)
///         .findNavigator(isPresented: $isPresented)
///         .toolbar {
///             Toggle(isOn: $isPresented) {
///                 Label("Find", systemImage: "magnifyingglass")
///             }
///         }
///
/// The find and replace interface allows people to search for instances
/// of a specified string in the text editor, and optionally to replace
/// instances of the search string with another string. They can also
/// show and hide the interface using built-in controls, like menus and
/// keyboard shortcuts. SwiftUI updates `isPresented` to reflect the
/// users's actions.
///
/// If the text editor view isn't currently in focus, the system still
/// presents the find and replace interface when you set `isPresented`
/// to `true`. If the view hierarchy contains multiple editors, the one
/// that shows the find and replace interface is nondeterministic.
///
/// You can disable the find and replace interface for a text editor by
/// applying the ``View/findDisabled(_:)`` modifier to the editor. If you
/// do that, setting this modifier's `isPresented` binding to `true` has
/// no effect, but only if the disabling modifier appears closer to the
/// text editor, like this:
///
///     TextEditor(text: $text)
///         .findDisabled(isDisabled)
///         .findNavigator(isPresented: $isPresented)
///
/// - Parameter isPresented: A binding to a Boolean value that controls the
///   presentation of the find and replace interface.
///
/// - Returns: A view that presents the find and replace interface when
///   `isPresented` is `true`.
public func findNavigator(isPresented: Binding<Bool>) -> some View
/// Prevents find and replace operations in a text editor.
///
/// Add this modifier to ensure that people can't activate the find
/// and replace interface for a ``TextEditor``:
///
///     TextEditor(text: $text)
///         .findDisabled()
///
/// When you disable the find operation, you also implicitly disable the
/// replace operation. If you want to only disable replace, use
/// ``View/replaceDisabled(_:)`` instead.
///
/// Using this modifer also prevents programmatic find and replace
/// interface presentation using the ``View/findNavigator(isPresented:)``
/// method. Be sure to place the disabling modifier closer to the text
/// editor for this to work:
///
///     TextEditor(text: $text)
///         .findDisabled(isDisabled)
///         .findNavigator(isPresented: $isPresented)
///
/// If you apply this modifer at multiple levels of a view hierarchy,
/// the call closest to the text editor takes precedence. For example,
/// people can activate find and replace for the first text editor
/// in the following example, but not the second:
///
///     VStack {
///         TextEditor(text: $text1)
///             .findDisabled(false)
///         TextEditor(text: $text2)
///     }
///     .findDisabled(true)
///
/// - Parameter isDisabled: A Boolean value that indicates whether to
///   disable the find and replace interface for a text editor.
///
/// - Returns: A view that disables the find and replace interface.
public func findDisabled(_ isDisabled: Bool = true) -> some View
/// Prevents replace operations in a text editor.
///
/// Add this modifier to ensure that people can't activate the replace
/// feature of a find and replace interface for a ``TextEditor``:
///
///     TextEditor(text: $text)
///         .replaceDisabled()
///
/// If you want to disable both find and replace, use the
/// ``View/findDisabled(_:)`` modifier instead.
///
/// Using this modifer also disables the replace feature of a find and
/// replace interface that you present programmatically using the
/// ``View/findNavigator(isPresented:)`` method. Be sure to place the
/// disabling modifier closer to the text editor for this to work:
///
///     TextEditor(text: $text)
///         .replaceDisabled(isDisabled)
///         .findNavigator(isPresented: $isPresented)
///
/// If you apply this modifer at multiple levels of a view hierarchy,
/// the call closest to the text editor takes precedence. For example,
/// people can activate find and replace for the first text editor
/// in the following example, but only find for the second:
///
///     VStack {
///         TextEditor(text: $text1)
///             .replaceDisabled(false)
///         TextEditor(text: $text2)
///     }
///     .replaceDisabled(true)
///
/// - Parameter isDisabled: A Boolean value that indicates whether text
///   replacement in the find and replace interface is disabled.
///
/// - Returns: A view that disables the replace feature of a find and
///   replace interface.
public func replaceDisabled(_ isDisabled: Bool = true) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Returns a new view configured with the specified allowed
/// dynamic range.
///
/// The following example enables HDR rendering within a view
/// hierarchy:
///
///     MyView().allowedDynamicRange(.high)
///
/// - Parameter range: the requested dynamic range, or nil to
///   restore the default allowed range.
///
/// - Returns: a new view.
public func allowedDynamicRange(_ range: Image.DynamicRange?) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets whether VoiceOver should always speak all punctuation in the text
/// view.
///
/// Use this modifier to control whether the system speaks punctuation
/// characters in the text. You might use this for code or other text where
/// the punctuation is relevant, or where you want VoiceOver to speak a
/// verbatim transcription of the text you provide. For example, given the
/// text:
///
///     Text("All the world's a stage, " +
///          "And all the men and women merely players;")
///          .speechAlwaysIncludesPunctuation()
///
/// VoiceOver would speak "All the world apostrophe s a stage comma and all
/// the men and women merely players semicolon".
///
/// By default, VoiceOver voices punctuation based on surrounding context.
///
/// - Parameter value: A Boolean value that you set to `true` if
///   VoiceOver should speak all punctuation in the text. Defaults to `true`.
public func speechAlwaysIncludesPunctuation(_ value: Bool = true) -> some View
/// Sets whether VoiceOver should speak the contents of the text view
/// character by character.
///
/// Use this modifier when you want VoiceOver to speak text as individual
/// letters, character by character. This is important for text that is not
/// meant to be spoken together, like:
/// - An acronym that isn't a word, like APPL, spoken as "A-P-P-L".
/// - A number representing a series of digits, like 25, spoken as "two-five"
///   rather than "twenty-five".
///
/// - Parameter value: A Boolean value that when `true` indicates
///    VoiceOver should speak text as individual characters. Defaults
///    to `true`.
public func speechSpellsOutCharacters(_ value: Bool = true) -> some View
/// Raises or lowers the pitch of spoken text.
///
/// Use this modifier when you want to change the pitch of spoken text.
/// The value indicates how much higher or lower to change the pitch.
///
/// - Parameter value: The amount to raise or lower the pitch.
///   Values between `-1` and `0` result in a lower pitch while
///   values between `0` and `1` result in a higher pitch.
///   The method clamps values to the range `-1` to `1`.
public func speechAdjustedPitch(_ value: Double) -> some View
/// Controls whether to queue pending announcements behind existing speech
/// rather than interrupting speech in progress.
///
/// Use this modifier when you want affect the order in which the
/// accessibility system delivers spoken text. Announcements can
/// occur automatically when the label or value of an accessibility
/// element changes.
///
/// - Parameter value: A Boolean value that determines if VoiceOver speaks
///   changes to text immediately or enqueues them behind existing speech.
///   Defaults to `true`.
public func speechAnnouncementsQueued(_ value: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the specified style to render backgrounds within the view.
///
/// The following example uses this modifier to set the
/// ``EnvironmentValues/backgroundStyle`` environment value to a
/// ``ShapeStyle/blue`` color that includes a subtle ``Color/gradient``.
/// SwiftUI fills the ``Circle`` shape that acts as a background element
/// with this style:
///
///     Image(systemName: "swift")
///         .padding()
///         .background(in: Circle())
///         .backgroundStyle(.blue.gradient)
///
/// ![An image of the Swift logo inside a circle that's blue with a slight
/// linear gradient. The blue color is slightly lighter at the top of the
/// circle and slightly darker at the bottom.](View-backgroundStyle-1-iOS)
///
/// To restore the default background style, set the
/// ``EnvironmentValues/backgroundStyle`` environment value to
/// `nil` using the ``View/environment(_:_:)`` modifer:
///
///     .environment(\.backgroundStyle, nil)
///
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@inlinable public func backgroundStyle<S>(_ style: S) -> some View where S : ShapeStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the view's horizontal alignment.
///
/// Use `alignmentGuide(_:computeValue:)` to calculate specific offsets
/// to reposition views in relationship to one another. You can return a
/// constant or can use the ``ViewDimensions`` argument to the closure to
/// calculate a return value.
///
/// In the example below, the ``HStack`` is offset by a constant of 50
/// points to the right of center:
///
///     VStack {
///         Text("Today's Weather")
///             .font(.title)
///             .border(.gray)
///         HStack {
///             Text("🌧")
///             Text("Rain & Thunderstorms")
///             Text("⛈")
///         }
///         .alignmentGuide(HorizontalAlignment.center) { _ in  50 }
///         .border(.gray)
///     }
///     .border(.gray)
///
/// Changing the alignment of one view may have effects on surrounding
/// views. Here the offset values inside a stack and its contained views is
/// the difference of their absolute offsets.
///
/// ![A view showing the two emoji offset from a text element using a
/// horizontal alignment guide.](SwiftUI-View-HAlignmentGuide.png)
///
/// - Parameters:
///   - g: A ``HorizontalAlignment`` value at which to base the offset.
///   - computeValue: A closure that returns the offset value to apply to
///     this view.
///
/// - Returns: A view modified with respect to its horizontal alignment
///   according to the computation performed in the method's closure.
@inlinable public func alignmentGuide(_ g: HorizontalAlignment, computeValue: @escaping (ViewDimensions) -> CGFloat) -> some View
/// Sets the view's vertical alignment.
///
/// Use `alignmentGuide(_:computeValue:)` to calculate specific offsets
/// to reposition views in relationship to one another. You can return a
/// constant or can use the ``ViewDimensions`` argument to the closure to
/// calculate a return value.
///
/// In the example below, the weather emoji are offset 20 points from the
/// vertical center of the ``HStack``.
///
///     VStack {
///         Text("Today's Weather")
///             .font(.title)
///             .border(.gray)
///
///         HStack {
///             Text("🌧")
///                 .alignmentGuide(VerticalAlignment.center) { _ in -20 }
///                 .border(.gray)
///             Text("Rain & Thunderstorms")
///                 .border(.gray)
///             Text("⛈")
///                 .alignmentGuide(VerticalAlignment.center) { _ in 20 }
///                 .border(.gray)
///         }
///     }
///
/// Changing the alignment of one view may have effects on surrounding
/// views. Here the offset values inside a stack and its contained views is
/// the difference of their absolute offsets.
///
/// ![A view showing the two emoji offset from a text element using a
/// vertical alignment guide.](SwiftUI-View-VAlignmentGuide.png)
///
/// - Parameters:
///   - g: A ``VerticalAlignment`` value at which to base the offset.
///   - computeValue: A closure that returns the offset value to apply to
///     this view.
///
/// - Returns: A view modified with respect to its vertical alignment
///   according to the computation performed in the method's closure.
@inlinable public func alignmentGuide(_ g: VerticalAlignment, computeValue: @escaping (ViewDimensions) -> CGFloat) -> some View
}
extension View {
/// Configures the search scopes for this view.
///
/// To enable people to narrow the scope of their searches, you can
/// create a type that represents the possible scopes, and then create a
/// state variable to hold the current selection. For example, you can
/// scope the product search to just fruits or just vegetables:
///
///     enum ProductScope {
///         case fruit
///         case vegetable
///     }
///
///     @State private var scope: ProductScope = .fruit
///
/// Provide a binding to the scope, as well as a view that represents each
/// scope:
///
///     ProductList()
///         .searchable(text: $text, tokens: $tokens) { token in
///             switch token {
///             case .apple: Text("Apple")
///             case .pear: Text("Pear")
///             case .banana: Text("Banana")
///             }
///         }
///         .searchScopes($scope) {
///             Text("Fruit").tag(ProductScope.fruit)
///             Text("Vegetable").tag(ProductScope.vegetable)
///         }
///
/// SwiftUI uses this binding and view to add a ``Picker`` with the search
/// field. In iOS, iPadOS, macOS, and tvOS, the picker appears below the
/// search field when search is active. To ensure that the picker operates
/// correctly, match the type of the scope binding with the type of each
/// view's tag. Then modify your search to account for the current value of
/// the `scope` state property.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - scope: The active scope of the search field.
///   - scopes: A view builder that represents the scoping options
///     SwiftUI uses to populate a ``Picker``.
@available(iOS 16.0, macOS 13.0, tvOS 16.4, *)
@available(watchOS, unavailable)
public func searchScopes<V, S>(_ scope: Binding<V>, @ViewBuilder scopes: () -> S) -> some View where V : Hashable, S : View
}
extension View {
/// Configures the search scopes for this view with the specified
/// activation strategy.
///
/// To enable people to narrow the scope of their searches, you can
/// create a type that represents the possible scopes, and then create a
/// state variable to hold the current selection. For example, you can
/// scope the product search to just fruits or just vegetables:
///
///     enum ProductScope {
///         case fruit
///         case vegetable
///     }
///
///     @State private var scope: ProductScope = .fruit
///
/// Provide a binding to the scope, as well as a view that represents each
/// scope:
///
///     ProductList()
///         .searchable(text: $text, tokens: $tokens) { token in
///             switch token {
///             case .apple: Text("Apple")
///             case .pear: Text("Pear")
///             case .banana: Text("Banana")
///             }
///         }
///         .searchScopes($scope) {
///             Text("Fruit").tag(ProductScope.fruit)
///             Text("Vegetable").tag(ProductScope.vegetable)
///         }
///
/// SwiftUI uses this binding and view to add a ``Picker`` below the search
/// field. In iOS, macOS, and tvOS, the picker appears below the search
/// field when search is active. To ensure that the picker operates
/// correctly, match the type of the scope binding with the type of each
/// view's tag. Then condition your search on the current value of the
/// `scope` state property.
///
/// By default, the appearance of scopes varies by platform:
///   - In iOS and iPadOS, search scopes appear when someone enters text
///     into the search field and disappear when someone cancels the search.
///   - In macOS, search scopes appear when SwiftUI presents search and
///     disappear when someone cancels the search.
///
/// However, you can use the `activation` parameter with a value of
/// ``SearchScopeActivation/onTextEntry`` or
/// ``SearchScopeActivation/onSearchPresentation`` to configure this
/// behavior:
///
///     .searchScopes($scope, activation: .onSearchPresentation) {
///         Text("Fruit").tag(ProductScope.fruit)
///         Text("Vegetable").tag(ProductScope.vegetable)
///     }
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - scope: The active scope of the search field.
///   - activation: The activation style of the search field's scopes.
///   - scopes: A view builder that represents the scoping options
///     SwiftUI uses to populate a ``Picker``.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, *)
@available(watchOS, unavailable)
public func searchScopes<V, S>(_ scope: Binding<V>, activation: SearchScopeActivation, @ViewBuilder _ scopes: () -> S) -> some View where V : Hashable, S : View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Returns a new view with its inherited symbol image effects
/// either removed or left unchanged.
///
/// The following example adds a repeating pulse effect to two
/// symbol images, but then disables the effect on one of them:
///
///     VStack {
///         Image(systemName: "bolt.slash.fill") // does not pulse
///             .symbolEffectsRemoved()
///         Image(systemName: "folder.fill.badge.person.crop") // pulses
///     }
///     .symbolEffect(.pulse)
///
/// - Parameter isEnabled: Whether to remove inherited symbol
///   effects or not.
///
/// - Returns: a copy of the view with its symbol effects either
///   removed or left unchanged.
public func symbolEffectsRemoved(_ isEnabled: Bool = true) -> some View
}
extension View {
/// Adds a condition that controls whether users can select this view.
///
/// Use this modifier to control the selectability of views in
/// selectable containers like ``List`` or ``Table``. In the example,
/// below, the user can't select the first item in the list.
///
///     @Binding var selection: Item.ID?
///     @Binding var items: [Item]
///
///     var body: some View {
///         List(selection: $selection) {
///             ForEach(items) { item in
///                 ItemView(item: item)
///                     .selectionDisabled(item.id == items.first?.id)
///             }
///         }
///     }
///
/// You can also use this modifier to specify the selectability of views
/// within a `Picker`. The following example represents a flavor picker
/// that disables selection on flavors that are unavailable.
///
///     Picker("Flavor", selection: $selectedFlavor) {
///         ForEach(Flavor.allCases) { flavor in
///             Text(flavor.rawValue.capitalized)
///                 .selectionDisabled(isSoldOut(flavor))
///         }
///     }
///
/// - Parameter isDisabled: A Boolean value that determines whether users can
///   select this view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func selectionDisabled(_ isDisabled: Bool = true) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Advertises a user activity type.
///
/// You can use `userActivity(_:isActive:_:)` to start, stop, or modify the
/// advertisement of a specific type of user activity.
///
/// The scope of the activity applies only to the scene or window the
/// view is in.
///
/// - Parameters:
///   - activityType: The type of activity to advertise.
///   - isActive: When `false`, avoids advertising the activity. Defaults
///     to `true`.
///   - update: A function that modifies the passed-in activity for
///     advertisement.
public func userActivity(_ activityType: String, isActive: Bool = true, _ update: @escaping (NSUserActivity) -> ()) -> some View
/// Advertises a user activity type.
///
/// The scope of the activity applies only to the scene or window the
/// view is in.
///
/// - Parameters:
///   - activityType: The type of activity to advertise.
///   - element: If the element is `nil`, the handler will not be
///     associated with the activity (and if there are no handlers, no
///     activity is advertised). The method passes the non-`nil` element to
///     the handler as a convenience so the handlers don't all need to
///     implement an early exit with
///     `guard element = element else { return }`.
///    - update: A function that modifies the passed-in activity for
///    advertisement.
public func userActivity<P>(_ activityType: String, element: P?, _ update: @escaping (P, NSUserActivity) -> ()) -> some View
/// Registers a handler to invoke when the view receives the specified
/// activity type for the scene or window the view is in.
///
/// - Parameters:
///   - activityType: The type of activity to handle.
///   - action: A function to call that takes a
///     <doc://com.apple.documentation/documentation/Foundation/NSUserActivity>
///     object as its parameter
///     when delivering the activity to the scene or window the view is in.
public func onContinueUserActivity(_ activityType: String, perform action: @escaping (NSUserActivity) -> ()) -> some View
/// Registers a handler to invoke when the view receives a url for the
/// scene or window the view is in.
///
/// > Note: This method handles the reception of Universal Links,
///   rather than a
///   <doc://com.apple.documentation/documentation/Foundation/NSUserActivity>.
///
/// - Parameter action: A function that takes a
///  <doc://com.apple.documentation/documentation/Foundation/URL>
///  object as its parameter when delivering the URL to the scene or window
///  the view is in.
public func onOpenURL(perform action: @escaping (URL) -> ()) -> some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Specifies a modifier indicating the Scene this View
/// is in can handle matching incoming External Events.
///
/// If no modifier is set in any Views within a Scene, the behavior
/// is platform dependent. On macOS, a new Scene will be created to
/// use for the External Event. On iOS, the system will choose an
/// existing Scene to use.
///
/// On platforms that only allow a single Window/Scene, this method is
/// ignored, and incoming External Events are always routed to the
/// existing single Scene.
///
/// - Parameter preferring: A Set of Strings that are checked to see
/// if they are contained in the targetContentIdenfifier to see if
/// the Scene this View is in prefers to handle the Exernal Event.
/// The empty Set and empty Strings never match. The String value
/// "*" always matches. The String comparisons are case/diacritic
/// insensitive
///
/// - Parameter allowing: A Set of Strings that are checked to see
/// if they are contained in the targetContentIdenfifier to see if
/// the Scene this View is in allows handling the External Event.
/// The empty Set and empty Strings never match. The String value
/// "*" always matches.
public func handlesExternalEvents(preferring: Set<String>, allowing: Set<String>) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Transforms the environment value of the specified key path with the
/// given function.
@inlinable public func transformEnvironment<V>(_ keyPath: WritableKeyPath<EnvironmentValues, V>, transform: @escaping (inout V) -> Void) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Returns a new view that applies `shader` to `self` as a filter
/// effect on the color of each pixel.
///
/// For a shader function to act as a color filter it must have a
/// function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position, half4 color, args...)
///
/// where `position` is the user-space coordinates of the pixel
/// applied to the shader and `color` its source color, as a
/// pre-multiplied color in the destination color space. `args...`
/// should be compatible with the uniform arguments bound to
/// `shader`. The function should return the modified color value.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply to `self` as a color filter.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a color filter.
public func colorEffect(_ shader: Shader, isEnabled: Bool = true) -> some View
/// Returns a new view that applies `shader` to `self` as a
/// geometric distortion effect on the location of each pixel.
///
/// For a shader function to act as a distortion effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] float2 name(float2 position, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader. `args...` should be
/// compatible with the uniform arguments bound to `shader`. The
/// function should return the user-space coordinates of the
/// corresponding source pixel.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply as a distortion effect.
///   - maxSampleOffset: The maximum distance in each axis between
///     the returned source pixel position and the destination pixel
///     position, for all source pixels.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a distortion effect.
public func distortionEffect(_ shader: Shader, maxSampleOffset: CGSize, isEnabled: Bool = true) -> some View
/// Returns a new view that applies `shader` to `self` as a filter
/// on the raster layer created from `self`.
///
/// For a shader function to act as a layer effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position,
///       SwiftUI::Layer layer, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader, and `layer` is a
/// subregion of the rasterized contents of `self`. `args...`
/// should be compatible with the uniform arguments bound to
/// `shader`.
///
/// The `SwiftUI::Layer` type is defined in the
/// `<SwiftUI/SwiftUI.h>` header file. It exports a single
/// `sample()` function that returns a linearly-filtered pixel
/// value from a position in the source content, as a premultiplied
/// RGBA pixel value:
///
///     namespace SwiftUI {
///       struct Layer {
///         half4 sample(float2 position) const;
///       };
///     };
///
/// The function should return the color mapping to the destination
/// pixel, typically by sampling one or more pixels from `layer` at
/// location(s) derived from `position` and them applying some kind
/// of transformation to produce a new color.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply as a layer effect.
///   - maxSampleOffset: If the shader function samples from the
///     layer at locations not equal to the destination position,
///     this value must specify the maximum sampling distance in
///     each axis, for all source pixels.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a distortion effect.
public func layerEffect(_ shader: Shader, maxSampleOffset: CGSize, isEnabled: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies a transformation to a preference value.
@inlinable public func transformPreference<K>(_ key: K.Type = K.self, _ callback: @escaping (inout K.Value) -> Void) -> some View where K : PreferenceKey
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an action to perform when this view detects data emitted by the
/// given publisher.
///
/// - Parameters:
///   - publisher: The publisher to subscribe to.
///   - action: The action to perform when an event is emitted by
///     `publisher`. The event emitted by publisher is passed as a
///     parameter to `action`.
///
/// - Returns: A view that triggers `action` when `publisher` emits an
///   event.
@inlinable public func onReceive<P>(_ publisher: P, perform action: @escaping (P.Output) -> Void) -> some View where P : Publisher, P.Failure == Never
}
@available(iOS 14.0, macOS 11.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Sets the style for menus within this view.
///
/// To set a specific style for all menu instances within a view, use the
/// `menuStyle(_:)` modifier:
///
///     Menu("PDF") {
///         Button("Open in Preview", action: openInPreview)
///         Button("Save as PDF", action: saveAsPDF)
///     }
///     .menuStyle(ButtonMenuStyle())
///
public func menuStyle<S>(_ style: S) -> some View where S : MenuStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Fixes this view at its ideal size in the specified dimensions.
///
/// This function behaves like ``View/fixedSize()``, except with
/// `fixedSize(horizontal:vertical:)` the fixing of the axes can be
/// optionally specified in one or both dimensions. For example, if you
/// horizontally fix a text view before wrapping it in the frame view,
/// you're telling the text view to maintain its ideal _width_. The view
/// calculates this to be the space needed to represent the entire string.
///
///     Text("A single line of text, too long to fit in a box.")
///         .fixedSize(horizontal: true, vertical: false)
///         .frame(width: 200, height: 200)
///         .border(Color.gray)
///
/// This can result in the view exceeding the parent's bounds, which may or
/// may not be the effect you want.
///
/// ![A screenshot showing a text view exceeding the bounds of its
/// parent.](SwiftUI-View-fixedSize-3.png)
///
/// - Parameters:
///   - horizontal: A Boolean value that indicates whether to fix the width
///     of the view.
///   - vertical: A Boolean value that indicates whether to fix the height
///     of the view.
///
/// - Returns: A view that fixes this view at its ideal size in the
///   dimensions specified by `horizontal` and `vertical`.
@inlinable public func fixedSize(horizontal: Bool, vertical: Bool) -> some View
/// Fixes this view at its ideal size.
///
/// During the layout of the view hierarchy, each view proposes a size to
/// each child view it contains. If the child view doesn't need a fixed size
/// it can accept and conform to the size offered by the parent.
///
/// For example, a ``Text`` view placed in an explicitly sized frame wraps
/// and truncates its string to remain within its parent's bounds:
///
///     Text("A single line of text, too long to fit in a box.")
///         .frame(width: 200, height: 200)
///         .border(Color.gray)
///
/// ![A screenshot showing the text in a text view contained within its
/// parent.](SwiftUI-View-fixedSize-1.png)
///
/// The `fixedSize()` modifier can be used to create a view that maintains
/// the *ideal size* of its children both dimensions:
///
///     Text("A single line of text, too long to fit in a box.")
///         .fixedSize()
///         .frame(width: 200, height: 200)
///         .border(Color.gray)
///
/// This can result in the view exceeding the parent's bounds, which may or
/// may not be the effect you want.
///
/// ![A screenshot showing a text view exceeding the bounds of its
/// parent.](SwiftUI-View-fixedSize-2.png)
///
/// You can think of `fixedSize()` as the creation of a *counter proposal*
/// to the view size proposed to a view by its parent. The ideal size of a
/// view, and the specific effects of `fixedSize()` depends on the
/// particular view and how you have configured it.
///
/// To create a view that fixes the view's size in either the horizontal or
/// vertical dimensions, see ``View/fixedSize(horizontal:vertical:)``.
///
/// - Returns: A view that fixes this view at its ideal size.
@inlinable public func fixedSize() -> some View
}
extension View {
/// Sets this view's color scheme.
///
/// Use `colorScheme(_:)` to set the color scheme for the view to which you
/// apply it and any subviews. If you want to set the color scheme for all
/// views in the presentation, use ``View/preferredColorScheme(_:)``
/// instead.
///
/// - Parameter colorScheme: The color scheme for this view.
///
/// - Returns: A view that sets this view's color scheme.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@inlinable public func colorScheme(_ colorScheme: ColorScheme) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets whether this view mirrors its contents horizontally when the layout
/// direction is right-to-left.
///
/// Use `flipsForRightToLeftLayoutDirection(_:)` when you need the system to
/// horizontally mirror the contents of the view when presented in
/// a right-to-left layout.
///
/// To override the layout direction for a specific view, use the
/// ``View/environment(_:_:)`` view modifier to explicitly override
/// the ``EnvironmentValues/layoutDirection`` environment value for
/// the view.
///
/// - Parameter enabled: A Boolean value that indicates whether this view
///   should have its content flipped horizontally when the layout
///   direction is right-to-left. By default, views will adjust their layouts
///   automatically in a right-to-left context and do not need to be mirrored.
///
/// - Returns: A view that conditionally mirrors its contents
///   horizontally when the layout direction is right-to-left.
@inlinable public func flipsForRightToLeftLayoutDirection(_ enabled: Bool) -> some View
}
@available(iOS 17.0, macOS 14.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the style for text editors within this view.
public func textEditorStyle(_ style: some TextEditorStyle) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for toggles in a view hierarchy.
///
/// Use this modifier on a ``Toggle`` instance to set a style that defines
/// the control's appearance and behavior. For example, you can choose
/// the ``ToggleStyle/switch`` style:
///
///     Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
///         .toggleStyle(.switch)
///
/// Built-in styles typically have a similar appearance across platforms,
/// tailored to the platform's overall style:
///
/// | Platform    | Appearance |
/// |-------------|------------|
/// | iOS, iPadOS | ![A screenshot of the text Vibrate on Ring appearing to the left of a toggle switch that's on. The toggle's tint color is green. The toggle and its text appear in a rounded rectangle.](View-toggleStyle-1-iOS) |
/// | macOS       | ![A screenshot of the text Vibrate on Ring appearing to the left of a toggle switch that's on. The toggle's tint color is blue. The toggle and its text appear on a neutral background.](View-toggleStyle-1-macOS) |
///
/// ### Styling toggles in a hierarchy
///
/// You can set a style for all toggle instances within a view hierarchy
/// by applying the style modifier to a container view. For example, you
/// can apply the ``ToggleStyle/button`` style to an ``HStack``:
///
///     HStack {
///         Toggle(isOn: $isFlagged) {
///             Label("Flag", systemImage: "flag.fill")
///         }
///         Toggle(isOn: $isMuted) {
///             Label("Mute", systemImage: "speaker.slash.fill")
///         }
///     }
///     .toggleStyle(.button)
///
/// The example above has the following appearance when `isFlagged` is
/// `true` and `isMuted` is `false`:
///
/// | Platform    | Appearance |
/// |-------------|------------|
/// | iOS, iPadOS | ![A screenshot of two buttons arranged horizontally. The first has the image of a flag and is active with a blue tint. The second has an image of a speaker with a line through it and is inactive with a neutral tint.](View-toggleStyle-2-iOS) |
/// | macOS       | ![A screenshot of two buttons arranged horizontally. The first has the image of a flag and is active with a blue tint. The second has an image of a speaker with a line through it and is inactive with a neutral tint.](View-toggleStyle-2-macOS) |
///
/// ### Automatic styling
///
/// If you don't set a style, SwiftUI assumes a value of
/// ``ToggleStyle/automatic``, which corresponds to a context-specific
/// default. Specify the automatic style explicitly to override a
/// container's style and revert to the default:
///
///     HStack {
///         Toggle(isOn: $isShuffling) {
///             Label("Shuffle", systemImage: "shuffle")
///         }
///         Toggle(isOn: $isRepeating) {
///             Label("Repeat", systemImage: "repeat")
///         }
///
///         Divider()
///
///         Toggle("Enhance Sound", isOn: $isEnhanced)
///             .toggleStyle(.automatic) // Revert to the default style.
///     }
///     .toggleStyle(.button) // Use button style for toggles in the stack.
///     .labelStyle(.iconOnly) // Omit the title from any labels.
///
/// The style that SwiftUI uses as the default depends on both the platform
/// and the context. In macOS, the default in most contexts is a
/// ``ToggleStyle/checkbox``, while in iOS, the default toggle style is a
/// ``ToggleStyle/switch``:
///
/// | Platform    | Appearance |
/// |-------------|------------|
/// | iOS, iPadOS | ![A screenshot of several horizontally arranged items: two buttons, a vertical divider line, the text Enhance sound, and a switch. The first button has two right facing arrows that cross over in the middle and is active with a blue tint. The second button has one right and one left facing arrow and is inactive with neutral tint. The switch is on and has a green tint.](View-toggleStyle-3-iOS) |
/// | macOS       | ![A screenshot of several horizontally arranged items: two buttons, a vertical divider line, a checkbox, and the text Enhance sound. The first button has two right facing arrows that cross over in the middle and is active with a blue tint. The second button has one right and one left facing arrow and is inactive with a neutral tint. The check box is checked and has a blue tint.](View-toggleStyle-3-macOS) |
///
/// > Note: Like toggle style does for toggles, the ``View/labelStyle(_:)``
/// modifier sets the style for ``Label`` instances in the hierarchy. The
/// example above demostrates the compact ``LabelStyle/iconOnly`` style,
/// which is useful for button toggles in space-constrained contexts.
/// Always include a descriptive title for better accessibility.
///
/// For more information about how SwiftUI chooses a default toggle style,
/// see the ``ToggleStyle/automatic`` style.
///
/// - Parameter style: The toggle style to set. Use one of the built-in
///   values, like ``ToggleStyle/switch`` or ``ToggleStyle/button``,
///   or a custom style that you define by creating a type that conforms
///   to the ``ToggleStyle`` protocol.
///
/// - Returns: A view that uses the specified toggle style for itself
///   and its child views.
public func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
}
extension View {
/// Sets the visibility of the status bar.
///
/// - Parameter hidden: A Boolean value that indicates whether to hide the
///   status bar.
@available(iOS 13.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func statusBarHidden(_ hidden: Bool = true) -> some View
}
extension View {
/// Sets the visibility of the status bar.
///
/// Use `statusBar(hidden:)` to show or hide the status bar.
///
/// - Parameter hidden: A Boolean value that indicates whether to hide the
///   status bar.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "statusBarHidden(_:)")
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "statusBarHidden(_:)")
public func statusBar(hidden: Bool) -> some View
}
extension View {
/// Sets the keyboard type for this view.
///
/// Use `keyboardType(_:)` to specify the keyboard type to use for text
/// entry. A number of different keyboard types are available to meet
/// specialized input needs, such as entering email addresses or phone
/// numbers.
///
/// The example below presents a ``TextField`` to input an email address.
/// Setting the text field's keyboard type to `.emailAddress` ensures the
/// user can only enter correctly formatted email addresses.
///
///     TextField("someone@example.com", text: $emailAddress)
///         .keyboardType(.emailAddress)
///
/// There are several different kinds of specialized keyboard types
/// available though the
/// <doc://com.apple.documentation/documentation/UIKit/UIKeyboardType> enumeration. To
/// specify the default system keyboard type, use `.default`.
///
/// ![A screenshot showing the use of a specialized keyboard type with a
/// text field.](SwiftUI-View-keyboardType.png)
///
/// - Parameter type: One of the keyboard types defined in the
/// <doc://com.apple.documentation/documentation/UIKit/UIKeyboardType> enumeration.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public func keyboardType(_ type: UIKeyboardType) -> some View
}
extension View {
/// Sets whether to apply auto-capitalization to this view.
///
/// Use `autocapitalization(_:)` when you need to automatically capitalize
/// words, sentences, or other text like proper nouns.
///
/// In example below, as the user enters text each word is automatically
/// capitalized:
///
///     TextField("Last, First", text: $fullName)
///         .autocapitalization(UITextAutocapitalizationType.words)
///
/// The <doc://com.apple.documentation/documentation/UIKit/UITextAutocapitalizationType>
/// enumeration defines the available capitalization modes. The default is
/// <doc://com.apple.documentation/documentation/UIKit/UITextAutocapitalizationType/sentences>.
///
/// - Parameter style: One of the autocapitalization modes defined in the
/// <doc://com.apple.documentation/documentation/UIKit/UITextAutocapitalizationType>
/// enumeration.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use textInputAutocapitalization(_:)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use textInputAutocapitalization(_:)")
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use textInputAutocapitalization(_:)")
public func autocapitalization(_ style: UITextAutocapitalizationType) -> some View
}
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *)
@available(macOS, unavailable)
extension View {
/// Sets how often the shift key in the keyboard is automatically enabled.
///
/// Use `textInputAutocapitalization(_:)` when you need to automatically
/// capitalize words, sentences, or other text like proper nouns.
///
/// In example below, as the user enters text the shift key is
/// automatically enabled before every word:
///
///     TextField("Last, First", text: $fullName)
///         .textInputAutocapitalization(.words)
///
/// The ``TextInputAutocapitalization`` struct defines the available
/// autocapitalizing behavior. Providing `nil` to  this view modifier does
/// not change the autocapitalization behavior. The default is
/// ``TextInputAutocapitalization.sentences``.
///
/// - Parameter autocapitalization: One of the capitalizing behaviors
/// defined in the ``TextInputAutocapitalization`` struct or nil.
public func textInputAutocapitalization(_ autocapitalization: TextInputAutocapitalization?) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Sets the focused value for the given object type.
///
/// - Important: This initializer only accepts objects conforming to the
///   `Observable` protocol. For reading environment objects that conform to
///   `ObservableObject`, use `focusedObject(_:)`, instead.
///
/// To read this value, use the `FocusedValue` property wrapper.
public func focusedValue<T>(_ object: T?) -> some View where T : AnyObject, T : Observable
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Reads the specified preference value from the view, using it to
/// produce a second view that is applied as an overlay to the
/// original view.
///
/// The values of the preference key from both views
/// are combined and made visible to the parent view.
///
/// - Parameters:
///   - key: The preference key type whose value is to be read.
///   - alignment: An optional alignment to use when positioning the
///     overlay view relative to the original view.
///   - transform: A function that produces the overlay view from
///     the preference value read from the original view.
///
/// - Returns: A view that layers a second view in front of the view.
@inlinable public func overlayPreferenceValue<K, V>(_ key: K.Type, alignment: Alignment = .center, @ViewBuilder _ transform: @escaping (K.Value) -> V) -> some View where K : PreferenceKey, V : View
/// Reads the specified preference value from the view, using it to
/// produce a second view that is applied as the background of the
/// original view.
///
/// The values of the preference key from both views
/// are combined and made visible to the parent view.
///
/// - Parameters:
///   - key: The preference key type whose value is to be read.
///   - alignment: An optional alignment to use when positioning the
///     background view relative to the original view.
///   - transform: A function that produces the background view from
///     the preference value read from the original view.
///
/// - Returns: A view that layers a second view behind the view.
@inlinable public func backgroundPreferenceValue<K, V>(_ key: K.Type, alignment: Alignment = .center, @ViewBuilder _ transform: @escaping (K.Value) -> V) -> some View where K : PreferenceKey, V : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Reads the specified preference value from the view, using it to
/// produce a second view that is applied as an overlay to the
/// original view.
///
/// - Parameters:
///   - key: The preference key type whose value is to be read.
///   - transform: A function that produces the overlay view from
///     the preference value read from the original view.
///
/// - Returns: A view that layers a second view in front of the view.
@inlinable public func overlayPreferenceValue<Key, T>(_ key: Key.Type = Key.self, @ViewBuilder _ transform: @escaping (Key.Value) -> T) -> some View where Key : PreferenceKey, T : View
/// Reads the specified preference value from the view, using it to
/// produce a second view that is applied as the background of the
/// original view.
///
/// - Parameters:
///   - key: The preference key type whose value is to be read.
///   - transform: A function that produces the background view from
///     the preference value read from the original view.
///
/// - Returns: A view that layers a second view behind the view.
@inlinable public func backgroundPreferenceValue<Key, T>(_ key: Key.Type = Key.self, @ViewBuilder _ transform: @escaping (Key.Value) -> T) -> some View where Key : PreferenceKey, T : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the color of the foreground elements displayed by this view.
///
/// - Parameter color: The foreground color to use when displaying this
///   view. Pass `nil` to remove any custom foreground color and to allow
///   the system or the container to provide its own foreground color.
///   If a container-specific override doesn't exist, the system uses
///   the primary color.
///
/// - Returns: A view that uses the foreground color you supply.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "foregroundStyle(_:)")
@inlinable public func foregroundColor(_ color: Color?) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the header prominence for this view.
///
/// In the following example, the section header appears with increased
/// prominence:
///
///     List {
///         Section(header: Text("Header")) {
///             Text("Row")
///         }
///         .headerProminence(.increased)
///     }
///     .listStyle(.insetGrouped)
///
/// - Parameter prominence: The prominence to apply.
public func headerProminence(_ prominence: Prominence) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets the tint within this view.
///
/// Use this method to override the default accent color for this view with
/// a given styling. Unlike an app's accent color, which can be
/// overridden by user preference, tint is always respected and should
/// be used as a way to provide additional meaning to the control.
///
/// Controls which are unable to style themselves using the given type of
/// `ShapeStyle` will try to approximate the styling as best as they can
/// (i.e. controls which can not style themselves using a gradient will
/// attempt to use the color of the gradient's first stop).
///
/// This example shows a linear dashboard styled gauge tinted with a
/// gradient from  ``ShapeStyle/green`` to ``ShapeStyle/red``.
///
///     struct ControlTint: View {
///         var body: some View {
///             Gauge(value: 75, in: 0...100)
///                 .gaugeStyle(.linearDashboard)
///                 .tint(Gradient(colors: [.red, .yellow, .green]))
///         }
///     }
///
/// - Parameter tint: The tint to apply.
@inlinable public func tint<S>(_ tint: S?) -> some View where S : ShapeStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the tint color within this view.
///
/// Use this method to override the default accent color for this view.
/// Unlike an app's accent color, which can be overridden by user
/// preference, the tint color is always respected and should be used as a
/// way to provide additional meaning to the control.
///
/// This example shows Answer and Decline buttons with ``ShapeStyle/green``
/// and ``ShapeStyle/red`` tint colors, respectively.
///
///     struct ControlTint: View {
///         var body: some View {
///             HStack {
///                 Button {
///                     // Answer the call
///                 } label: {
///                     Label("Answer", systemImage: "phone")
///                 }
///                 .tint(.green)
///                 Button {
///                     // Decline the call
///                 } label: {
///                     Label("Decline", systemImage: "phone.down")
///                 }
///                 .tint(.red)
///             }
///             .padding()
///         }
///     }
///
/// - Parameter tint: The tint ``Color`` to apply.
@inlinable public func tint(_ tint: Color?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies a modifier to a view and returns a new view.
///
/// Use this modifier to combine a ``View`` and a ``ViewModifier``, to
/// create a new view. For example, if you create a view modifier for
/// a new kind of caption with blue text surrounded by a rounded rectangle:
///
///     struct BorderedCaption: ViewModifier {
///         func body(content: Content) -> some View {
///             content
///                 .font(.caption2)
///                 .padding(10)
///                 .overlay(
///                     RoundedRectangle(cornerRadius: 15)
///                         .stroke(lineWidth: 1)
///                 )
///                 .foregroundColor(Color.blue)
///         }
///     }
///
/// You can use ``modifier(_:)`` to extend ``View`` to create new modifier
/// for applying the `BorderedCaption` defined above:
///
///     extension View {
///         func borderedCaption() -> some View {
///             modifier(BorderedCaption())
///         }
///     }
///
/// Then you can apply the bordered caption to any view:
///
///     Image(systemName: "bus")
///         .resizable()
///         .frame(width:50, height:50)
///     Text("Downtown Bus")
///         .borderedCaption()
///
/// ![A screenshot showing the image of a bus with a caption reading
/// Downtown Bus. A view extension, using custom a modifier, renders the
///  caption in blue text surrounded by a rounded
///  rectangle.](SwiftUI-View-ViewModifier.png)
///
/// - Parameter modifier: The modifier to apply to this view.
@inlinable public func modifier<T>(_ modifier: T) -> ModifiedContent<Self, T>
}
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *)
@available(macOS, unavailable)
extension View {
/// Sets the style for the index view within the current environment.
///
/// - Parameter style: The style to apply to this view.
public func indexViewStyle<S>(_ style: S) -> some View where S : IndexViewStyle
}
extension View {
/// Sets the preferred order of items for menus presented from this view.
///
/// Use this modifier to override the default menu order. On supported
/// platforms, ``MenuOrder/priority`` order keeps the first items closer
/// to the user’s point of interaction, whereas ``MenuOrder/fixed`` order
/// always orders items from top to bottom.
///
/// On iOS, the ``MenuOrder/automatic`` order resolves to
/// ``MenuOrder/fixed`` for menus presented within scrollable content.
/// Pickers that use the ``PickerStyle/menu`` style also default to
/// ``MenuOrder/fixed`` order. In all other cases, menus default to
/// ``MenuOrder/priority`` order.
///
/// On macOS, tvOS and watchOS, the ``MenuOrder/automatic`` order always
/// resolves to ``MenuOrder/fixed`` order.
///
/// The following example creates a menu that presents its content in a
/// fixed order from top to bottom:
///
///     Menu {
///         Button("Select", action: selectFolders)
///         Button("New Folder", action: createFolder)
///         Picker("Appearance", selection: $appearance) {
///             Label("Icons", systemImage: "square.grid.2x2").tag(Appearance.icons)
///             Label("List", systemImage: "list.bullet").tag(Appearance.list)
///         }
///     } label: {
///         Label("Settings", systemImage: "ellipsis.circle")
///     }
///     .menuOrder(.fixed)
///
/// You can use this modifier on controls that present a menu.
/// For example, the code below creates a ``Picker`` using the
/// ``PickerStyle/menu`` style with a priority-based order:
///
///     Picker("Flavor", selection: $selectedFlavor) {
///         Text("Chocolate").tag(Flavor.chocolate)
///         Text("Vanilla").tag(Flavor.vanilla)
///         Text("Strawberry").tag(Flavor.strawberry)
///     }
///     .pickerStyle(.menu)
///     .menuOrder(.priority)
///
/// You can also use this modifier on context menus. The example below
/// creates a context menu that presents its content in a fixed order:
///
///     Text("Favorite Card Suit")
///         .padding()
///         .contextMenu {
///             Button("♥️ - Hearts", action: selectHearts)
///             Button("♣️ - Clubs", action: selectClubs)
///             Button("♠️ - Spades", action: selectSpades)
///             Button("♦️ - Diamonds", action: selectDiamonds)
///         }
///         .menuOrder(.fixed)
///
/// The modifier has no effect when applied to a subsection or
/// submenu of a menu.
///
/// - Parameter order: The menu item ordering strategy to apply.
///
/// - Returns: A view that uses the specified menu ordering strategy.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func menuOrder(_ order: MenuOrder) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets the style for the tab view within the current environment.
///
/// - Parameter style: The style to apply to this tab view.
public func tabViewStyle<S>(_ style: S) -> some View where S : TabViewStyle
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Cycles through the given phases when the trigger value changes,
/// updating the view using the modifiers you apply in `body`.
///
/// The phases that you provide specify the individual values that will
/// be animated to when the trigger value changes.
///
/// When the view first appears, the value from the first phase is provided
/// to the `content` closure. When the trigger value changes, the content
/// closure is called with the value from the second phase and its
/// corresponding animation. This continues until the last phase is
/// reached, after which the first phase is animated to.
///
/// - Parameters:
///   - phases: Phases defining the states that will be cycled through.
///     This sequence must not be empty. If an empty sequence is provided,
///     a visual warning will be displayed in place of this view, and a
///     warning will be logged.
///   - trigger: A value to observe for changes.
///   - content: A view builder closure that takes two parameters. The first
///     parameter is a proxy value representing the modified view. The
///     second parameter is the current phase.
///   - animation: A closure that returns the animation to use when
///     transitioning to the next phase. If `nil` is returned, the
///     transition will not be animated.
public func phaseAnimator<Phase>(_ phases: some Sequence, trigger: some Equatable, @ViewBuilder content: @escaping (PlaceholderContentView<Self>, Phase) -> some View, animation: @escaping (Phase) -> Animation? = { _ in .default }) -> some View where Phase : Equatable
/// Cycles through the given phases continuously, updating the content
/// using the view builder closure that you supply.
///
/// The phases that you provide define the individual values that will
/// be animated between.
///
/// When the view first appears, the the first phase is provided
/// to the `content` closure. The animator then immediately animates
/// to the second phase, using an animation returned from the `animation`
/// closure. This continues until the last phase is reached, after which
/// the animator loops back to the beginning.
///
/// - Parameters:
///   - phases: Phases defining the states that will be cycled through.
///     This sequence must not be empty. If an empty sequence is provided,
///     a visual warning will be displayed in place of this view, and a
///     warning will be logged.
///   - content: A view builder closure that takes two parameters. The first
///     parameter is a proxy value representing the modified view. The
///     second parameter is the current phase.
///   - animation: A closure that returns the animation to use when
///     transitioning to the next phase. If `nil` is returned, the
///     transition will not be animated.
public func phaseAnimator<Phase>(_ phases: some Sequence, @ViewBuilder content: @escaping (PlaceholderContentView<Self>, Phase) -> some View, animation: @escaping (Phase) -> Animation? = { _ in .default }) -> some View where Phase : Equatable
}
extension View {
/// Configures the content margin for a provided placement.
///
/// Use this modifier to customize the content margins of different
/// kinds of views. For example, you can use this modifier to customize
/// the margins of scrollable views like ``ScrollView``. In the
/// following example, the scroll view will automatically inset
/// its content by the safe area plus an additional 20 points
/// on the leading and trailing edge.
///
///     ScrollView(.horizontal) {
///         // ...
///     }
///     .contentMargins(.horizontal, 20.0)
///
/// You can provide a ``ContentMarginPlacement`` to target specific
/// parts of a view to customize. For example, provide a
/// ``ContentMargingPlacement/scrollContent`` placement to
/// inset the content of a ``TextEditor`` without affecting the
/// insets of its scroll indicators.
///
///     TextEditor(text: $text)
///         .contentMargins(.horizontal, 20.0, for: .scrollContent)
///
/// Similarly, you can customize the insets of scroll indicators
/// separately from scroll content. Consider doing this when applying
/// a custom clip shape that may clip the indicators.
///
///     ScrollView {
///         // ...
///     }
///     .clipShape(.rect(cornerRadius: 20.0))
///     .contentMargins(10.0, for: .scrollIndicators)
///
/// When applying multiple contentMargins modifiers, modifiers with
/// the same placement will override modifiers higher up in the view
/// hierarchy.
///
/// - Parameters:
///   - edges: The edges to add the margins to.
///   - insets: The amount of margins to add.
///   - placement: Where the margins should be added.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func contentMargins(_ edges: Edge.Set = .all, _ insets: EdgeInsets, for placement: ContentMarginPlacement = .automatic) -> some View
/// Configures the content margin for a provided placement.
///
/// Use this modifier to customize the content margins of different
/// kinds of views. For example, you can use this modifier to customize
/// the margins of scrollable views like ``ScrollView``. In the
/// following example, the scroll view will automatically inset
/// its content by the safe area plus an additional 20 points
/// on the leading and trailing edge.
///
///     ScrollView(.horizontal) {
///         // ...
///     }
///     .contentMargins(.horizontal, 20.0)
///
/// You can provide a ``ContentMarginPlacement`` to target specific
/// parts of a view to customize. For example, provide a
/// ``ContentMargingPlacement/scrollContent`` placement to
/// inset the content of a ``TextEditor`` without affecting the
/// insets of its scroll indicators.
///
///     TextEditor(text: $text)
///         .contentMargins(.horizontal, 20.0, for: .scrollContent)
///
/// Similarly, you can customize the insets of scroll indicators
/// separately from scroll content. Consider doing this when applying
/// a custom clip shape that may clip the indicators.
///
///     ScrollView {
///         // ...
///     }
///     .clipShape(.rect(cornerRadius: 20.0))
///     .contentMargins(10.0, for: .scrollIndicators)
///
/// When applying multiple contentMargins modifiers, modifiers with
/// the same placement will override modifiers higher up in the view
/// hierarchy.
///
/// - Parameters:
///   - edges: The edges to add the margins to.
///   - length: The amount of margins to add.
///   - placement: Where the margins should be added.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func contentMargins(_ edges: Edge.Set = .all, _ length: CGFloat?, for placement: ContentMarginPlacement = .automatic) -> some View
/// Configures the content margin for a provided placement.
///
/// Use this modifier to customize the content margins of different
/// kinds of views. For example, you can use this modifier to customize
/// the margins of scrollable views like ``ScrollView``. In the
/// following example, the scroll view will automatically inset
/// its content by the safe area plus an additional 20 points
/// on the leading and trailing edge.
///
///     ScrollView(.horizontal) {
///         // ...
///     }
///     .contentMargins(.horizontal, 20.0)
///
/// You can provide a ``ContentMarginPlacement`` to target specific
/// parts of a view to customize. For example, provide a
/// ``ContentMargingPlacement/scrollContent`` placement to
/// inset the content of a ``TextEditor`` without affecting the
/// insets of its scroll indicators.
///
///     TextEditor(text: $text)
///         .contentMargins(.horizontal, 20.0, for: .scrollContent)
///
/// Similarly, you can customize the insets of scroll indicators
/// separately from scroll content. Consider doing this when applying
/// a custom clip shape that may clip the indicators.
///
///     ScrollView {
///         // ...
///     }
///     .clipShape(.rect(cornerRadius: 20.0))
///     .contentMargins(10.0, for: .scrollIndicators)
///
/// When applying multiple contentMargins modifiers, modifiers with
/// the same placement will override modifiers higher up in the view
/// hierarchy.
///
/// - Parameters:
///   - length: The amount of margins to add on all edges.
///   - placement: Where the margins should be added.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func contentMargins(_ length: CGFloat, for placement: ContentMarginPlacement = .automatic) -> some View
}
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the style for disclosure groups within this view.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func disclosureGroupStyle<S>(_ style: S) -> some View where S : DisclosureGroupStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Defines the content shape for hit testing.
///
/// - Parameters:
///   - shape: The hit testing shape for the view.
///   - eoFill: A Boolean that indicates whether the shape is interpreted
///     with the even-odd winding number rule.
///
/// - Returns: A view that uses the given shape for hit testing.
@inlinable public func contentShape<S>(_ shape: S, eoFill: Bool = false) -> some View where S : Shape
}
extension View {
/// Defines a region of the window in which default focus is evaluated by
/// assigning a value to a given focus state binding.
///
/// By default, SwiftUI evaluates default focus when the window first
/// appears, and when a focus state binding update moves focus
/// automatically, but not when responding to user-driven navigation
/// commands.
///
/// Clients can override the default behavior by specifying an evaluation
/// priority of ``DefaultFocusEvaluationPriority/userInitiated``, which
/// causes SwiftUI to use the client's preferred default focus in response
/// to user-driven focus navigation as well as automatic changes.
///
/// In the following example, focus automatically goes to the second of the
/// two text fields when the view is first presented in the window.
///
///     WindowGroup {
///         VStack {
///             TextField(...)
///                 .focused($focusedField, equals: .firstField)
///             TextField(...)
///                 .focused($focusedField, equals: .secondField)
///         }
///         .defaultFocus($focusedField, .secondField)
///     }
///
/// - Parameters:
///   - binding: A focus state binding to update when evaluating default
///     focus in the modified view hierarchy.
///   - value: The value to set the binding to during evaluation.
///   - priority: An indication of how to prioritize the preferred default
///     focus target when focus moves into the modified view hierarchy.
///     The default value is `automatic`, which means the preference will
///     be given priority when focus is being initialized or relocated
///     programmatically, but not when responding to user-directed
///     navigation commands.
/// - Returns: The modified view.
@available(iOS 17.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func defaultFocus<V>(_ binding: FocusState<V>.Binding, _ value: V, priority: DefaultFocusEvaluationPriority = .automatic) -> some View where V : Hashable
}
extension View {
/// Adds an action to perform when the pointer enters, moves within, and
/// exits the view's bounds.
///
/// Call this method to define a region for detecting pointer movement with
/// the size and position of this view.
/// The following example updates `hoverLocation` and `isHovering` to be
/// based on the phase provided to the closure:
///
///     @State private var hoverLocation: CGPoint = .zero
///     @State private var isHovering = false
///
///     var body: some View {
///         VStack {
///             Color.red
///                 .frame(width: 400, height: 400)
///                 .onContinuousHover { phase in
///                     switch phase {
///                     case .active(let location):
///                         hoverLocation = location
///                         isHovering = true
///                     case .ended:
///                         isHovering = false
///                     }
///                 }
///                 .overlay {
///                     Rectangle()
///                         .frame(width: 50, height: 50)
///                         .foregroundColor(isHovering ? .green : .blue)
///                         .offset(x: hoverLocation.x, y: hoverLocation.y)
///                 }
///         }
///     }
///
/// - Parameters:
///    - coordinateSpace: The coordinate space for the
///    location values. Defaults to ``CoordinateSpace/local``.
///    - action: The action to perform whenever the pointer enters,
///    moves within, or exits the view's bounds. The `action` closure
///    passes the ``HoverPhase/active(_:)`` phase with the pointer's
///    coordinates if the pointer is in the view's bounds; otherwise, it
///    passes ``HoverPhase/ended``.
///
/// - Returns: A view that calls `action` when the pointer enters,
///   moves within, or exits the view's bounds.
@available(iOS, introduced: 16.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(macOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(tvOS, introduced: 16.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
public func onContinuousHover(coordinateSpace: CoordinateSpace = .local, perform action: @escaping (HoverPhase) -> Void) -> some View
}
extension View {
/// Adds an action to perform when the pointer enters, moves within, and
/// exits the view's bounds.
///
/// Call this method to define a region for detecting pointer movement with
/// the size and position of this view.
/// The following example updates `hoverLocation` and `isHovering` to be
/// based on the phase provided to the closure:
///
///     @State private var hoverLocation: CGPoint = .zero
///     @State private var isHovering = false
///
///     var body: some View {
///         VStack {
///             Color.red
///                 .frame(width: 400, height: 400)
///                 .onContinuousHover { phase in
///                     switch phase {
///                     case .active(let location):
///                         hoverLocation = location
///                         isHovering = true
///                     case .ended:
///                         isHovering = false
///                     }
///                 }
///                 .overlay {
///                     Rectangle()
///                         .frame(width: 50, height: 50)
///                         .foregroundColor(isHovering ? .green : .blue)
///                         .offset(x: hoverLocation.x, y: hoverLocation.y)
///                 }
///         }
///     }
///
/// - Parameters:
///    - coordinateSpace: The coordinate space for the
///    location values. Defaults to ``CoordinateSpace/local``.
///    - action: The action to perform whenever the pointer enters,
///    moves within, or exits the view's bounds. The `action` closure
///    passes the ``HoverPhase/active(_:)`` phase with the pointer's
///    coordinates if the pointer is in the view's bounds; otherwise, it
///    passes ``HoverPhase/ended``.
///
/// - Returns: A view that calls `action` when the pointer enters,
///   moves within, or exits the view's bounds.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
public func onContinuousHover(coordinateSpace: some CoordinateSpaceProtocol = .local, perform action: @escaping (HoverPhase) -> Void) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Returns a new view with a symbol effect added to it.
///
/// The following example adds a repeating pulse effect to two
/// symbol images:
///
///     VStack {
///         Image(systemName: "bolt.slash.fill")
///         Image(systemName: "folder.fill.badge.person.crop")
///     }
///     .symbolEffect(.pulse)
///
/// - Parameters:
///   - effect: A symbol effect to add to the view. Existing effects
///     added by ancestors of the view are preserved, but may be
///     overridden by the new effect. Added effects will be applied
///     to the ``SwiftUI/Image` views contained by the child view.
///   - isActive: whether the effect is active or inactive.
///
/// - Returns: a copy of the view with a symbol effect added.
public func symbolEffect<T>(_ effect: T, options: SymbolEffectOptions = .default, isActive: Bool = true) -> some View where T : IndefiniteSymbolEffect, T : SymbolEffect
/// Returns a new view with a symbol effect added to it.
///
/// The following example adds a bounce effect to two symbol
/// images, the animation will play each time `counter` changes:
///
///     VStack {
///         Image(systemName: "bolt.slash.fill")
///         Image(systemName: "folder.fill.badge.person.crop")
///     }
///     .symbolEffect(.bounce, value: counter)
///
/// - Parameters:
///   - effect: A symbol effect to add to the view. Existing effects
///     added by ancestors of the view are preserved, but may be
///     overridden by the new effect. Added effects will be applied
///     to the ``SwiftUI/Image` views contained by the child view.
///   - value: the value to monitor for changes, the animation is
///     triggered each time the value changes.
///
/// - Returns: a copy of the view with a symbol effect added.
public func symbolEffect<T, U>(_ effect: T, options: SymbolEffectOptions = .default, value: U) -> some View where T : DiscreteSymbolEffect, T : SymbolEffect, U : Equatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Sets the behavior of this view for different layout directions.
///
/// Use `layoutDirectionBehavior(_:)` when you need the system to
/// horizontally mirror the contents of the view when presented in a
/// layout direction.
///
/// To override the layout direction for a specific view, use the
/// ``View/environment(_:_:)`` view modifier to explicitly override
/// the ``EnvironmentValues/layoutDirection`` environment value for
/// the view.
///
/// - Parameter behavior: A LayoutDirectionBehavior value that indicates
///   whether this view should mirror in a particular layout direction. By
///   default, views will adjust their layouts automatically in a
///   right-to-left context and do not need to be mirrored.
///
/// - Returns: A view that conditionally mirrors its contents
///   horizontally in a given layout direction.
@inlinable public func layoutDirectionBehavior(_ behavior: LayoutDirectionBehavior) -> some View
}
extension View {
/// Associates a binding to be updated when a scroll view within this
/// view scrolls.
///
/// Use this modifier along with the ``View/scrollTargetLayout()``
/// modifier to know the identity of the view that is actively scrolled.
/// As the scroll view scrolls, the binding will be updated with the
/// identity of the leading-most / top-most view.
///
/// Use the ``View/scrollTargetLayout()`` modifier to configure
/// which the layout that contains your scroll targets. In the following
/// example, the top-most ItemView will update with the scrolledID
/// binding as the scroll view scrolls.
///
///     @Binding var items: [Item]
///     @Binding var scrolledID: Item.ID?
///
///     ScrollView {
///         LazyVStack {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollPosition(id: $scrolledID)
///
/// You can write to the binding to scroll to the view with
/// the provided identity.
///
///     @Binding var items: [Item]
///     @Binding var scrolledID: Item.ID?
///
///     ScrollView {
///         // ...
///     }
///     .scrollPosition(id: $scrolledID)
///     .toolbar {
///         Button("Scroll to Top") {
///             scrolledID = items.first
///         }
///     }
///
/// SwiftUI will attempt to keep the view with the identity specified
/// in the provided binding when events occur that might cause it
/// to be scrolled out of view by the system. Some examples of these
/// include:
///   - The data backing the content of a scroll view is re-ordered.
///   - The size of the scroll view changes, like when a window is resized
///     on macOS or during a rotation on iOS.
///   - The scroll view initially lays out it content defaulting to
///     the top most view, but the binding has a different view's identity.
///
/// You can provide an anchor to this modifier to both:
///   - Influence which view the system chooses as the view whose
///     identity value will update the providing binding as the scroll
///     view scrolls.
///   - Control the alignment of the view when scrolling to a view
///     when writing a new binding value.
///
/// For example, providing a value of ``UnitPoint/bottom`` will prefer
/// to have the bottom-most view chosen and prefer to scroll to views
/// aligned to the bottom.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollPosition(id: Binding<(some Hashable)?>, anchor: UnitPoint? = nil) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Adds an asynchronous task to perform before this view appears.
///
/// Use this modifier to perform an asynchronous task with a lifetime that
/// matches that of the modified view. If the task doesn't finish
/// before SwiftUI removes the view or the view changes identity, SwiftUI
/// cancels the task.
///
/// Use the `await` keyword inside the task to
/// wait for an asynchronous call to complete, or to wait on the values of
/// an <doc://com.apple.documentation/documentation/Swift/AsyncSequence>
/// instance. For example, you can modify a ``Text`` view to start a task
/// that loads content from a remote resource:
///
///     let url = URL(string: "https://example.com")!
///     @State private var message = "Loading..."
///
///     var body: some View {
///         Text(message)
///             .task {
///                 do {
///                     var receivedLines = [String]()
///                     for try await line in url.lines {
///                         receivedLines.append(line)
///                         message = "Received \(receivedLines.count) lines"
///                     }
///                 } catch {
///                     message = "Failed to load"
///                 }
///             }
///     }
///
/// This example uses the
/// <doc://com.apple.documentation/documentation/Foundation/URL/3767315-lines>
/// method to get the content stored at the specified
/// <doc://com.apple.documentation/documentation/Foundation/URL> as an
/// asynchronous sequence of strings. When each new line arrives, the body
/// of the `for`-`await`-`in` loop stores the line in an array of strings
/// and updates the content of the text view to report the latest line
/// count.
///
/// - Parameters:
///   - priority: The task priority to use when creating the asynchronous
///     task. The default priority is
///     <doc://com.apple.documentation/documentation/Swift/TaskPriority/3851283-userInitiated>.
///   - action: A closure that SwiftUI calls as an asynchronous task
///     before the view appears. SwiftUI will automatically cancel the task
///     at some point after the view disappears before the action completes.
///
///
/// - Returns: A view that runs the specified action asynchronously before
///   the view appears.
@inlinable public func task(priority: TaskPriority = .userInitiated, _ action: @escaping @Sendable () async -> Void) -> some View
/// Adds a task to perform before this view appears or when a specified
/// value changes.
///
/// This method behaves like ``View/task(priority:_:)``, except that it also
/// cancels and recreates the task when a specified value changes. To detect
/// a change, the modifier tests whether a new value for the `id` parameter
/// equals the previous value. For this to work,
/// the value's type must conform to the
/// <doc://com.apple.documentation/documentation/Swift/Equatable> protocol.
///
/// For example, if you define an equatable `Server` type that posts custom
/// notifications whenever its state changes --- for example, from _signed
/// out_ to _signed in_ --- you can use the task modifier to update
/// the contents of a ``Text`` view to reflect the state of the
/// currently selected server:
///
///     Text(status ?? "Signed Out")
///         .task(id: server) {
///             let sequence = NotificationCenter.default.notifications(
///                 named: .didChangeStatus,
///                 object: server)
///             for try await notification in sequence {
///                 status = notification.userInfo["status"] as? String
///             }
///         }
///
/// This example uses the
/// <doc://com.apple.documentation/documentation/Foundation/NotificationCenter/3813137-notifications>
/// method to wait indefinitely for an asynchronous sequence of
/// notifications, given by an
/// <doc://com.apple.documentation/documentation/Swift/AsyncSequence>
/// instance.
///
/// Elsewhere, the server defines a custom `didUpdateStatus` notification:
///
///     extension NSNotification.Name {
///         static var didUpdateStatus: NSNotification.Name {
///             NSNotification.Name("didUpdateStatus")
///         }
///     }
///
/// The server then posts a notification of this type whenever its status
/// changes, like after the user signs in:
///
///     let notification = Notification(
///         name: .didUpdateStatus,
///         object: self,
///         userInfo: ["status": "Signed In"])
///     NotificationCenter.default.post(notification)
///
/// The task attached to the ``Text`` view gets and displays the status
/// value from the notification's user information dictionary. When the user
/// chooses a different server, SwiftUI cancels the task and creates a new
/// one, which then starts waiting for notifications from the new server.
///
/// - Parameters:
///   - id: The value to observe for changes. The value must conform
///     to the <doc://com.apple.documentation/documentation/Swift/Equatable>
///     protocol.
///   - priority: The task priority to use when creating the asynchronous
///     task. The default priority is
///     <doc://com.apple.documentation/documentation/Swift/TaskPriority/3851283-userInitiated>.
///   - action: A closure that SwiftUI calls as an asynchronous task
///     before the view appears. SwiftUI can automatically cancel the task
///     after the view disappears before the action completes. If the
///     `id` value changes, SwiftUI cancels and restarts the task.
///
/// - Returns: A view that runs the specified action asynchronously before
///   the view appears, or restarts the task with the `id` value changes.
@inlinable public func task<T>(id value: T, priority: TaskPriority = .userInitiated, _ action: @escaping @Sendable () async -> Void) -> some View where T : Equatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Sets the spring loading behavior this view.
///
/// Spring loading refers to a view being activated during a drag and drop
/// interaction. On iOS this can occur when pausing briefly on top of a
/// view with dragged content. On macOS this can occur with similar brief
/// pauses or on pressure-sensitive systems by "force clicking" during the
/// drag. This has no effect on tvOS or watchOS.
///
/// This is commonly used with views that have a navigation or presentation
/// effect, allowing the destination to be revealed without pausing the
/// drag interaction. For example, a button that reveals a list of folders
/// that a dragged item can be dropped onto.
///
///     Button {
///         showFolders = true
///     } label: {
///         Label("Show Folders", systemImage: "folder")
///     }
///     .springLoadingBehavior(.enabled)
///
/// Unlike `disabled(_:)`, this modifier overrides the value set by an
/// ancestor view rather than being unioned with it. For example, the below
/// button would allow spring loading:
///
///     HStack {
///         Button {
///             showFolders = true
///         } label: {
///             Label("Show Folders", systemImage: "folder")
///         }
///         .springLoadingBehavior(.enabled)
///
///         ...
///     }
///     .springLoadingBehavior(.disabled)
///
/// - Parameter behavior: Whether spring loading is enabled or not. If
///   unspecified, the default behavior is `.automatic.`
public func springLoadingBehavior(_ behavior: SpringLoadingBehavior) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
public func searchable(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil) -> some View
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
public func searchable(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey) -> some View
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
public func searchable<S>(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: S) -> some View where S : StringProtocol
}
extension View {
/// Marks this view as searchable with programmatic presentation of the
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil) -> some View
/// Marks this view as searchable with programmatic presentation of the
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey) -> some View
/// Marks this view as searchable with programmatic presentation of the
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<S>(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: S) -> some View where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Associates a transition with the view.
///
/// When this view appears or disappears, the transition will be applied to
/// it, allowing for animating it in and out.
///
/// The following code will conditionally show MyView, and when it appears
/// or disappears, will use a slide transition to show it.
///
///     if isActive {
///         MyView()
///             .transition(.slide)
///     }
///     Button("Toggle") {
///         withAnimation {
///             isActive.toggle()
///         }
///     }
@inlinable public func transition(_ t: AnyTransition) -> some View
/// Associates a transition with the view.
///
/// When this view appears or disappears, the transition will be applied to
/// it, allowing for animating it in and out.
///
/// The following code will conditionally show MyView, and when it appears
/// or disappears, will use a custom RotatingFadeTransition transition to
/// show it.
///
///     if isActive {
///         MyView()
///             .transition(RotatingFadeTransition())
///     }
///     Button("Toggle") {
///         withAnimation {
///             isActive.toggle()
///         }
///     }
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func transition<T>(_ transition: T) -> some View where T : Transition
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Shows the specified content above or below the modified view.
///
/// The `content` view is anchored to the specified
/// vertical edge in the parent view, aligning its horizontal axis
/// to the specified alignment guide. The modified view is inset by
/// the height of `content`, from `edge`, with its safe area
/// increased by the same amount.
///
///     struct ScrollableViewWithBottomBar: View {
///         var body: some View {
///             ScrollView {
///                 ScrolledContent()
///             }
///             .safeAreaInset(edge: .bottom, spacing: 0) {
///                 BottomBarContent()
///             }
///         }
///     }
///
/// - Parameters:
///   - edge: The vertical edge of the view to inset by the height of
///    `content`, to make space for `content`.
///   - spacing: Extra distance placed between the two views, or
///     nil to use the default amount of spacing.
///   - alignment: The alignment guide used to position `content`
///     horizontally.
///   - content: A view builder function providing the view to
///     display in the inset space of the modified view.
///
/// - Returns: A new view that displays both `content` above or below the
///   modified view,
///   making space for the `content` view by vertically insetting
///   the modified view, adjusting the safe area of the result to match.
@inlinable public func safeAreaInset<V>(edge: VerticalEdge, alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> V) -> some View where V : View
/// Shows the specified content beside the modified view.
///
/// The `content` view is anchored to the specified
/// horizontal edge in the parent view, aligning its vertical axis
/// to the specified alignment guide. The modified view is inset by
/// the width of `content`, from `edge`, with its safe area
/// increased by the same amount.
///
///     struct ScrollableViewWithSideBar: View {
///         var body: some View {
///             ScrollView {
///                 ScrolledContent()
///             }
///             .safeAreaInset(edge: .leading, spacing: 0) {
///                 SideBarContent()
///             }
///         }
///     }
///
/// - Parameters:
///   - edge: The horizontal edge of the view to inset by the width of
///    `content`, to make space for `content`.
///   - spacing: Extra distance placed between the two views, or
///     nil to use the default amount of spacing.
///   - alignment: The alignment guide used to position `content`
///     vertically.
///   - content: A view builder function providing the view to
///     display in the inset space of the modified view.
///
/// - Returns: A new view that displays `content` beside the modified view,
///   making space for the `content` view by horizontally insetting
///   the modified view.
@inlinable public func safeAreaInset<V>(edge: HorizontalEdge, alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> V) -> some View where V : View
}
extension View {
/// Adds the provided insets into the safe area of this view.
///
/// Use this modifier when you would like to add a fixed amount
/// of space to the safe area a view sees.
///
///     ScrollView(.horizontal) {
///         HStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// See the ``View/safeAreaInset(edge:alignment:spacing:content)``
/// modifier for adding to the safe area based on the size of a
/// view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func safeAreaPadding(_ insets: EdgeInsets) -> some View
/// Adds the provided insets into the safe area of this view.
///
/// Use this modifier when you would like to add a fixed amount
/// of space to the safe area a view sees.
///
///     ScrollView(.horizontal) {
///         HStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// See the ``View/safeAreaInset(edge:alignment:spacing:content)``
/// modifier for adding to the safe area based on the size of a
/// view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func safeAreaPadding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View
/// Adds the provided insets into the safe area of this view.
///
/// Use this modifier when you would like to add a fixed amount
/// of space to the safe area a view sees.
///
///     ScrollView(.horizontal) {
///         HStack(spacing: 10.0) {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///     }
///     .safeAreaPadding(.horizontal, 20.0)
///
/// See the ``View/safeAreaInset(edge:alignment:spacing:content)``
/// modifier for adding to the safe area based on the size of a
/// view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func safeAreaPadding(_ length: CGFloat) -> some View
}
extension View {
/// Sets the style for navigation split views within this view.
///
/// - Parameter style: The style to set.
///
/// - Returns: A view that uses the specified navigation split view style.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func navigationSplitViewStyle<S>(_ style: S) -> some View where S : NavigationSplitViewStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Configures whether this view participates in hit test operations.
@inlinable public func allowsHitTesting(_ enabled: Bool) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the environment value of the specified key path to the given value.
///
/// Use this modifier to set one of the writable properties of the
/// ``EnvironmentValues`` structure, including custom values that you
/// create. For example, you can set the value associated with the
/// ``EnvironmentValues/truncationMode`` key:
///
///     MyView()
///         .environment(\.truncationMode, .head)
///
/// You then read the value inside `MyView` or one of its descendants
/// using the ``Environment`` property wrapper:
///
///     struct MyView: View {
///         @Environment(\.truncationMode) var truncationMode: Text.TruncationMode
///
///         var body: some View { ... }
///     }
///
/// SwiftUI provides dedicated view modifiers for setting most
/// environment values, like the ``View/truncationMode(_:)``
/// modifier which sets the ``EnvironmentValues/truncationMode`` value:
///
///     MyView()
///         .truncationMode(.head)
///
/// Prefer the dedicated modifier when available, and offer your own when
/// defining custom environment values, as described in
/// ``EnvironmentKey``.
///
/// This modifier affects the given view,
/// as well as that view's descendant views. It has no effect
/// outside the view hierarchy on which you call it.
///
/// - Parameters:
///   - keyPath: A key path that indicates the property of the
///     ``EnvironmentValues`` structure to update.
///   - value: The new value to set for the item specified by `keyPath`.
///
/// - Returns: A view that has the given value set in its environment.
@inlinable public func environment<V>(_ keyPath: WritableKeyPath<EnvironmentValues, V>, _ value: V) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the content shape for this view.
///
/// The content shape has a variety of uses. You can control the kind of the
/// content shape by specifying one in `kind`. For example, the
/// following example only sets the focus ring shape of the view, without
/// affecting its shape for hit-testing:
///
///     MyFocusableView()
///         .contentShape(.focusEffect, Circle())
///
/// - Parameters:
///   - kind: The kinds to apply to this content shape.
///   - shape: The shape to use.
///   - eoFill: A Boolean that indicates whether the shape is interpreted
///     with the even-odd winding number rule.
///
/// - Returns: A view that uses the given shape for the specified kind.
@inlinable public func contentShape<S>(_ kind: ContentShapeKinds, _ shape: S, eoFill: Bool = false) -> some View where S : Shape
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Applies the given transition, animating between the phases
/// of the transition as this view appears and disappears within the
/// visible region of the containing scroll view, or other container
/// specified using the `coordinateSpace` parameter.
///
/// - Parameters:
///   - configuration: The configuration controlling how the
///     transition will be applied. The configuration will be applied both
///     while the view is coming into view and while it is disappearing (the
///     transition is symmetrical).
///   - axis: The axis of the containing scroll view over which the
///     transition will be applied. The default value of `nil` uses the
///     axis of the innermost containing scroll view, or `.vertical` if
///     the innermost scroll view is scrollable along both axes.
///   - coordinateSpace: The coordinate space of the container that
///     visibility is evaluated within. Defaults to `.scrollView`.
///   - transition: A closure that applies visual effects as a function of
///     the provided phase.
public func scrollTransition(_ configuration: ScrollTransitionConfiguration = .interactive, axis: Axis? = nil, transition: @escaping @Sendable (EmptyVisualEffect, ScrollTransitionPhase) -> some VisualEffect) -> some View
/// Applies the given transition, animating between the phases
/// of the transition as this view appears and disappears within the
/// visible region of the containing scroll view, or other container
/// specified using the `coordinateSpace` parameter.
///
/// - Parameters:
///   - transition: the transition to apply.
///   - topLeading: The configuration that drives the transition when
///     the view is about to appear at the top edge of a vertical
///     scroll view, or the leading edge of a horizont scroll view.
///   - bottomTrailing: The configuration that drives the transition when
///     the view is about to appear at the bottom edge of a vertical
///     scroll view, or the trailing edge of a horizont scroll view.
///   - axis: The axis of the containing scroll view over which the
///     transition will be applied. The default value of `nil` uses the
///     axis of the innermost containing scroll view, or `.vertical` if
///     the innermost scroll view is scrollable along both axes.
///   - transition: A closure that applies visual effects as a function of
///     the provided phase.
public func scrollTransition(topLeading: ScrollTransitionConfiguration, bottomTrailing: ScrollTransitionConfiguration, axis: Axis? = nil, transition: @escaping @Sendable (EmptyVisualEffect, ScrollTransitionPhase) -> some VisualEffect) -> some View
}
extension View {
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
public func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
public func navigationBarItems<L>(leading: L) -> some View where L : View
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement")
public func navigationBarItems<T>(trailing: T) -> some View where T : View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets an explicit type select equivalent text in a collection, such as
/// a list or table.
///
/// By default, a type select equivalent is automatically derived from any
/// `Text` or `TextField` content in a list or table. In the below example,
/// type select can be used to select a person, even though no explicit
/// value has been set.
///
///     List(people, selection: $selectedPersonID) { person in
///         Label {
///             Text(person.name)
///         } icon: {
///             person.avatar
///         }
///     }
///
/// An explicit type select value should be set when there is no textual
/// content or when a different value is desired compared to what's
/// displayed in the view. Explicit values also provide a more performant
/// for complex view types. In the below example, type select is explicitly
/// set to allow selection of views that otherwise only display an image.
///
///     List(people, selection: $selectedPersonID) { person in
///         person.avatar
///             .accessibilityLabel(person.name)
///             .typeSelectEquivalent(person.name)
///     }
///
/// Setting an empty string value disables text selection for the view,
/// and a value of `nil` results in the view using its default value.
///
/// - Parameter text: The explicit text value to use as a type select
/// equivalent for a view in a collection.
@inlinable public func typeSelectEquivalent(_ text: Text?) -> some View
/// Sets an explicit type select equivalent text in a collection, such as
/// a list or table.
///
/// By default, a type select equivalent is automatically derived from any
/// `Text` or `TextField` content in a list or table. In the below example,
/// type select can be used to select a person, even though no explicit
/// value has been set.
///
///     List(people, selection: $selectedPersonID) { person in
///         Label {
///             Text(person.name)
///         } icon: {
///             person.avatar
///         }
///     }
///
/// An explicit type select value should be set when there is no textual
/// content or when a different value is desired compared to what's
/// displayed in the view. Explicit values also provide a more performant
/// for complex view types. In the below example, type select is explicitly
/// set to allow selection of views that otherwise only display an image.
///
///     List(people, selection: $selectedPersonID) { person in
///         person.avatar
///             .accessibilityLabel(person.name)
///             .typeSelectEquivalent(person.name)
///     }
///
/// Setting an empty string value disables text selection for the view,
/// and a value of `nil` results in the view using its default value.
///
/// - Parameter stringKey: The localized string key to use as a type select
/// equivalent for a view in a collection.
public func typeSelectEquivalent(_ stringKey: LocalizedStringKey) -> some View
/// Sets an explicit type select equivalent text in a collection, such as
/// a list or table.
///
/// By default, a type select equivalent is automatically derived from any
/// `Text` or `TextField` content in a list or table. In the below example,
/// type select can be used to select a person, even though no explicit
/// value has been set.
///
///     List(people, selection: $selectedPersonID) { person in
///         Label {
///             Text(person.name)
///         } icon: {
///             person.avatar
///         }
///     }
///
/// An explicit type select value should be set when there is no textual
/// content or when a different value is desired compared to what's
/// displayed in the view. Explicit values also provide a more performant
/// for complex view types. In the below example, type select is explicitly
/// set to allow selection of views that otherwise only display an image.
///
///     List(people, selection: $selectedPersonID) { person in
///         person.avatar
///             .accessibilityLabel(person.name)
///             .typeSelectEquivalent(person.name)
///     }
///
/// Setting an empty string value disables text selection for the view,
/// and a value of `nil` results in the view using its default value.
///
/// - Parameter string: The string to use as a type select equivalent for a
/// view in a collection.
public func typeSelectEquivalent<S>(_ string: S) -> some View where S : StringProtocol
}
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Adds an action to perform when the user moves the pointer over or away
/// from the view's frame.
///
/// Calling this method defines a region for detecting pointer movement with
/// the size and position of this view.
///
/// - Parameter action: The action to perform whenever the pointer enters or
///   exits this view's frame. If the pointer is in the view's frame, the
///   `action` closure passes `true` as a parameter; otherwise, `false`.
///
/// - Returns: A view that triggers `action` when the pointer enters or
///   exits this view's frame.
@inlinable public func onHover(perform action: @escaping (Bool) -> Void) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue(_ valueDescription: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue(_ valueKey: LocalizedStringKey) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(),
/// you can provide the current volume setting, like "60%", using accessibilityValue().
public func accessibilityValue<S>(_ value: S) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where S : StringProtocol
}
extension View {
/// Adds a textual description of the value that the view contains.
///
/// Use this method to describe the value represented by a view, but only if that's different than the
/// view's label. For example, for a slider that you label as "Volume" using accessibility(label:),
/// you can provide the current volume setting, like "60%", using accessibility(value:).
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)")
public func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
///
/// > Note: On macOS, if the view does not have an action and it has been
///   made into a container with ``accessibilityElement(children: .contain)``,
///   this will be used to describe the container. For example, if the container is
///   for a graph, the hint could be "graph".
public func accessibilityHint(_ hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   `accessibilityLabel()` modifier.
///
/// - Parameter inputLabels: An array of Text elements to use as input labels.
public func accessibilityInputLabels(_ inputLabels: [Text]) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
public func accessibilityHint(_ hintKey: LocalizedStringKey) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
public func accessibilityHint<S>(_ hint: S) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where S : StringProtocol
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   `accessibilityLabel()` modifier.
public func accessibilityInputLabels(_ inputLabelKeys: [LocalizedStringKey]) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   `accessibilityLabel()` modifier.
public func accessibilityInputLabels<S>(_ inputLabels: [S]) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where S : StringProtocol
}
extension View {
/// Specifies whether to hide this view from system accessibility features.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")
public func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds a label to the view that describes its contents.
///
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon.
/// For example, you could use this method to label a button that plays music with the text "Play".
/// Don't include text in the label that repeats information that users already have. For example,
/// don't use the label "Play button" because a button already has a trait that identifies it as a button.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)")
public func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Communicates to the user what happens after performing the view's
/// action.
///
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or
/// "Downloads the attachment".
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)")
public func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets alternate input labels with which users identify a view.
///
/// Provide labels in descending order of importance. Voice Control
/// and Full Keyboard Access use the input labels.
///
/// > Note: If you don't specify any input labels, the user can still
///   refer to the view using the accessibility label that you add with the
///   ``accessibility(label:)`` modifier.
///
/// - Parameter inputLabels: An array of Text elements to use as input labels.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)")
public func accessibility(inputLabels: [Text]) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Uses the specified string to identify the view.
///
/// Use this value for testing. It isn't visible to the user.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)")
public func accessibility(identifier: String) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets a selection identifier for this view's accessibility element.
///
/// Picker uses the value to determine what node to use for the
/// accessibility value.
@available(iOS, deprecated, introduced: 13.0)
@available(macOS, deprecated, introduced: 10.15)
@available(tvOS, deprecated, introduced: 13.0)
@available(watchOS, deprecated, introduced: 6)
@available(visionOS, introduced: 1.0, deprecated: 1.0)
public func accessibility(selectionIdentifier: AnyHashable) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Sets the sort priority order for this view's accessibility element,
/// relative to other elements at the same level.
///
/// Higher numbers are sorted first. The default sort priority is zero.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)")
public func accessibility(sortPriority: Double) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Specifies the point where activations occur in the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
public func accessibility(activationPoint: CGPoint) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Specifies the unit point where activations occur in the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)")
public func accessibility(activationPoint: UnitPoint) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 15.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the display mode for the separator associated with this specific row.
///
/// Separators can be presented above and below a row. You can specify to
/// which edge this preference should apply.
///
/// This modifier expresses a preference to the containing ``List``. The list
/// style is the final arbiter of the separator visibility.
///
/// The following example shows a simple grouped list whose row separators
/// are hidden:
///
///     List {
///         ForEach(garage.cars) { car in
///             Text(car.model)
///                 .listRowSeparator(.hidden)
///         }
///     }
///     .listStyle(.grouped)
///
/// To change the color of a row separators, use
/// ``View/listRowSeparatorTint(_:edges:)``.
/// To hide or change the tint color for a section separators, use
/// ``View/listSectionSeparator(_:edges:)`` and
/// ``View/listSectionSeparatorTint(_:edges:)``.
///
/// - Parameters:
///     - visibility: The visibility of this row's separators.
///     - edges: The set of row edges for which this preference applies.
///         The list style might already decide to not display separators for
///         some edges, typically the top edge. The default is
///         ``VerticalEdge/Set/all``.
///
public func listRowSeparator(_ visibility: Visibility, edges: VerticalEdge.Set = .all) -> some View
/// Sets the tint color associated with a row.
///
/// Separators can be presented above and below a row. You can specify to
/// which edge this preference should apply.
///
/// This modifier expresses a preference to the containing ``List``. The list
/// style is the final arbiter for the separator tint.
///
/// The following example shows a simple grouped list whose row separators
/// are tinted based on row-specific data:
///
///     List {
///         ForEach(garage.cars) { car in
///             Text(car.model)
///                 .listRowSeparatorTint(car.brandColor)
///         }
///     }
///     .listStyle(.grouped)
///
/// To hide a row separators, use
/// ``View/listRowSeparator(_:edges:)``.
/// To hide or change the tint color for a section separator, use
/// ``View/listSectionSeparator(_:edges:)`` and
/// ``View/listSectionSeparatorTint(_:edges:)``.
///
/// - Parameters:
///     - color: The color to use to tint the row separators, or `nil` to
///         use the default color for the current list style.
///     - edges: The set of row edges for which the tint applies.
///         The list style might decide to not display certain separators,
///         typically the top edge. The default is ``VerticalEdge/Set/all``.
///
public func listRowSeparatorTint(_ color: Color?, edges: VerticalEdge.Set = .all) -> some View
}
@available(iOS 15.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets whether to hide the separator associated with a list section.
///
/// Separators can be presented above and below a section. You can specify to
/// which edge this preference should apply.
///
/// This modifier expresses a preference to the containing ``List``. The list
/// style is the final arbiter of the separator visibility.
///
/// The following example shows a simple grouped list whose bottom
/// sections separator are hidden:
///
///     List {
///         ForEach(garage) { garage in
///             Section(header: Text(garage.location)) {
///                 ForEach(garage.cars) { car in
///                     Text(car.model)
///                         .listRowSeparatorTint(car.brandColor)
///                 }
///             }
///             .listSectionSeparator(.hidden, edges: .bottom)
///         }
///     }
///     .listStyle(.grouped)
///
/// To change the visibility and tint color for a row separator, use
/// ``View/listRowSeparator(_:edges:)`` and
/// ``View/listRowSeparatorTint(_:edges:)``.
/// To set the tint color for a section separator, use
/// ``View/listSectionSeparatorTint(_:edges:)``.
///
/// - Parameters:
///     - visibility: The visibility of this section's separators.
///     - edges: The set of row edges for which the preference applies.
///         The list style might already decide to not display separators for
///         some edges. The default is ``VerticalEdge/Set/all``.
///
public func listSectionSeparator(_ visibility: Visibility, edges: VerticalEdge.Set = .all) -> some View
/// Sets the tint color associated with a section.
///
/// Separators can be presented above and below a section. You can specify to
/// which edge this preference should apply.
///
/// This modifier expresses a preference to the containing ``List``. The list
/// style is the final arbiter for the separator tint.
///
/// The following example shows a simple grouped list whose section separators
/// are tinted based on section-specific data:
///
///     List {
///         ForEach(garage) { garage in
///             Section(header: Text(garage.location)) {
///                 ForEach(garage.cars) { car in
///                     Text(car.model)
///                         .listRowSeparatorTint(car.brandColor)
///                 }
///             }
///             .listSectionSeparatorTint(
///                 garage.cars.last?.brandColor, edges: .bottom)
///         }
///     }
///     .listStyle(.grouped)
///
/// To change the visibility and tint color for a row separator, use
/// ``View/listRowSeparator(_:edges:)`` and
/// ``View/listRowSeparatorTint(_:edges:)``.
/// To hide a section separator, use
/// ``View/listSectionSeparator(_:edges:)``.
///
/// - Parameters:
///     - color: The color to use to tint the section separators, or `nil` to
///         use the default color for the current list style.
///     - edges: The set of row edges for which the tint applies.
///         The list style might decide to not display certain separators,
///         typically the top edge. The default is ``VerticalEdge/Set/all``.
///
public func listSectionSeparatorTint(_ color: Color?, edges: VerticalEdge.Set = .all) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an action to perform when the specified preference key's value
/// changes.
///
/// - Parameters:
///   - key: The key to monitor for value changes.
///   - action: The action to perform when the value for `key` changes. The
///     `action` closure passes the new value as its parameter.
///
/// - Returns: A view that triggers `action` when the value for `key`
///   changes.
@inlinable public func onPreferenceChange<K>(_ key: K.Type = K.self, perform action: @escaping (K.Value) -> Void) -> some View where K : PreferenceKey, K.Value : Equatable
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets the sort priority order for this view's accessibility element,
/// relative to other elements at the same level.
///
/// Higher numbers are sorted first. The default sort priority is zero.
public func accessibilitySortPriority(_ sortPriority: Double) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Makes symbols within the view show a particular variant.
///
/// When you want all the
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/)
/// in a part of your app's user interface to use the same variant, use the
/// `symbolVariant(_:)` modifier with a ``SymbolVariants`` value, like
/// ``SymbolVariants/fill-swift.type.property``:
///
///     VStack(spacing: 20) {
///         HStack(spacing: 20) {
///             Image(systemName: "person")
///             Image(systemName: "folder")
///             Image(systemName: "gearshape")
///             Image(systemName: "list.bullet")
///         }
///
///         HStack(spacing: 20) {
///             Image(systemName: "person")
///             Image(systemName: "folder")
///             Image(systemName: "gearshape")
///             Image(systemName: "list.bullet")
///         }
///         .symbolVariant(.fill) // Shows filled variants, when available.
///     }
///
/// A symbol that doesn't have the specified variant remains unaffected.
/// In the example above, the `list.bullet` symbol doesn't have a filled
/// variant, so the `symbolVariant(_:)` modifer has no effect.
///
/// ![A screenshot showing two rows of four symbols. Both rows contain a
/// person, a folder, a gear, and a bullet list. The symbols in the first
/// row are outlined. The symbols in the second row are filled, except the
/// list, which is the same in both rows.](View-symbolVariant-1)
///
/// If you apply the modifier more than once, its effects accumulate.
/// Alternatively, you can apply multiple variants in one call:
///
///     Label("Airplane", systemImage: "airplane.circle.fill")
///
///     Label("Airplane", systemImage: "airplane")
///         .symbolVariant(.circle)
///         .symbolVariant(.fill)
///
///     Label("Airplane", systemImage: "airplane")
///         .symbolVariant(.circle.fill)
///
/// All of the labels in the code above produce the same output:
///
/// ![A screenshot of a label that shows an airplane in a filled circle
/// beside the word Airplane.](View-symbolVariant-2)
///
/// You can apply all these variants in any order, but
/// if you apply more than one shape variant, the one closest to the
/// symbol takes precedence. For example, the following image uses the
/// ``SymbolVariants/square-swift.type.property`` shape:
///
///     Image(systemName: "arrow.left")
///         .symbolVariant(.square) // This shape takes precedence.
///         .symbolVariant(.circle)
///         .symbolVariant(.fill)
///
/// ![A screenshot of a left arrow symbol in a filled
/// square.](View-symbolVariant-3)
///
/// To cause a symbol to ignore the variants currently in the environment,
/// directly set the ``EnvironmentValues/symbolVariants`` environment value
/// to ``SymbolVariants/none`` using the ``View/environment(_:_:)`` modifer.
///
/// - Parameter variant: The variant to use for symbols. Use the values in
///   ``SymbolVariants``.
/// - Returns: A view that applies the specified symbol variant or variants
///   to itself and its child views.
public func symbolVariant(_ variant: SymbolVariants) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an accessibility scroll action to the view. Actions allow
/// assistive technologies, such as the VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how a scroll action to trigger
/// a refresh could be added to a view.
///
///     var body: some View {
///         ScrollView {
///             ContentView()
///         }
///         .accessibilityScrollAction { edge in
///             if edge == .top {
///                 // Refresh content
///             }
///         }
///     }
///
public func accessibilityScrollAction(_ handler: @escaping (Edge) -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Configures the ``fileExporter``, ``fileImporter``, or ``fileMover`` to
/// open with the specified default directory.
///
/// - Parameter defaultDirectory: The directory to show when
///   the system file dialog launches. If the given file dialog has
///   a `fileDialogCustomizationID` if stores the user-chosen directory and subsequently
///   opens with it, ignoring the default value provided in this modifier.
public func fileDialogDefaultDirectory(_ defaultDirectory: URL?) -> some View
/// On macOS, configures the `fileExporter`, `fileImporter`,
/// or `fileMover` to persist and restore the file dialog configuration.
///
/// Among other parameters, it stores the current directory,
/// view style (e.g., Icons, List, Columns), recent places,
/// and expanded window size.
/// It enables a refined user experience; for example,
/// when importing an image, the user might switch to the Icons view,
/// but the List view could be more convenient in another context.
/// The file dialog stores these settings and applies them
/// every time before presenting the panel.
/// If not provided, on every launch, the file dialog
/// uses the default configuration.
///
/// - Parameter id: An identifier of the configuration.
public func fileDialogCustomizationID(_ id: String) -> some View
/// On macOS, configures the the ``fileExporter``, ``fileImporter``, or ``fileMover``
/// with a custom text that is presented to the user,
/// similar to a title.
///
/// - Parameter message: The optional text to use as the file dialog message.
public func fileDialogMessage(_ message: Text?) -> some View
/// On macOS, configures the the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` with a custom message that is presented to the user,
/// similar to a title.
///
/// - Parameter messageKey: The key to a localized string to display.
public func fileDialogMessage(_ messageKey: LocalizedStringKey) -> some View
/// On macOS, configures the the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` with a custom message that is presented to the user,
/// similar to a title.
///
/// - Parameter message: The string to use as the file dialog message.
public func fileDialogMessage<S>(_ message: S) -> some View where S : StringProtocol
/// On macOS, configures the the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` with a custom confirmation button label.
///
/// - Parameter label: The string to use as the label for the confirmation button.
public func fileDialogConfirmationLabel<S>(_ label: S) -> some View where S : StringProtocol
/// On macOS, configures the the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` with custom text as a confirmation button label.
///
/// - Parameter label: The optional text to use as the label for the confirmation button.
public func fileDialogConfirmationLabel(_ label: Text?) -> some View
/// On macOS, configures the the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` with a custom confirmation button label.
///
/// - Parameter labelKey: The key to a localized string to display.
public func fileDialogConfirmationLabel(_ labelKey: LocalizedStringKey) -> some View
/// On macOS, configures the ``fileExporter``
/// with a text to use as a label for the file name field.
/// - Parameter label: The optional text to use as the label for the file name field.
public func fileExporterFilenameLabel(_ label: Text?) -> some View
/// On macOS, configures the ``fileExporter``
/// with a label for the file name field.
/// - Parameter labelKey: The key to a localized string to display.
public func fileExporterFilenameLabel(_ labelKey: LocalizedStringKey) -> some View
/// On macOS, configures the ``fileExporter``
/// with a label for the file name field.
/// - Parameter label: The string to use as the label for the file name field.
public func fileExporterFilenameLabel<S>(_ label: S) -> some View where S : StringProtocol
/// On macOS, configures the the ``fileImporter``
/// or ``fileMover`` to conditionally disable presented URLs.
///
/// - Parameter predicate: The predicate that evaluates the
///    URLs presented to the user to conditionally disable them.
///    The implementation is expected to have constant complexity
///    and should not access the files contents or metadata. A common use case
///    is inspecting the path or the file name.
public func fileDialogURLEnabled(_ predicate: Predicate<URL>) -> some View
/// On macOS, configures the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` behavior when a user chooses an alias.
///
/// By default, file dialogs resolve aliases and
/// provide the URL of the item referred to by the chosen alias.
/// This modifier allows control of this behavior: pass `true` if the
/// application doesn't want file dialog to resolve aliases.
/// - Parameter imports: A Boolean value that indicates
///     if the application receives unresolved or resolved URLs
///     when a user chooses aliases.
public func fileDialogImportsUnresolvedAliases(_ imports: Bool) -> some View
/// On macOS, configures the ``fileExporter``, ``fileImporter``,
/// or ``fileMover`` to provide a refined URL search experience: include or exclude
/// hidden files, allow searching by tag, etc.
///
/// - Parameter options: The search options to apply to a given file dialog.
public func fileDialogBrowserOptions(_ options: FileDialogBrowserOptions) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Attaches a gesture to the view with a lower precedence than gestures
/// defined by the view.
///
/// Use this method when you need to attach a gesture to a view. The
/// example below defines a custom gesture that prints a message to the
/// console and attaches it to the view's ``VStack``. Inside the ``VStack``
/// a red heart ``Image`` defines its own ``TapGesture``
/// handler that also prints a message to the console, and blue rectangle
/// with no custom gesture handlers. Tapping or clicking the image
/// prints a message to the console from the tap gesture handler on the
/// image, while tapping or clicking  the rectangle inside the ``VStack``
/// prints a message in the console from the enclosing vertical stack
/// gesture handler.
///
///     struct GestureExample: View {
///         @State private var message = "Message"
///         let newGesture = TapGesture().onEnded {
///             print("Tap on VStack.")
///         }
///
///         var body: some View {
///             VStack(spacing:25) {
///                 Image(systemName: "heart.fill")
///                     .resizable()
///                     .frame(width: 75, height: 75)
///                     .padding()
///                     .foregroundColor(.red)
///                     .onTapGesture {
///                         print("Tap on image.")
///                     }
///                 Rectangle()
///                     .fill(Color.blue)
///             }
///             .gesture(newGesture)
///             .frame(width: 200, height: 200)
///             .border(Color.purple)
///         }
///     }
///
/// - Parameters:
///    - gesture: A gesture to attach to the view.
///    - mask: A value that controls how adding this gesture to the view
///      affects other gestures recognized by the view and its subviews.
///      Defaults to ``SwiftUI/GestureMask/all``.
public func gesture<T>(_ gesture: T, including mask: GestureMask = .all) -> some View where T : Gesture
/// Attaches a gesture to the view with a higher precedence than gestures
/// defined by the view.
///
/// Use this method when you need to define a high priority gesture
/// to take precedence over the view's existing gestures. The
/// example below defines a custom gesture that prints a message to the
/// console and attaches it to the view's ``VStack``. Inside the ``VStack``
/// a red heart ``Image`` defines its own ``TapGesture`` handler that
/// also prints a message to the console, and a blue rectangle
/// with no custom gesture handlers. Tapping or clicking any of the
/// views results in a console message from the high priority gesture
/// attached to the enclosing ``VStack``.
///
///     struct HighPriorityGestureExample: View {
///         @State private var message = "Message"
///         let newGesture = TapGesture().onEnded {
///             print("Tap on VStack.")
///         }
///
///         var body: some View {
///             VStack(spacing:25) {
///                 Image(systemName: "heart.fill")
///                     .resizable()
///                     .frame(width: 75, height: 75)
///                     .padding()
///                     .foregroundColor(.red)
///                     .onTapGesture {
///                         print("Tap on image.")
///                     }
///                 Rectangle()
///                     .fill(Color.blue)
///             }
///             .highPriorityGesture(newGesture)
///             .frame(width: 200, height: 200)
///             .border(Color.purple)
///         }
///     }
///
/// - Parameters:
///    - gesture: A gesture to attach to the view.
///    - mask: A value that controls how adding this gesture to the view
///      affects other gestures recognized by the view and its subviews.
///      Defaults to ``SwiftUI/GestureMask/all``.
public func highPriorityGesture<T>(_ gesture: T, including mask: GestureMask = .all) -> some View where T : Gesture
/// Attaches a gesture to the view to process simultaneously with gestures
/// defined by the view.
///
/// Use this method when you need to define and process  a view specific
/// gesture simultaneously with the same priority as the
/// view's existing gestures. The example below defines a custom gesture
/// that prints a message to the console and attaches it to the view's
/// ``VStack``. Inside the ``VStack`` is a red heart ``Image`` defines its
/// own ``TapGesture`` handler that also prints a message to the console
/// and a blue rectangle with no custom gesture handlers.
///
/// Tapping or clicking the "heart" image sends two messages to the
/// console: one for the image's tap gesture handler, and the other from a
/// custom gesture handler attached to the enclosing vertical stack.
/// Tapping or clicking on the blue rectangle results only in the single
/// message to the console from the tap recognizer attached to the
/// ``VStack``:
///
///     struct SimultaneousGestureExample: View {
///         @State private var message = "Message"
///         let newGesture = TapGesture().onEnded {
///             print("Gesture on VStack.")
///         }
///
///         var body: some View {
///             VStack(spacing:25) {
///                 Image(systemName: "heart.fill")
///                     .resizable()
///                     .frame(width: 75, height: 75)
///                     .padding()
///                     .foregroundColor(.red)
///                     .onTapGesture {
///                         print("Gesture on image.")
///                     }
///                 Rectangle()
///                     .fill(Color.blue)
///             }
///             .simultaneousGesture(newGesture)
///             .frame(width: 200, height: 200)
///             .border(Color.purple)
///         }
///     }
///
/// - Parameters:
///    - gesture: A gesture to attach to the view.
///    - mask: A value that controls how adding this gesture to the view
///      affects other gestures recognized by the view and its subviews.
///      Defaults to ``SwiftUI/GestureMask/all``.
public func simultaneousGesture<T>(_ gesture: T, including mask: GestureMask = .all) -> some View where T : Gesture
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Enables user suppression of dialogs and alerts presented within `self`,
/// with a custom suppression message on macOS. Unused on other platforms.
///
/// Applying dialog suppression adds a toggle to dialogs on macOS,
/// which allows the user to request the alert not be displayed again.
/// Typically whether a dialog is suppressed is stored in `AppStorage`
/// and used to decide whether to present the dialog in the future.
///
/// The following example configures a `confirmationDialog` with a
/// suppression toggle. The toggle's state is stored in `AppStorage` and
/// used to determine whether or not to show the dialog when the
/// "Delete Items" button is pressed.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///
///         @AppStorage("suppressEraseItemAlert")
///         private var suppressAlert = false
///
///         var body: some View {
///             Button("Delete Items") {
///                 if !suppressAlert {
///                     isShowingDialog = true
///                 } else {
///                     // Handle item deletion.
///                 }
///             }
///             .confirmationDialog(
///                 "Are you sure you want to erase these items?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Erase", role: .destructive) {
///                     // Handle item deletion.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             }
///             .dialogSuppressionToggle(
///                 "Do not ask about erasing items again",
///                 isSuppressed: $suppressAlert)
///         }
///     }
///
/// - Parameters:
///   - titleKey: The title of the suppression toggle in the dialog. This
///     parameter can be elided to use the default suppression title.
///   - isSuppressed: Whether the suppression toggle is on or off in the
///     dialog.
public func dialogSuppressionToggle(_ titleKey: LocalizedStringKey, isSuppressed: Binding<Bool>) -> some View
/// Enables user suppression of dialogs and alerts presented within `self`,
/// with a custom suppression message on macOS. Unused on other platforms.
///
/// Applying dialog suppression adds a toggle to dialogs on macOS,
/// which allows the user to request the alert not be displayed again.
/// Typically whether a dialog is suppressed is stored in `AppStorage`
/// and used to decide whether to present the dialog in the future.
///
/// The following example configures a `confirmationDialog` with a
/// suppression toggle. The toggle's state is stored in `AppStorage` and
/// used to determine whether or not to show the dialog when the
/// "Delete Items" button is pressed.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///
///         @AppStorage("suppressEraseItemAlert")
///         private var suppressAlert = false
///
///         var body: some View {
///             Button("Delete Items") {
///                 if !suppressAlert {
///                     isShowingDialog = true
///                 } else {
///                     // Handle item deletion.
///                 }
///             }
///             .confirmationDialog(
///                 "Are you sure you want to erase these items?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Erase", role: .destructive) {
///                     // Handle item deletion.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             }
///             .dialogSuppressionToggle(
///                 "Do not ask about erasing items again",
///                 isSuppressed: $suppressAlert)
///         }
///     }
///
/// - Parameters:
///   - title: The title of the suppression toggle in the dialog. This
///     parameter can be elided to use the default suppression title.
///   - isSuppressed: Whether the suppression toggle is on or off in the
///     dialog.
public func dialogSuppressionToggle<S>(_ title: S, isSuppressed: Binding<Bool>) -> some View where S : StringProtocol
/// Enables user suppression of dialogs and alerts presented within `self`,
/// with a custom suppression message on macOS. Unused on other platforms.
///
/// Applying dialog suppression adds a toggle to dialogs on macOS,
/// which allows the user to request the alert not be displayed again.
/// Typically whether a dialog is suppressed is stored in `AppStorage`
/// and used to decide whether to present the dialog in the future.
///
/// The following example configures a `confirmationDialog` with a
/// suppression toggle. The toggle's state is stored in `AppStorage` and
/// used to determine whether or not to show the dialog when the
/// "Delete Items" button is pressed.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///
///         @AppStorage("suppressEraseItemAlert")
///         private var suppressAlert = false
///
///         var body: some View {
///             Button("Delete Items") {
///                 if !suppressAlert {
///                     isShowingDialog = true
///                 } else {
///                     // Handle item deletion.
///                 }
///             }
///             .confirmationDialog(
///                 "Are you sure you want to erase these items?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Erase", role: .destructive) {
///                     // Handle item deletion.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             }
///             .dialogSuppressionToggle(
///                 Text("Do not ask about erasing items again"),
///                 isSuppressed: $suppressAlert)
///         }
///     }
///
/// - Parameters:
///   - label: The label of the suppression toggle in the dialog. This
///     parameter can be elided to use the default suppression title.
///   - isSuppressed: Whether the suppression toggle is on or off in the
///     dialog.
public func dialogSuppressionToggle(_ label: Text, isSuppressed: Binding<Bool>) -> some View
/// Enables user suppression of dialogs and alerts presented within `self`,
/// with a default suppression message on macOS. Unused on other platforms.
///
/// Applying dialog suppression adds a toggle to dialogs on macOS,
/// which allows the user to request the alert not be displayed again.
/// Typically whether a dialog is suppressed is stored in `AppStorage`
/// and used to decide whether to present the dialog in the future.
///
/// The following example configures a `confirmationDialog` with a
/// suppression toggle. The toggle's state is stored in `AppStorage` and
/// used to determine whether or not to show the dialog when the
/// "Delete Items" button is pressed.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///
///         @AppStorage("suppressEraseItemAlert")
///         private var suppressAlert = false
///
///         var body: some View {
///             Button("Delete Items") {
///                 if !suppressAlert {
///                     isShowingDialog = true
///                 } else {
///                     // Handle item deletion.
///                 }
///             }
///             .confirmationDialog(
///                 "Are you sure you want to erase these items?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Erase", role: .destructive) {
///                     // Handle item deletion.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             }
///             .dialogSuppressionToggle(isSuppressed: $suppressAlert)
///         }
///     }
///
/// - Parameter isSuppressed: Whether the suppression toggle is on or off
///   in the dialog.
public func dialogSuppressionToggle(isSuppressed: Binding<Bool>) -> some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system interface for allowing the user to import an existing
/// file.
///
/// In order for the interface to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCompletion` will not be
/// called.
///
/// - Note: This dialog provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// For example, an application can have a button that allows the user to choose the default directory
/// with document templates loaded on every launch. Such a button might look like this:
///
///      struct PickTemplatesDirectoryButton: View {
///          @State private var showFileImporter = false
///          var onTemplatesDirectoryPicked: (URL) -> Void
///
///          var body: some View {
///              Button {
///                  showFileImporter = true
///              } label: {
///                  Label("Choose templates directory", systemImage: "folder.circle")
///              }
///              .fileImporter(
///                  isPresented: $showFileImporter,
///                  allowedContentTypes: [.directory]
///              ) { result in
///                   switch result {
///                   case .success(let directory):
///                       // gain access to the directory
///                       let gotAccess = directory.startAccessingSecurityScopedResource()
///                       if !gotAccess { return }
///                       // access the directory URL
///                       // (read templates in the directory, make a bookmark, etc.)
///                       onTemplatesDirectoryPicked(directory)
///                       // release access
///                       directory.stopAccessingSecurityScopedResource()
///                   case .failure(let error):
///                       // handle error
///                       print(error)
///                   }
///              }
///          }
///      }
///
/// - Note: Changing `allowedContentTypes` while the file importer is
///   presented will have no immediate effect, however will apply the next
///   time it is presented.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - allowedContentTypes: The list of supported content types which can
///     be imported.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileImporter(isPresented: Binding<Bool>, allowedContentTypes: [UTType], onCompletion: @escaping (_ result: Result<URL, Error>) -> Void) -> some View
/// Presents a system interface for allowing the user to import multiple
/// files.
///
/// In order for the interface to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCompletion` will not be
/// called.
///
/// - Note: This dialog provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// For example, a button that allows the user to choose multiple PDF files for the application
/// to combine them later, might look like this:
///
///        struct PickPDFsButton: View {
///            @State private var showFileImporter = false
///            var handlePickedPDF: (URL) -> Void
///
///            var body: some View {
///                Button {
///                    showFileImporter = true
///                } label: {
///                    Label("Choose PDFs to combine", systemImage: "doc.circle")
///                }
///                .fileImporter(
///                    isPresented: $showFileImporter,
///                    allowedContentTypes: [.pdf],
///                    allowsMultipleSelection: true
///                ) { result in
///                    switch result {
///                    case .success(let files):
///                        files.forEach { file in
///                            // gain access to the directory
///                            let gotAccess = file.startAccessingSecurityScopedResource()
///                            if !gotAccess { return }
///                            // access the directory URL
///                            // (read templates in the directory, make a bookmark, etc.)
///                            handlePickedPDF(file)
///                            // release access
///                            file.stopAccessingSecurityScopedResource()
///                        }
///                    case .failure(let error):
///                        // handle error
///                        print(error)
///                    }
///                }
///            }
///        }
///
/// - Note: Changing `allowedContentTypes` or `allowsMultipleSelection`
///   while the file importer is presented will have no immediate effect,
///   however will apply the next time it is presented.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - allowedContentTypes: The list of supported content types which can
///     be imported.
///   - allowsMultipleSelection: Whether the importer allows the user to
///     select more than one file to import.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileImporter(isPresented: Binding<Bool>, allowedContentTypes: [UTType], allowsMultipleSelection: Bool, onCompletion: @escaping (_ result: Result<[URL], Error>) -> Void) -> some View
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system dialog for allowing the user to import multiple
/// files.
///
/// In order for the dialog to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCompletion` will not be
/// called.
///
/// - Note: This dialog provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// For example, a button that allows the user to choose multiple PDF files for the application
/// to combine them later, might look like this:
///
///        struct PickPDFsButton: View {
///            @State private var showFileImporter = false
///            var handlePickedPDF: (URL) -> Void
///
///            var body: some View {
///                Button {
///                    showFileImporter = true
///                } label: {
///                    Label("Choose PDFs to combine", systemImage: "doc.circle")
///                }
///                .fileImporter(
///                    isPresented: $showFileImporter,
///                    allowedContentTypes: [.pdf],
///                    allowsMultipleSelection: true
///                ) { result in
///                    switch result {
///                    case .success(let files):
///                        files.forEach { file in
///                            // gain access to the directory
///                            let gotAccess = file.startAccessingSecurityScopedResource()
///                            if !gotAccess { return }
///                            // access the directory URL
///                            // (read templates in the directory, make a bookmark, etc.)
///                            handlePickedPDF(file)
///                            // release access
///                            file.stopAccessingSecurityScopedResource()
///                        }
///                    case .failure(let error):
///                        // handle error
///                        print(error)
///                    }
///                }
///            }
///        }
///
/// - Note: Changing `allowedContentTypes` or `allowsMultipleSelection`
///   while the file importer is presented will have no immediate effect,
///   however will apply the next time it is presented.
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - allowedContentTypes: The list of supported content types which can
///     be imported.
///   - allowsMultipleSelection: Whether the importer allows the user to
///     select more than one file to import.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether the operation
///     succeeded or failed. To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileImporter(isPresented: Binding<Bool>, allowedContentTypes: [UTType], allowsMultipleSelection: Bool, onCompletion: @escaping (_ result: Result<[URL], Error>) -> Void, onCancellation: @escaping () -> Void) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Masks this view using the alpha channel of the given view.
///
/// Use `mask(_:)` when you want to apply the alpha (opacity) value of
/// another view to the current view.
///
/// This example shows an image masked by rectangle with a 10% opacity:
///
///     Image(systemName: "envelope.badge.fill")
///         .foregroundColor(Color.blue)
///         .font(.system(size: 128, weight: .regular))
///         .mask {
///             Rectangle().opacity(0.1)
///         }
///
/// ![A screenshot of a view masked by a rectangle with 10%
/// opacity.](SwiftUI-View-mask.png)
///
/// - Parameters:
///     - alignment: The alignment for `mask` in relation to this view.
///     - mask: The view whose alpha the rendering system applies to
///       the specified view.
@inlinable public func mask<Mask>(alignment: Alignment = .center, @ViewBuilder _ mask: () -> Mask) -> some View where Mask : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Masks this view using the alpha channel of the given view.
///
/// Use `mask(_:)` when you want to apply the alpha (opacity) value of
/// another view to the current view.
///
/// This example shows an image masked by rectangle with a 10% opacity:
///
///     Image(systemName: "envelope.badge.fill")
///         .foregroundColor(Color.blue)
///         .font(.system(size: 128, weight: .regular))
///         .mask(Rectangle().opacity(0.1))
///
/// ![A screenshot of a view masked by a rectangle with 10%
/// opacity.](SwiftUI-View-mask.png)
///
/// - Parameter mask: The view whose alpha the rendering system applies to
///   the specified view.
@available(iOS, deprecated: 100000.0, message: "Use overload where mask accepts a @ViewBuilder instead.")
@available(macOS, deprecated: 100000.0, message: "Use overload where mask accepts a @ViewBuilder instead.")
@available(tvOS, deprecated: 100000.0, message: "Use overload where mask accepts a @ViewBuilder instead.")
@available(watchOS, deprecated: 100000.0, message: "Use overload where mask accepts a @ViewBuilder instead.")
@available(visionOS, deprecated: 100000.0, message: "Use overload where mask accepts a @ViewBuilder instead.")
@inlinable public func mask<Mask>(_ mask: Mask) -> some View where Mask : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Layers the given view behind this view.
///
/// Use `background(_:alignment:)` when you need to place one view behind
/// another, with the background view optionally aligned with a specified
/// edge of the frontmost view.
///
/// The example below creates two views: the `Frontmost` view, and the
/// `DiamondBackground` view. The `Frontmost` view uses the
/// `DiamondBackground` view for the background of the image element inside
/// the `Frontmost` view's ``VStack``.
///
///     struct DiamondBackground: View {
///         var body: some View {
///             VStack {
///                 Rectangle()
///                     .fill(.gray)
///                     .frame(width: 250, height: 250, alignment: .center)
///                     .rotationEffect(.degrees(45.0))
///             }
///         }
///     }
///
///     struct Frontmost: View {
///         var body: some View {
///             VStack {
///                 Image(systemName: "folder")
///                     .font(.system(size: 128, weight: .ultraLight))
///                     .background(DiamondBackground())
///             }
///         }
///     }
///
/// ![A view showing a large folder image with a gray diamond placed behind
/// it as its background view.](View-background-1)
///
/// - Parameters:
///   - background: The view to draw behind this view.
///   - alignment: The alignment with a default value of
///     ``Alignment/center`` that you use to position the background view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `background(alignment:content:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `background(alignment:content:)` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use `background(alignment:content:)` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use `background(alignment:content:)` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `background(alignment:content:)` instead.")
@inlinable public func background<Background>(_ background: Background, alignment: Alignment = .center) -> some View where Background : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Layers the views that you specify behind this view.
///
/// Use this modifier to place one or more views behind another view.
/// For example, you can place a collection of stars beind a ``Text`` view:
///
///     Text("ABCDEF")
///         .background(alignment: .leading) { Star(color: .red) }
///         .background(alignment: .center) { Star(color: .green) }
///         .background(alignment: .trailing) { Star(color: .blue) }
///
/// The example above assumes that you've defined a `Star` view with a
/// parameterized color:
///
///     struct Star: View {
///         var color: Color
///
///         var body: some View {
///             Image(systemName: "star.fill")
///                 .foregroundStyle(color)
///         }
///     }
///
/// By setting different `alignment` values for each modifier, you make the
/// stars appear in different places behind the text:
///
/// ![A screenshot of the letters A, B, C, D, E, and F written in front of
/// three stars. The stars, from left to right, are red, green, and
/// blue.](View-background-2)
///
/// If you specify more than one view in the `content` closure, the modifier
/// collects all of the views in the closure into an implicit ``ZStack``,
/// taking them in order from back to front. For example, you can layer a
/// vertical bar behind a circle, with both of those behind a horizontal
/// bar:
///
///     Color.blue
///         .frame(width: 200, height: 10) // Creates a horizontal bar.
///         .background {
///             Color.green
///                 .frame(width: 10, height: 100) // Creates a vertical bar.
///             Circle()
///                 .frame(width: 50, height: 50)
///         }
///
/// Both the background modifier and the implicit ``ZStack`` composed from
/// the background content --- the circle and the vertical bar --- use a
/// default ``Alignment/center`` alignment. The vertical bar appears
/// centered behind the circle, and both appear as a composite view centered
/// behind the horizontal bar:
///
/// ![A screenshot of a circle with a horizontal blue bar layered on top
/// and a vertical green bar layered underneath. All of the items are center
/// aligned.](View-background-3)
///
/// If you specify an alignment for the background, it applies to the
/// implicit stack rather than to the individual views in the closure. You
/// can see this if you add the ``Alignment/leading`` alignment:
///
///     Color.blue
///         .frame(width: 200, height: 10)
///         .background(alignment: .leading) {
///             Color.green
///                 .frame(width: 10, height: 100)
///             Circle()
///                 .frame(width: 50, height: 50)
///         }
///
/// The vertical bar and the circle move as a unit to align the stack
/// with the leading edge of the horizontal bar, while the
/// vertical bar remains centered on the circle:
///
/// ![A screenshot of a horizontal blue bar in front of a circle, which
/// is in front of a vertical green bar. The horizontal bar and the circle
/// are center aligned with each other; the left edges of the circle
/// and the horizontal are aligned.](View-background-3a)
///
/// To control the placement of individual items inside the `content`
/// closure, either use a different background modifier for each item, as
/// the earlier example of stars under text demonstrates, or add an explicit
/// ``ZStack`` inside the content closure with its own alignment:
///
///     Color.blue
///         .frame(width: 200, height: 10)
///         .background(alignment: .leading) {
///             ZStack(alignment: .leading) {
///                 Color.green
///                     .frame(width: 10, height: 100)
///                 Circle()
///                     .frame(width: 50, height: 50)
///             }
///         }
///
/// The stack alignment ensures that the circle's leading edge aligns with
/// the vertical bar's, while the background modifier aligns the composite
/// view with the horizontal bar:
///
/// ![A screenshot of a horizontal blue bar in front of a circle, which
/// is in front of a vertical green bar. All items are aligned on their
/// left edges.](View-background-4)
///
/// You can achieve layering without a background modifier by putting both
/// the modified view and the background content into a ``ZStack``. This
/// produces a simpler view hierarchy, but it changes the layout priority
/// that SwiftUI applies to the views. Use the background modifier when you
/// want the modified view to dominate the layout.
///
/// If you want to specify a ``ShapeStyle`` like a
/// ``HierarchicalShapeStyle`` or a ``Material`` as the background, use
/// ``View/background(_:ignoresSafeAreaEdges:)`` instead.
/// To specify a ``Shape`` or ``InsettableShape``, use
/// ``View/background(_:in:fillStyle:)-89n7j`` or
/// ``View/background(_:in:fillStyle:)-20tq5``, respectively.
/// To configure the background of a presentation, like a sheet, use
/// ``View/presentationBackground(alignment:content:)``.
///
/// - Parameters:
///   - alignment: The alignment that the modifier uses to position the
///     implicit ``ZStack`` that groups the background views. The default
///     is ``Alignment/center``.
///   - content: A ``ViewBuilder`` that you use to declare the views to draw
///     behind this view, stacked in a cascading order from bottom to top.
///     The last view that you list appears at the front of the stack.
///
/// - Returns: A view that uses the specified content as a background.
@inlinable public func background<V>(alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View where V : View
/// Sets the view's background to the default background style.
///
/// This modifier behaves like ``View/background(_:ignoresSafeAreaEdges:)``,
/// except that it always uses the ``ShapeStyle/background`` shape style.
/// For example, you can add a background to a ``Label``:
///
///     ZStack {
///         Color.teal
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background()
///     }
///
/// Without the background modifier, the teal color behind the label shows
/// through the label. With the modifier, the label's text and icon appear
/// backed by a region filled with a color that's appropriate for light
/// or dark appearance:
///
/// ![A screenshot of a flag icon and the word flag inside a rectangle; the
/// rectangle is filled with the background color and layered on top of a
/// larger rectangle that's filled with the color teal.](View-background-7)
///
/// If you want to specify a ``View`` or a stack of views as the background,
/// use ``View/background(alignment:content:)`` instead.
/// To specify a ``Shape`` or ``InsettableShape``, use
/// ``View/background(_:in:fillStyle:)-89n7j`` or
/// ``View/background(_:in:fillStyle:)-20tq5``, respectively.
/// To configure the background of a presentation, like a sheet, use
/// ``View/presentationBackground(_:)``.
///
/// - Parameters:
///   - edges: The set of edges for which to ignore safe area insets
///     when adding the background. The default value is ``Edge/Set/all``.
///     Specify an empty set to respect safe area insets on all edges.
///
/// - Returns: A view with the ``ShapeStyle/background`` shape style
///   drawn behind it.
@inlinable public func background(ignoresSafeAreaEdges edges: Edge.Set = .all) -> some View
/// Sets the view's background to a style.
///
/// Use this modifier to place a type that conforms to the ``ShapeStyle``
/// protocol --- like a ``Color``, ``Material``, or
/// ``HierarchicalShapeStyle`` --- behind a view. For example, you can add
/// the ``ShapeStyle/regularMaterial`` behind a ``Label``:
///
///     struct FlagLabel: View {
///         var body: some View {
///             Label("Flag", systemImage: "flag.fill")
///                 .padding()
///                 .background(.regularMaterial)
///         }
///     }
///
/// SwiftUI anchors the style to the view's bounds. For the example above,
/// the background fills the entirety of the label's frame, which includes
/// the padding:
///
/// ![A screenshot of a flag symbol and the word flag layered over a
/// gray rectangle.](View-background-5)
///
/// SwiftUI limits the background style's extent to the modified view's
/// container-relative shape. You can see this effect if you constrain the
/// `FlagLabel` view with a ``View/containerShape(_:)`` modifier:
///
///     FlagLabel()
///         .containerShape(RoundedRectangle(cornerRadius: 16))
///
/// The background takes on the specified container shape:
///
/// ![A screenshot of a flag symbol and the word flag layered over a
/// gray rectangle with rounded corners.](View-background-6)
///
/// By default, the background ignores safe area insets on all edges, but
/// you can provide a specific set of edges to ignore, or an empty set to
/// respect safe area insets on all edges:
///
///     Rectangle()
///         .background(
///             .regularMaterial,
///             ignoresSafeAreaEdges: []) // Ignore no safe area insets.
///
/// If you want to specify a ``View`` or a stack of views as the background,
/// use ``View/background(alignment:content:)`` instead.
/// To specify a ``Shape`` or ``InsettableShape``, use
/// ``View/background(_:in:fillStyle:)-89n7j`` or
/// ``View/background(_:in:fillStyle:)-20tq5``, respectively.
/// To configure the background of a presentation, like a sheet, use
/// ``View/presentationBackground(_:)``.
///
/// - Parameters:
///   - style: An instance of a type that conforms to ``ShapeStyle`` that
///     SwiftUI draws behind the modified view.
///   - edges: The set of edges for which to ignore safe area insets
///     when adding the background. The default value is ``Edge/Set/all``.
///     Specify an empty set to respect safe area insets on all edges.
///
/// - Returns: A view with the specified style drawn behind it.
@inlinable public func background<S>(_ style: S, ignoresSafeAreaEdges edges: Edge.Set = .all) -> some View where S : ShapeStyle
/// Sets the view's background to a shape filled with the
/// default background style.
///
/// This modifier behaves like ``View/background(_:in:fillStyle:)-89n7j``,
/// except that it always uses the ``ShapeStyle/background`` shape style
/// to fill the specified shape. For example, you can create a ``Path``
/// that outlines a trapezoid:
///
///     let trapezoid = Path { path in
///         path.move(to: .zero)
///         path.addLine(to: CGPoint(x: 90, y: 0))
///         path.addLine(to: CGPoint(x: 80, y: 50))
///         path.addLine(to: CGPoint(x: 10, y: 50))
///     }
///
/// Then you can use that shape as a background for a ``Label``:
///
///     ZStack {
///         Color.teal
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background(in: trapezoid)
///     }
///
/// Without the background modifier, the fill color shows
/// through the label. With the modifier, the label's text and icon appear
/// backed by a shape filled with a color that's appropriate for light
/// or dark appearance:
///
/// ![A screenshot of a flag icon and the word flag inside a trapezoid; the
/// trapezoid is filled with the background color and layered on top of
/// a rectangle filled with the color teal.](View-background-B)
///
/// To create a background with other ``View`` types --- or with a stack
/// of views --- use ``View/background(alignment:content:)`` instead.
/// To add a ``ShapeStyle`` as a background, use
/// ``View/background(_:ignoresSafeAreaEdges:)``.
///
/// - Parameters:
///   - shape: An instance of a type that conforms to ``Shape`` that
///     SwiftUI draws behind the view using the ``ShapeStyle/background``
///     shape style.
///   - fillStyle: The ``FillStyle`` to use when drawing the shape.
///     The default style uses the nonzero winding number rule and
///     antialiasing.
///
/// - Returns: A view with the specified shape drawn behind it.
@inlinable public func background<S>(in shape: S, fillStyle: FillStyle = FillStyle()) -> some View where S : Shape
/// Sets the view's background to a shape filled with a style.
///
/// Use this modifier to layer a type that conforms to the ``Shape``
/// protocol behind a view. Specify the ``ShapeStyle`` that's used to
/// fill the shape. For example, you can create a ``Path`` that outlines
/// a trapezoid:
///
///     let trapezoid = Path { path in
///         path.move(to: .zero)
///         path.addLine(to: CGPoint(x: 90, y: 0))
///         path.addLine(to: CGPoint(x: 80, y: 50))
///         path.addLine(to: CGPoint(x: 10, y: 50))
///     }
///
/// Then you can use that shape as a background for a ``Label``:
///
///     Label("Flag", systemImage: "flag.fill")
///         .padding()
///         .background(.teal, in: trapezoid)
///
/// The ``ShapeStyle/teal`` color fills the shape:
///
/// ![A screenshot of the flag icon and the word flag inside a trapezoid;
/// The trapezoid is filled with the color teal.](View-background-A)
///
/// This modifier and ``View/background(_:in:fillStyle:)-20tq5`` are
/// convenience methods for placing a single shape behind a view. To
/// create a background with other ``View`` types --- or with a stack
/// of views --- use ``View/background(alignment:content:)`` instead.
/// To add a ``ShapeStyle`` as a background, use
/// ``View/background(_:ignoresSafeAreaEdges:)``.
///
/// - Parameters:
///   - style: A ``ShapeStyle`` that SwiftUI uses to the fill the shape
///     that you specify.
///   - shape: An instance of a type that conforms to ``Shape`` that
///     SwiftUI draws behind the view.
///   - fillStyle: The ``FillStyle`` to use when drawing the shape.
///     The default style uses the nonzero winding number rule and
///     antialiasing.
///
/// - Returns: A view with the specified shape drawn behind it.
@inlinable public func background<S, T>(_ style: S, in shape: T, fillStyle: FillStyle = FillStyle()) -> some View where S : ShapeStyle, T : Shape
/// Sets the view's background to an insettable shape filled with the
/// default background style.
///
/// This modifier behaves like ``View/background(_:in:fillStyle:)-20tq5``,
/// except that it always uses the ``ShapeStyle/background`` shape style
/// to fill the specified insettable shape. For example, you can use
/// a ``RoundedRectangle`` as a background on a ``Label``:
///
///     ZStack {
///         Color.teal
///         Label("Flag", systemImage: "flag.fill")
///             .padding()
///             .background(in: RoundedRectangle(cornerRadius: 8))
///     }
///
/// Without the background modifier, the fill color shows
/// through the label. With the modifier, the label's text and icon appear
/// backed by a shape filled with a color that's appropriate for light
/// or dark appearance:
///
/// ![A screenshot of a flag icon and the word flag inside a rectangle with
/// rounded corners; the rectangle is filled with the background color, and
/// is layered on top of a larger rectangle that's filled with the color
/// teal.](View-background-9)
///
/// To create a background with other ``View`` types --- or with a stack
/// of views --- use ``View/background(alignment:content:)`` instead.
/// To add a ``ShapeStyle`` as a background, use
/// ``View/background(_:ignoresSafeAreaEdges:)``.
///
/// - Parameters:
///   - shape: An instance of a type that conforms to ``InsettableShape``
///     that SwiftUI draws behind the view using the
///     ``ShapeStyle/background`` shape style.
///   - fillStyle: The ``FillStyle`` to use when drawing the shape.
///     The default style uses the nonzero winding number rule and
///     antialiasing.
///
/// - Returns: A view with the specified insettable shape drawn behind it.
@inlinable public func background<S>(in shape: S, fillStyle: FillStyle = FillStyle()) -> some View where S : InsettableShape
/// Sets the view's background to an insettable shape filled with a style.
///
/// Use this modifier to layer a type that conforms to the
/// ``InsettableShape`` protocol --- like a ``Rectangle``, ``Circle``, or
/// ``Capsule`` --- behind a view. Specify the ``ShapeStyle`` that's used to
/// fill the shape. For example, you can place a ``RoundedRectangle``
/// behind a ``Label``:
///
///     Label("Flag", systemImage: "flag.fill")
///         .padding()
///         .background(.teal, in: RoundedRectangle(cornerRadius: 8))
///
/// The ``ShapeStyle/teal`` color fills the shape:
///
/// ![A screenshot of the flag icon and word on a teal rectangle with
/// rounded corners.](View-background-8)
///
/// This modifier and ``View/background(_:in:fillStyle:)-89n7j`` are
/// convenience methods for placing a single shape behind a view. To
/// create a background with other ``View`` types --- or with a stack
/// of views --- use ``View/background(alignment:content:)`` instead.
/// To add a ``ShapeStyle`` as a background, use
/// ``View/background(_:ignoresSafeAreaEdges:)``.
///
/// - Parameters:
///   - style: A ``ShapeStyle`` that SwiftUI uses to the fill the shape
///     that you specify.
///   - shape: An instance of a type that conforms to ``InsettableShape``
///     that SwiftUI draws behind the view.
///   - fillStyle: The ``FillStyle`` to use when drawing the shape.
///     The default style uses the nonzero winding number rule and
///     antialiasing.
///
/// - Returns: A view with the specified insettable shape drawn behind it.
@inlinable public func background<S, T>(_ style: S, in shape: T, fillStyle: FillStyle = FillStyle()) -> some View where S : ShapeStyle, T : InsettableShape
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Layers a secondary view in front of this view.
///
/// When you apply an overlay to a view, the original view continues to
/// provide the layout characteristics for the resulting view. In the
/// following example, the heart image is shown overlaid in front of, and
/// aligned to the bottom of the folder image.
///
///     Image(systemName: "folder")
///         .font(.system(size: 55, weight: .thin))
///         .overlay(Text("❤️"), alignment: .bottom)
///
/// ![View showing placement of a heart overlaid onto a folder
/// icon.](View-overlay-1)
///
/// - Parameters:
///   - overlay: The view to layer in front of this view.
///   - alignment: The alignment for `overlay` in relation to this view.
///
/// - Returns: A view that layers `overlay` in front of the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `overlay(alignment:content:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `overlay(alignment:content:)` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use `overlay(alignment:content:)` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use `overlay(alignment:content:)` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `overlay(alignment:content:)` instead.")
@inlinable public func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View where Overlay : View
/// Adds a border to this view with the specified style and width.
///
/// Use this modifier to draw a border of a specified width around the
/// view's frame. By default, the border appears inside the bounds of this
/// view. For example, you can add a four-point wide border covers the text:
///
///     Text("Purple border inside the view bounds.")
///         .border(Color.purple, width: 4)
///
/// ![A screenshot showing the text Purple border inside the view bounds.
/// The text is surrounded by a purple border that outlines the text,
/// but isn't quite big enough and encroaches on the text.](View-border-1)
///
/// To place a border around the outside of this view, apply padding of the
/// same width before adding the border:
///
///     Text("Purple border outside the view bounds.")
///         .padding(4)
///         .border(Color.purple, width: 4)
///
/// ![A screenshot showing the text Purple border outside the view bounds.
/// The text is surrounded by a purple border that outlines the text
/// without touching the text.](View-border-2)
///
/// - Parameters:
///   - content: A value that conforms to the ``ShapeStyle`` protocol,
///     like a ``Color`` or ``HierarchicalShapeStyle``, that SwiftUI
///     uses to fill the border.
///   - width: The thickness of the border. The default is 1 pixel.
///
/// - Returns: A view that adds a border with the specified style and width
///   to this view.
@inlinable public func border<S>(_ content: S, width: CGFloat = 1) -> some View where S : ShapeStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Layers the views that you specify in front of this view.
///
/// Use this modifier to place one or more views in front of another view.
/// For example, you can place a group of stars on a ``RoundedRectangle``:
///
///     RoundedRectangle(cornerRadius: 8)
///         .frame(width: 200, height: 100)
///         .overlay(alignment: .topLeading) { Star(color: .red) }
///         .overlay(alignment: .topTrailing) { Star(color: .yellow) }
///         .overlay(alignment: .bottomLeading) { Star(color: .green) }
///         .overlay(alignment: .bottomTrailing) { Star(color: .blue) }
///
/// The example above assumes that you've defined a `Star` view with a
/// parameterized color:
///
///     struct Star: View {
///         var color = Color.yellow
///
///         var body: some View {
///             Image(systemName: "star.fill")
///                 .foregroundStyle(color)
///         }
///     }
///
/// By setting different `alignment` values for each modifier, you make the
/// stars appear in different places on the rectangle:
///
/// ![A screenshot of a rounded rectangle with a star in each corner. The
/// star in the upper-left is red; the start in the upper-right is yellow;
/// the star in the lower-left is green; the star the lower-right is
/// blue.](View-overlay-2)
///
/// If you specify more than one view in the `content` closure, the modifier
/// collects all of the views in the closure into an implicit ``ZStack``,
/// taking them in order from back to front. For example, you can place a
/// star and a ``Circle`` on a field of ``ShapeStyle/blue``:
///
///     Color.blue
///         .frame(width: 200, height: 200)
///         .overlay {
///             Circle()
///                 .frame(width: 100, height: 100)
///             Star()
///         }
///
/// Both the overlay modifier and the implicit ``ZStack`` composed from the
/// overlay content --- the circle and the star --- use a default
/// ``Alignment/center`` alignment. The star appears centered on the circle,
/// and both appear as a composite view centered in front of the square:
///
/// ![A screenshot of a star centered on a circle, which is
/// centered on a square.](View-overlay-3)
///
/// If you specify an alignment for the overlay, it applies to the implicit
/// stack rather than to the individual views in the closure. You can see
/// this if you add the ``Alignment/bottom`` alignment:
///
///     Color.blue
///         .frame(width: 200, height: 200)
///         .overlay(alignment: .bottom) {
///             Circle()
///                 .frame(width: 100, height: 100)
///             Star()
///         }
///
/// The circle and the star move down as a unit to align the stack's bottom
/// edge with the bottom edge of the square, while the star remains
/// centered on the circle:
///
/// ![A screenshot of a star centered on a circle, which is on a square.
/// The circle's bottom edge is aligned with the square's bottom
/// edge.](View-overlay-3a)
///
/// To control the placement of individual items inside the `content`
/// closure, either use a different overlay modifier for each item, as the
/// earlier example of stars in the corners of a rectangle demonstrates, or
/// add an explicit ``ZStack`` inside the content closure with its own
/// alignment:
///
///     Color.blue
///         .frame(width: 200, height: 200)
///         .overlay(alignment: .bottom) {
///             ZStack(alignment: .bottom) {
///                 Circle()
///                     .frame(width: 100, height: 100)
///                 Star()
///             }
///         }
///
/// The stack alignment ensures that the star's bottom edge aligns with the
/// circle's, while the overlay aligns the composite view with the square:
///
/// ![A screenshot of a star, a circle, and a square with all their
/// bottom edges aligned.](View-overlay-4)
///
/// You can achieve layering without an overlay modifier by putting both the
/// modified view and the overlay content into a ``ZStack``. This can
/// produce a simpler view hierarchy, but changes the layout priority that
/// SwiftUI applies to the views. Use the overlay modifier when you want the
/// modified view to dominate the layout.
///
/// If you want to specify a ``ShapeStyle`` like a ``Color`` or a
/// ``Material`` as the overlay, use
/// ``View/overlay(_:ignoresSafeAreaEdges:)`` instead. To specify a
/// ``Shape``, use ``View/overlay(_:in:fillStyle:)``.
///
/// - Parameters:
///   - alignment: The alignment that the modifier uses to position the
///     implicit ``ZStack`` that groups the foreground views. The default
///     is ``Alignment/center``.
///   - content: A ``ViewBuilder`` that you use to declare the views to
///     draw in front of this view, stacked in the order that you list them.
///     The last view that you list appears at the front of the stack.
///
/// - Returns: A view that uses the specified content as a foreground.
@inlinable public func overlay<V>(alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View where V : View
/// Layers the specified style in front of this view.
///
/// Use this modifier to layer a type that conforms to the ``ShapeStyle``
/// protocol, like a ``Color``, ``Material``, or ``HierarchicalShapeStyle``,
/// in front of a view. For example, you can overlay the
/// ``ShapeStyle/ultraThinMaterial`` over a ``Circle``:
///
///     struct CoveredCircle: View {
///         var body: some View {
///             Circle()
///                 .frame(width: 300, height: 200)
///                 .overlay(.ultraThinMaterial)
///         }
///     }
///
/// SwiftUI anchors the style to the view's bounds. For the example above,
/// the overlay fills the entirety of the circle's frame (which happens
/// to be wider than the circle is tall):
///
/// ![A screenshot of a circle showing through a rectangle that imposes
/// a blurring effect.](View-overlay-5)
///
/// SwiftUI also limits the style's extent to the view's
/// container-relative shape. You can see this effect if you constrain the
/// `CoveredCircle` view with a ``View/containerShape(_:)`` modifier:
///
///     CoveredCircle()
///         .containerShape(RoundedRectangle(cornerRadius: 30))
///
/// The overlay takes on the specified container shape:
///
/// ![A screenshot of a circle showing through a rounded rectangle that
/// imposes a blurring effect.](View-overlay-6)
///
/// By default, the overlay ignores safe area insets on all edges, but you
/// can provide a specific set of edges to ignore, or an empty set to
/// respect safe area insets on all edges:
///
///     Rectangle()
///         .overlay(
///             .secondary,
///             ignoresSafeAreaEdges: []) // Ignore no safe area insets.
///
/// If you want to specify a ``View`` or a stack of views as the overlay
/// rather than a style, use ``View/overlay(alignment:content:)`` instead.
/// If you want to specify a ``Shape``, use
/// ``View/overlay(_:in:fillStyle:)``.
///
/// - Parameters:
///   - style: An instance of a type that conforms to ``ShapeStyle`` that
///     SwiftUI layers in front of the modified view.
///   - edges: The set of edges for which to ignore safe area insets
///     when adding the overlay. The default value is ``Edge/Set/all``.
///     Specify an empty set to respect safe area insets on all edges.
///
/// - Returns: A view with the specified style drawn in front of it.
@inlinable public func overlay<S>(_ style: S, ignoresSafeAreaEdges edges: Edge.Set = .all) -> some View where S : ShapeStyle
/// Layers a shape that you specify in front of this view.
///
/// Use this modifier to layer a type that conforms to the ``Shape``
/// protocol --- like a ``Rectangle``, ``Circle``, or ``Capsule`` --- in
/// front of a view. Specify a ``ShapeStyle`` that's used to fill the shape.
/// For example, you can overlay the outline of one rectangle in front of
/// another:
///
///     Rectangle()
///         .frame(width: 200, height: 100)
///         .overlay(.teal, in: Rectangle().inset(by: 10).stroke(lineWidth: 5))
///
/// The example above uses the ``InsettableShape/inset(by:)`` method to
/// slightly reduce the size of the overlaid rectangle, and the
/// ``Shape/stroke(lineWidth:)`` method to fill only the shape's outline.
/// This creates an inset border:
///
/// ![A screenshot of a rectangle with a teal border that's
/// inset from the edge.](View-overlay-7)
///
/// This modifier is a convenience method for layering a shape over a view.
/// To handle the more general case of overlaying a ``View`` --- or a stack
/// of views --- with control over the position, use
/// ``View/overlay(alignment:content:)`` instead. To cover a view with a
/// ``ShapeStyle``, use ``View/overlay(_:ignoresSafeAreaEdges:)``.
///
/// - Parameters:
///   - style: A ``ShapeStyle`` that SwiftUI uses to the fill the shape
///     that you specify.
///   - shape: An instance of a type that conforms to ``Shape`` that
///     SwiftUI draws in front of the view.
///   - fillStyle: The ``FillStyle`` to use when drawing the shape.
///     The default style uses the nonzero winding number rule and
///     antialiasing.
///
/// - Returns: A view with the specified shape drawn in front of it.
@inlinable public func overlay<S, T>(_ style: S, in shape: T, fillStyle: FillStyle = FillStyle()) -> some View where S : ShapeStyle, T : Shape
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Presents a sheet using the given item as a data source
/// for the sheet's content.
///
/// Use this method when you need to present a modal view with content
/// from a custom data source. The example below shows a custom data source
/// `InventoryItem` that the `content` closure uses to populate the display
/// the action sheet shows to the user:
///
///     struct ShowPartDetail: View {
///         @State private var sheetDetail: InventoryItem?
///
///         var body: some View {
///             Button("Show Part Details") {
///                 sheetDetail = InventoryItem(
///                     id: "0123456789",
///                     partNumber: "Z-1234A",
///                     quantity: 100,
///                     name: "Widget")
///             }
///             .sheet(item: $sheetDetail,
///                    onDismiss: didDismiss) { detail in
///                 VStack(alignment: .leading, spacing: 20) {
///                     Text("Part Number: \(detail.partNumber)")
///                     Text("Name: \(detail.name)")
///                     Text("Quantity On-Hand: \(detail.quantity)")
///                 }
///                 .onTapGesture {
///                     sheetDetail = nil
///                 }
///             }
///         }
///
///         func didDismiss() {
///             // Handle the dismissing action.
///         }
///     }
///
///     struct InventoryItem: Identifiable {
///         var id: String
///         let partNumber: String
///         let quantity: Int
///         let name: String
///     }
///
/// ![A view showing a custom structure acting as a data source, providing
/// data to a modal sheet.](SwiftUI-View-SheetItemContent.png)
///
/// In vertically compact environments, such as iPhone in landscape
/// orientation, a sheet presentation automatically adapts to appear as a
/// full-screen cover. Use the ``View/presentationCompactAdaptation(_:)`` or
/// ``View/presentationCompactAdaptation(horizontal:vertical:)`` modifier to
/// override this behavior.
///
/// - Parameters:
///   - item: A binding to an optional source of truth for the sheet.
///     When `item` is non-`nil`, the system passes the item's content to
///     the modifier's closure. You display this content in a sheet that you
///     create that the system displays to the user. If `item` changes,
///     the system dismisses the sheet and replaces it with a new one
///     using the same process.
///   - onDismiss: The closure to execute when dismissing the sheet.
///   - content: A closure returning the content of the sheet.
public func sheet<Item, Content>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping (Item) -> Content) -> some View where Item : Identifiable, Content : View
/// Presents a sheet when a binding to a Boolean value that you
/// provide is true.
///
/// Use this method when you want to present a modal view to the
/// user when a Boolean value you provide is true. The example
/// below displays a modal view of the mockup for a software license
/// agreement when the user toggles the `isShowingSheet` variable by
/// clicking or tapping on the "Show License Agreement" button:
///
///     struct ShowLicenseAgreement: View {
///         @State private var isShowingSheet = false
///         var body: some View {
///             Button(action: {
///                 isShowingSheet.toggle()
///             }) {
///                 Text("Show License Agreement")
///             }
///             .sheet(isPresented: $isShowingSheet,
///                    onDismiss: didDismiss) {
///                 VStack {
///                     Text("License Agreement")
///                         .font(.title)
///                         .padding(50)
///                     Text("""
///                             Terms and conditions go here.
///                         """)
///                         .padding(50)
///                     Button("Dismiss",
///                            action: { isShowingSheet.toggle() })
///                 }
///             }
///         }
///
///         func didDismiss() {
///             // Handle the dismissing action.
///         }
///     }
///
/// ![A screenshot of a full-screen modal sheet showing the mockup of a
/// software license agreement with a Dismiss
/// button.](SwiftUI-View-SheetIsPresentingContent.png)
///
/// In vertically compact environments, such as iPhone in landscape
/// orientation, a sheet presentation automatically adapts to appear as a
/// full-screen cover. Use the ``View/presentationCompactAdaptation(_:)`` or
/// ``View/presentationCompactAdaptation(horizontal:vertical:)`` modifier to
/// override this behavior.
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the sheet that you create in the modifier's
///     `content` closure.
///   - onDismiss: The closure to execute when dismissing the sheet.
///   - content: A closure that returns the content of the sheet.
public func sheet<Content>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping () -> Content) -> some View where Content : View
}
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
@available(macOS, unavailable)
extension View {
/// Presents a modal view that covers as much of the screen as
/// possible using the binding you provide as a data source for the
/// sheet's content.
///
/// Use this method to display a modal view that covers as much of the
/// screen as possible. In the example below a custom structure —
/// `CoverData` — provides data for the full-screen view to display in the
/// `content` closure when the user clicks or taps the
/// "Present Full-Screen Cover With Data" button:
///
///     struct FullScreenCoverItemOnDismissContent: View {
///         @State private var coverData: CoverData?
///
///         var body: some View {
///             Button("Present Full-Screen Cover With Data") {
///                 coverData = CoverData(body: "Custom Data")
///             }
///             .fullScreenCover(item: $coverData,
///                              onDismiss: didDismiss) { details in
///                 VStack(spacing: 20) {
///                     Text("\(details.body)")
///                 }
///                 .onTapGesture {
///                     coverData = nil
///                 }
///             }
///         }
///
///         func didDismiss() {
///             // Handle the dismissing action.
///         }
///
///     }
///
///     struct CoverData: Identifiable {
///         var id: String {
///             return body
///         }
///         let body: String
///     }
///
/// ![A full-screen modal view that shows Custom
/// Content.](SwiftUI-FullScreenCoverItemOnDismissContent.png)
///
/// - Parameters:
///   - item: A binding to an optional source of truth for the sheet.
///     When `item` is non-`nil`, the system passes the contents to
///     the modifier's closure. You display this content in a sheet that you
///     create that the system displays to the user. If `item` changes,
///     the system dismisses the currently displayed sheet and replaces
///     it with a new one using the same process.
///   - onDismiss: The closure to execute when dismissing the modal view.
///   - content: A closure returning the content of the modal view.
public func fullScreenCover<Item, Content>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping (Item) -> Content) -> some View where Item : Identifiable, Content : View
/// Presents a modal view that covers as much of the screen as
/// possible when binding to a Boolean value you provide is true.
///
/// Use this method to show a modal view that covers as much of the screen
/// as possible. The example below displays a custom view when the user
/// toggles the value of the `isPresenting` binding:
///
///     struct FullScreenCoverPresentedOnDismiss: View {
///         @State private var isPresenting = false
///         var body: some View {
///             Button("Present Full-Screen Cover") {
///                 isPresenting.toggle()
///             }
///             .fullScreenCover(isPresented: $isPresenting,
///                              onDismiss: didDismiss) {
///                 VStack {
///                     Text("A full-screen modal view.")
///                         .font(.title)
///                     Text("Tap to Dismiss")
///                 }
///                 .onTapGesture {
///                     isPresenting.toggle()
///                 }
///                 .foregroundColor(.white)
///                 .frame(maxWidth: .infinity,
///                        maxHeight: .infinity)
///                 .background(Color.blue)
///                 .ignoresSafeArea(edges: .all)
///             }
///         }
///
///         func didDismiss() {
///             // Handle the dismissing action.
///         }
///     }
///
/// ![A full-screen modal view with the text A full-screen modal view
/// and Tap to Dismiss.](SwiftUI-FullScreenCoverIsPresented.png)
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the sheet.
///   - onDismiss: The closure to execute when dismissing the modal view.
///   - content: A closure that returns the content of the modal view.
public func fullScreenCover<Content>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping () -> Content) -> some View where Content : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Constrains this view's dimensions to the specified aspect ratio.
///
/// Use `aspectRatio(_:contentMode:)` to constrain a view's dimensions to an
/// aspect ratio specified by a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGFloat> using the specified
/// content mode.
///
/// If this view is resizable, the resulting view will have `aspectRatio` as
/// its aspect ratio. In this example, the purple ellipse has a 3:4
/// width-to-height ratio, and scales to fit its frame:
///
///     Ellipse()
///         .fill(Color.purple)
///         .aspectRatio(0.75, contentMode: .fit)
///         .frame(width: 200, height: 200)
///         .border(Color(white: 0.75))
///
/// ![A view showing a purple ellipse that has a 3:4 width-to-height ratio,
/// and scales to fit its frame.](SwiftUI-View-aspectRatio-cgfloat.png)
///
/// - Parameters:
///   - aspectRatio: The ratio of width to height to use for the resulting
///     view. Use `nil` to maintain the current aspect ratio in the
///     resulting view.
///   - contentMode: A flag that indicates whether this view fits or fills
///     the parent context.
///
/// - Returns: A view that constrains this view's dimensions to the aspect
///   ratio of the given size using `contentMode` as its scaling algorithm.
@inlinable public func aspectRatio(_ aspectRatio: CGFloat? = nil, contentMode: ContentMode) -> some View
/// Constrains this view's dimensions to the aspect ratio of the given size.
///
/// Use `aspectRatio(_:contentMode:)` to constrain a view's dimensions to
/// an aspect ratio specified by a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGSize>.
///
/// If this view is resizable, the resulting view uses `aspectRatio` as its
/// own aspect ratio. In this example, the purple ellipse has a 3:4
/// width-to-height ratio, and scales to fill its frame:
///
///     Ellipse()
///         .fill(Color.purple)
///         .aspectRatio(CGSize(width: 3, height: 4), contentMode: .fill)
///         .frame(width: 200, height: 200)
///         .border(Color(white: 0.75))
///
/// ![A view showing a purple ellipse that has a 3:4 width-to-height ratio,
/// and scales to fill its frame.](SwiftUI-View-aspectRatio.png)
///
/// - Parameters:
///   - aspectRatio: A size that specifies the ratio of width to height to
///     use for the resulting view.
///   - contentMode: A flag indicating whether this view should fit or fill
///     the parent context.
///
/// - Returns: A view that constrains this view's dimensions to
///   `aspectRatio`, using `contentMode` as its scaling algorithm.
@inlinable public func aspectRatio(_ aspectRatio: CGSize, contentMode: ContentMode) -> some View
/// Scales this view to fit its parent.
///
/// Use `scaledToFit()` to scale this view to fit its parent, while
/// maintaining the view's aspect ratio as the view scales.
///
///     Circle()
///         .fill(Color.pink)
///         .scaledToFit()
///         .frame(width: 300, height: 150)
///         .border(Color(white: 0.75))
///
/// ![A screenshot of pink circle scaled to fit its
/// frame.](SwiftUI-View-scaledToFit-1.png)
///
/// This method is equivalent to calling
/// ``View/aspectRatio(_:contentMode:)-6j7xz`` with a `nil` aspectRatio and
/// a content mode of ``ContentMode/fit``.
///
/// - Returns: A view that scales this view to fit its parent, maintaining
///   this view's aspect ratio.
@inlinable public func scaledToFit() -> some View
/// Scales this view to fill its parent.
///
/// Use `scaledToFill()` to scale this view to fill its parent, while
/// maintaining the view's aspect ratio as the view scales:
///
///     Circle()
///         .fill(Color.pink)
///         .scaledToFill()
///         .frame(width: 300, height: 150)
///         .border(Color(white: 0.75))
///
/// ![A screenshot of pink circle scaled to fill its
/// frame.](SwiftUI-View-scaledToFill-1.png)
///
/// This method is equivalent to calling
/// ``View/aspectRatio(_:contentMode:)-6j7xz`` with a `nil` aspectRatio and
/// a content mode of ``ContentMode/fill``.
///
/// - Returns: A view that scales this view to fill its parent, maintaining
///   this view's aspect ratio.
@inlinable public func scaledToFill() -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// The default store used by `AppStorage` contained within the view.
///
/// If unspecified, the default store for a view hierarchy is
/// `UserDefaults.standard`, but can be set a to a custom one. For example,
/// sharing defaults between an app and an extension can override the
/// default store to one created with `UserDefaults.init(suiteName:_)`.
///
/// - Parameter store: The user defaults to use as the default
///   store for `AppStorage`.
public func defaultAppStorage(_ store: UserDefaults) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Adds an action to perform when the user submits a value to this view.
///
/// Different views may have different triggers for the provided action.
/// A ``TextField``, or ``SecureField`` will trigger this action when the
/// user hits the hardware or software return key. This modifier may also
/// bind this action to a default action keyboard shortcut. You may set this
/// action on an individual view or an entire view hierarchy.
///
///     TextField("Username", text: $username)
///         .onSubmit {
///             guard viewModel.validate() else { return }
///             viewModel.login()
///         }
///
/// You can use the ``View/submitScope(_:)`` modifier to stop a submit
/// trigger from a control from propagating higher up in the view hierarchy
/// to higher `View.onSubmit(of:_:)` modifiers.
///
///     Form {
///         TextField("Username", text: $viewModel.userName)
///         SecureField("Password", text: $viewModel.password)
///
///         TextField("Tags", text: $viewModel.tags)
///             .submitScope()
///     }
///     .onSubmit {
///         guard viewModel.validate() else { return }
///         viewModel.login()
///     }
///
/// You can use different submit triggers to filter the types of triggers
/// that should invoke the provided submission action. For example, you
/// may provide a value of ``SubmitTriggers/search`` to only hear
/// submission triggers that originate from search fields vended by
/// searchable modifiers.
///
///     @StateObject private var viewModel = ViewModel()
///
///     NavigationView {
///         SidebarView()
///         DetailView()
///     }
///     .searchable(
///         text: $viewModel.searchText,
///         placement: .sidebar
///     ) {
///         SuggestionsView()
///     }
///     .onSubmit(of: .search) {
///         viewModel.submitCurrentSearchQuery()
///     }
///
/// - Parameters:
///   - triggers: The triggers that should invoke the provided action.
///   - action: The action to perform on submission of a value.
public func onSubmit(of triggers: SubmitTriggers = .text, _ action: @escaping (() -> Void)) -> some View
/// Prevents submission triggers originating from this view to invoke
/// a submission action configured by a submission modifier higher up
/// in the view hierarchy.
///
/// Use this modifier when you want to avoid specific views from initiating
/// a submission action configured by the ``View/onSubmit(of:_:)`` modifier.
/// In the example below, the tag field doesn't trigger the submission of
/// the form:
///
///     Form {
///         TextField("Username", text: $viewModel.userName)
///         SecureField("Password", text: $viewModel.password)
///
///         TextField("Tags", text: $viewModel.tags)
///             .submitScope()
///     }
///     .onSubmit {
///         guard viewModel.validate() else { return }
///         viewModel.login()
///     }
///
/// - Parameter isBlocking: A Boolean that indicates whether this scope is
///   actively blocking submission triggers from reaching higher submission
///   actions.
public func submitScope(_ isBlocking: Bool = true) -> some View
}
@available(iOS 13.0, macOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Hides the navigation bar for this view.
///
/// Use `navigationBarHidden(_:)` to hide the navigation bar. This modifier
/// only takes effect when this view is inside of and visible within a
/// ``NavigationView``.
///
/// - Parameter hidden: A Boolean value that indicates whether to hide the
///   navigation bar.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(.hidden)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(.hidden)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use toolbar(.hidden)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use toolbar(.hidden)")
public func navigationBarHidden(_ hidden: Bool) -> some View
/// Sets the title in the navigation bar for this view.
///
/// Use `navigationBarTitle(_:)` to set the title of the navigation bar.
/// This modifier only takes effect when this view is inside of and visible
/// within a ``NavigationView``.
///
/// The example below shows setting the title of the navigation bar using a
/// ``Text`` view:
///
///     struct FlavorView: View {
///         let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                      "Pistachio"]
///         var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle(Text("Today's Flavors"))
///             }
///         }
///     }
///
/// ![A screenshot showing the title of a navigation bar configured using a
/// text view.](SwiftUI-navigationBarTitle-Text.png)
///
/// - Parameter title: A description of this view to display in the
///   navigation bar.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
public func navigationBarTitle(_ title: Text) -> some View
/// Sets the title of this view's navigation bar with a localized string.
///
/// Use `navigationBarTitle(_:)` to set the title of the navigation bar
/// using a ``LocalizedStringKey`` that will be used to search for a
/// matching localized string in the application's localizable strings
/// assets.
///
/// This modifier only takes effect when this view is inside of and visible
/// within a ``NavigationView``.
///
/// In the example below, a string constant is used to access a
/// ``LocalizedStringKey`` that will be resolved at run time to provide a
/// title for the navigation bar. If the localization key cannot be
/// resolved, the text of the key name will be used as the title text.
///
///     struct FlavorView: View {
///         let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                      "Pistachio"]
///         var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle("Today's Flavors")
///             }
///         }
///     }
///
/// - Parameter titleKey: A key to a localized description of this view to
///   display in the navigation bar.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
public func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View
/// Sets the title of this view's navigation bar with a string.
///
/// Use `navigationBarTitle(_:)` to set the title of the navigation bar
/// using a `String`. This modifier only takes effect when this view is
/// inside of and visible within a ``NavigationView``.
///
/// In the example below, text for the navigation bar title is provided
/// using a string:
///
///     struct FlavorView: View {
///         let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                      "Pistachio"]
///         let text = "Today's Flavors"
///         var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle(text)
///             }
///         }
///     }
///
/// - Parameter title: A title for this view to display in the navigation
///   bar.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
public func navigationBarTitle<S>(_ title: S) -> some View where S : StringProtocol
/// Sets the title and display mode in the navigation bar for this view.
///
/// Use `navigationBarTitle(_:displayMode:)` to set the title of the
/// navigation bar for this view and specify a display mode for the title
/// from one of the ``NavigationBarItem/TitleDisplayMode`` styles. This
/// modifier only takes effect when this view is inside of and visible
/// within a ``NavigationView``.
///
/// In the example below, text for the navigation bar title is provided
/// using a ``Text`` view. The navigation bar title's
/// ``NavigationBarItem/TitleDisplayMode`` is set to `.inline` which places
/// the navigation bar title in the bounds of the navigation bar.
///
///     struct FlavorView: View {
///        let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                     "Pistachio"]
///        var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle(Text("Today's Flavors", displayMode: .inline)
///             }
///         }
///     }
///
/// - Parameters:
///   - title: A title for this view to display in the navigation bar.
///   - displayMode: The style to use for displaying the navigation bar title.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
public func navigationBarTitle(_ title: Text, displayMode: NavigationBarItem.TitleDisplayMode) -> some View
/// Sets the title and display mode in the navigation bar for this view.
///
/// Use `navigationBarTitle(_:displayMode:)` to set the title of the
/// navigation bar for this view and specify a display mode for the title
/// from one of the ``NavigationBarItem/TitleDisplayMode`` styles. This
/// modifier only takes effect when this view is inside of and visible
/// within a ``NavigationView``.
///
/// In the example below, text for the navigation bar title is provided
/// using a string. The navigation bar title's
/// ``NavigationBarItem/TitleDisplayMode`` is set to `.inline` which places
/// the navigation bar title in the bounds of the navigation bar.
///
///     struct FlavorView: View {
///         let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                      "Pistachio"]
///         var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle("Today's Flavors", displayMode: .inline)
///             }
///         }
///     }
///
/// If the `titleKey` can't be found, the title uses the text of the key
/// name instead.
///
/// - Parameters:
///   - titleKey: A key to a localized description of this view to display
///     in the navigation bar.
///   - displayMode: The style to use for displaying the navigation bar
///     title.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
public func navigationBarTitle(_ titleKey: LocalizedStringKey, displayMode: NavigationBarItem.TitleDisplayMode) -> some View
/// Sets the title and display mode in the navigation bar for this view.
///
/// Use `navigationBarTitle(_:displayMode:)` to set the title of the
/// navigation bar for this view and specify a display mode for the
/// title from one of the `NavigationBarItem.Title.DisplayMode`
/// styles. This modifier only takes effect when this view is inside of and
/// visible within a `NavigationView`.
///
/// In the example below, `navigationBarTitle(_:displayMode:)` uses a
/// string to provide a title for the navigation bar. Setting the title's
/// `displayMode` to `.inline` places the navigation bar title within the
/// bounds of the navigation bar.
///
/// In the example below, text for the navigation bar title is provided using
/// a string. The navigation bar title's `displayMode` is set to
/// `.inline` which places the navigation bar title in the bounds of the
/// navigation bar.
///
///     struct FlavorView: View {
///         let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
///                      "Pistachio"]
///         let title = "Today's Flavors"
///         var body: some View {
///             NavigationView {
///                 List(items, id: \.self) {
///                     Text($0)
///                 }
///                 .navigationBarTitle(title, displayMode: .inline)
///             }
///         }
///     }
///
/// ![A screenshot of a navigation bar, showing the title within the bounds
///  of the navigation bar]
/// (SwiftUI-navigationBarTitle-stringProtocol.png)
///
/// - Parameters:
///   - title: A title for this view to display in the navigation bar.
///   - displayMode: The way to display the title.
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
public func navigationBarTitle<S>(_ title: S, displayMode: NavigationBarItem.TitleDisplayMode) -> some View where S : StringProtocol
/// Hides the navigation bar back button for the view.
///
/// Use `navigationBarBackButtonHidden(_:)` to hide the back button for this
/// view.
///
/// This modifier only takes effect when this view is inside of and visible
/// within a ``NavigationView``.
///
/// - Parameter hidesBackButton: A Boolean value that indicates whether to
///   hide the back button. The default value is `true`.
public func navigationBarBackButtonHidden(_ hidesBackButton: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a different padding amount to each edge of this view.
///
/// Use this modifier to add a different amount of padding on each edge
/// of a view:
///
///     VStack {
///         Text("Text padded by different amounts on each edge.")
///             .padding(EdgeInsets(top: 10, leading: 20, bottom: 40, trailing: 0))
///             .border(.gray)
///         Text("Unpadded text for comparison.")
///             .border(.yellow)
///     }
///
/// The order in which you apply modifiers matters. The example above
/// applies the padding before applying the border to ensure that the
/// border encompasses the padded region:
///
/// ![A screenshot of two text strings arranged vertically, each surrounded
/// by a border, with a small space between the two borders.
/// The first string says Text padded by different amounts on each edge.
/// Its border is gray, and there are different amounts of space between
/// the string and its border on each edge: 40 points on the bottom, 10
/// points on the top, 20 points on the leading edge, and no space on
/// the trailing edge.
/// The second string says Unpadded text for comparison.
/// Its border is yellow, and there's no space between the string
/// and its border.](View-padding-3-iOS)
///
/// To pad a view on specific edges with equal padding for all padded
/// edges, use ``View/padding(_:_:)``. To pad all edges of a view
/// equally, use ``View/padding(_:)-68shk``.
///
/// - Parameter insets: An ``EdgeInsets`` instance that contains
///   padding amounts for each edge.
///
/// - Returns: A view that's padded by different amounts on each edge.
@inlinable public func padding(_ insets: EdgeInsets) -> some View
/// Adds an equal padding amount to specific edges of this view.
///
/// Use this modifier to add a specified amount of padding to one or more
/// edges of the view. Indicate the edges to pad by naming either a single
/// value from ``Edge/Set``, or by specifying an
/// <doc://com.apple.documentation/documentation/Swift/OptionSet>
/// that contains edge values:
///
///     VStack {
///         Text("Text padded by 20 points on the bottom and trailing edges.")
///             .padding([.bottom, .trailing], 20)
///             .border(.gray)
///         Text("Unpadded text for comparison.")
///             .border(.yellow)
///     }
///
/// The order in which you apply modifiers matters. The example above
/// applies the padding before applying the border to ensure that the
/// border encompasses the padded region:
///
/// ![A screenshot of two text strings arranged vertically, each surrounded
/// by a border, with a small space between the two borders.
/// The first string says Text padded by 20 points
/// on the bottom and trailing edges.
/// Its border is gray, and there are 20 points of space between the bottom
/// and trailing edges of the string and its border.
/// There's no space between the string and the border on the other edges.
/// The second string says Unpadded text for comparison.
/// Its border is yellow, and there's no space between the string
/// and its border.](View-padding-2-iOS)
///
/// You can omit either or both of the parameters. If you omit the `length`,
/// SwiftUI uses a default amount of padding. If you
/// omit the `edges`, SwiftUI applies the padding to all edges. Omit both
/// to add a default padding all the way around a view. SwiftUI chooses a
/// default amount of padding that's appropriate for the platform and
/// the presentation context.
///
///     VStack {
///         Text("Text with default padding.")
///             .padding()
///             .border(.gray)
///         Text("Unpadded text for comparison.")
///             .border(.yellow)
///     }
///
/// The example above looks like this in iOS under typical conditions:
///
/// ![A screenshot of two text strings arranged vertically, each surrounded
/// by a border, with a small space between the two borders.
/// The first string says Text with default padding.
/// Its border is gray, and there is padding on all sides
/// between the border and the string it encloses in an amount that's
/// similar to the height of the text.
/// The second string says Unpadded text for comparison.
/// Its border is yellow, and there's no space between the string
/// and its border.](View-padding-2a-iOS)
///
/// To control the amount of padding independently for each edge, use
/// ``View/padding(_:)-6pgqq``. To pad all outside edges of a view by a
/// specified amount, use ``View/padding(_:)-68shk``.
///
/// - Parameters:
///   - edges: The set of edges to pad for this view. The default
///     is ``Edge/Set/all``.
///   - length: An amount, given in points, to pad this view on the
///     specified edges. If you set the value to `nil`, SwiftUI uses
///     a platform-specific default amount. The default value of this
///     parameter is `nil`.
///
/// - Returns: A view that's padded by the specified amount on the
///   specified edges.
@inlinable public func padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View
/// Adds a specific padding amount to each edge of this view.
///
/// Use this modifier to add padding all the way around a view.
///
///     VStack {
///         Text("Text padded by 10 points on each edge.")
///             .padding(10)
///             .border(.gray)
///         Text("Unpadded text for comparison.")
///             .border(.yellow)
///     }
///
/// The order in which you apply modifiers matters. The example above
/// applies the padding before applying the border to ensure that the
/// border encompasses the padded region:
///
/// ![A screenshot of two text strings arranged vertically, each surrounded
/// by a border, with a small space between the two borders.
/// The first string says Text padded by 10 points on each edge.
/// Its border is gray, and there are 10 points of space on all sides
/// between the string and its border.
/// The second string says Unpadded text for comparison.
/// Its border is yellow, and there's no space between the string
/// and its border.](View-padding-1-iOS)
///
/// To independently control the amount of padding for each edge, use
/// ``View/padding(_:)-6pgqq``. To pad a select set of edges by the
/// same amount, use ``View/padding(_:_:)``.
///
/// - Parameter length: The amount, given in points, to pad this view on all
///   edges.
///
/// - Returns: A view that's padded by the amount you specify.
@inlinable public func padding(_ length: CGFloat) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Adds padding to the specified edges of this view using an amount that's
/// appropriate for the current scene.
///
/// Use this modifier to add a scene-appropriate amount of padding to a
/// view. Specify either a single edge value from ``Edge/Set``, or an
/// <doc://com.apple.documentation/documentation/Swift/OptionSet> that
/// describes the edges to pad.
///
/// In macOS, use scene padding to produce the recommended spacing around
/// the root view of a window. In watchOS, use scene padding to align
/// elements of your user interface with top level elements, like the title
/// of a navigation view. For example, compare the effects of different
/// kinds of padding on text views presented inside a ``NavigationView``
/// in watchOS:
///
///     VStack(alignment: .leading, spacing: 10) {
///         Text("Scene padding")
///             .scenePadding(.horizontal)
///             .border(.red) // Border added for reference.
///         Text("Regular padding")
///             .padding(.horizontal)
///             .border(.green)
///         Text("Text with no padding")
///             .border(.blue)
///         Button("Button") { }
///     }
///     .navigationTitle("Hello World")
///
/// The text with scene padding automatically aligns with the title,
/// unlike the text that uses the default padding or the text without
/// padding:
///
/// ![A watchOS screenshot with the title Hello World and a back button
/// in the upper left. The title is indented by a small amount from
/// the leading edge of the screen. Three bordered strings and a button
/// appear arranged vertically below the title.
/// The first string says Scene padding and has a red border that's aligned
/// with the leading edge of the screen. The leading
/// edge of the string inside the border aligns with the leading edge of
/// the screen's title.
/// The second string says Regular padding and has a green border that's
/// aligned with the leading edge of the screen. The leading edge of the
/// string appears offset from the title's leading edge by a small amount.
/// The third string says Text with no padding and has a blue border that's
/// aligned with the leading edge of the screen. The string is also aligned
/// with the leading edge of the screen.](View-scenePadding-1-watchOS)
///
/// Scene padding in watchOS also ensures that your content avoids the
/// curved edges of a device like Apple Watch Series 7.
/// In other platforms, scene padding produces the same default padding that
/// you get from the ``View/padding(_:_:)`` modifier.
///
/// > Important: Scene padding doesn't pad the top and bottom edges of a
/// view in watchOS, even if you specify those edges as part of the input.
/// For example, if you specify ``Edge/Set/vertical`` instead of
/// ``Edge/Set/horizontal`` in the example above, the modifier would have
/// no effect in watchOS. It does, however, apply to all the edges that you
/// specify in other platforms.
///
/// - Parameter edges: The set of edges along which to pad this view.
///
/// - Returns: A view that's padded on specified edges by a
///   scene-appropriate amount.
public func scenePadding(_ edges: Edge.Set = .all) -> some View
/// Adds a specified kind of padding to the specified edges of this view
/// using an amount that's appropriate for the current scene.
///
/// Use this modifier to add a scene-appropriate amount of padding to a
/// view. Specify either a single edge value from ``Edge/Set``, or an
/// <doc://com.apple.documentation/documentation/Swift/OptionSet> that
/// describes the edges to pad.
///
/// In macOS, use scene padding to produce the recommended spacing around
/// the root view of a window. In watchOS, use scene padding to align
/// elements of your user interface with top level elements, like the title
/// of a navigation view. For example, compare the effects of different
/// kinds of padding on text views presented inside a ``NavigationView``
/// in watchOS:
///
///     VStack(alignment: .leading, spacing: 10) {
///         Text("Minimum Scene padding")
///             .scenePadding(.minimum, edges: .horizontal)
///             .border(.red) // Border added for reference.
///         Text("Navigation Bar Scene padding")
///             .scenePadding(.navigationBar, edges: .horizontal)
///             .border(.yellow)
///         Text("Regular padding")
///             .padding(.horizontal)
///             .border(.green)
///         Text("Text with no padding")
///             .border(.blue)
///         Button("Button") { }
///     }
///     .navigationTitle("Hello World")
///
/// The text with minimum scene padding uses the system minimum padding
/// and the text with navigation bar scene padding automatically aligns
/// with the navigation bar content. In contrast, the text that uses the
/// default padding and the text without padding do not align with scene
/// elements.
///
/// Scene padding in watchOS also ensures that your content avoids the
/// curved edges of a device like Apple Watch Series 7.
/// In other platforms, scene padding produces the same default padding that
/// you get from the ``View/padding(_:_:)`` modifier.
///
/// > Important: Scene padding doesn't pad the top and bottom edges of a
/// view in watchOS, even if you specify those edges as part of the input.
/// For example, if you specify ``Edge/Set/vertical`` instead of
/// ``Edge/Set/horizontal`` in the example above, the modifier would have
/// no effect in watchOS. It does, however, apply to all the edges that you
/// specify in other platforms.
///
/// - Parameter padding: The kind of padding to add.
/// - Parameter edges: The set of edges along which to pad this view.
///
/// - Returns: A view that's padded on specified edges by a
///   scene-appropriate amount.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func scenePadding(_ padding: ScenePadding, edges: Edge.Set = .all) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Explicitly set whether this Accessibility element responds to user
/// interaction and would thus be interacted with by technologies such as
/// Switch Control, Voice Control or Full Keyboard Access.
///
/// If this is not set, the value is inferred from the traits of the
/// Accessibility element, the presence of Accessibility actions on the
/// element, or the presence of gestures on the element or containing views.
public func accessibilityRespondsToUserInteraction(_ respondsToUserInteraction: Bool = true) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for buttons within this view to a button style with a
/// custom appearance and custom interaction behavior.
///
/// Use this modifier to set a specific style for button instances
/// within a view:
///
///     HStack {
///         Button("Sign In", action: signIn)
///         Button("Register", action: register)
///     }
///     .buttonStyle(.bordered)
///
public func buttonStyle<S>(_ style: S) -> some View where S : PrimitiveButtonStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Modifies this view by binding its focus state to the given state value.
///
/// Use this modifier to cause the view to receive focus whenever the
/// the `binding` equals the `value`. Typically, you create an enumeration
/// of fields that may receive focus, bind an instance of this enumeration,
/// and assign its cases to focusable views.
///
/// The following example uses the cases of a `LoginForm` enumeration to
/// bind the focus state of two ``TextField`` views. A sign-in button
/// validates the fields and sets the bound `focusedField` value to
/// any field that requires the user to correct a problem.
///
///     struct LoginForm {
///         enum Field: Hashable {
///             case usernameField
///             case passwordField
///         }
///
///         @State private var username = ""
///         @State private var password = ""
///         @FocusState private var focusedField: Field?
///
///         var body: some View {
///             Form {
///                 TextField("Username", text: $username)
///                     .focused($focusedField, equals: .usernameField)
///
///                 SecureField("Password", text: $password)
///                     .focused($focusedField, equals: .passwordField)
///
///                 Button("Sign In") {
///                     if username.isEmpty {
///                         focusedField = .usernameField
///                     } else if password.isEmpty {
///                         focusedField = .passwordField
///                     } else {
///                         handleLogin(username, password)
///                     }
///                 }
///             }
///         }
///     }
///
/// To control focus using a Boolean, use the ``View/focused(_:)`` method
/// instead.
///
/// - Parameters:
///   - binding: The state binding to register. When focus moves to the
///     modified view, the binding sets the bound value to the corresponding
///     match value. If a caller sets the state value programmatically to the
///     matching value, then focus moves to the modified view. When focus
///     leaves the modified view, the binding sets the bound value to
///     `nil`. If a caller sets the value to `nil`, SwiftUI automatically
///     dismisses focus.
///   - value: The value to match against when determining whether the
///     binding should change.
/// - Returns: The modified view.
public func focused<Value>(_ binding: FocusState<Value>.Binding, equals value: Value) -> some View where Value : Hashable
/// Modifies this view by binding its focus state to the given Boolean state
/// value.
///
/// Use this modifier to cause the view to receive focus whenever the
/// the `condition` value is `true`. You can use this modifier to
/// observe the focus state of a single view, or programmatically set and
/// remove focus from the view.
///
/// In the following example, a single ``TextField`` accepts a user's
/// desired `username`. The text field binds its focus state to the
/// Boolean value `usernameFieldIsFocused`. A "Submit" button's action
/// verifies whether the name is available. If the name is unavailable, the
/// button sets `usernameFieldIsFocused` to `true`, which causes focus to
/// return to the text field, so the user can enter a different name.
///
///     @State private var username: String = ""
///     @FocusState private var usernameFieldIsFocused: Bool
///     @State private var showUsernameTaken = false
///
///     var body: some View {
///         VStack {
///             TextField("Choose a username.", text: $username)
///                 .focused($usernameFieldIsFocused)
///             if showUsernameTaken {
///                 Text("That username is taken. Please choose another.")
///             }
///             Button("Submit") {
///                 showUsernameTaken = false
///                 if !isUserNameAvailable(username: username) {
///                     usernameFieldIsFocused = true
///                     showUsernameTaken = true
///                 }
///             }
///         }
///     }
///
/// To control focus by matching a value, use the
/// ``View/focused(_:equals:)`` method instead.
///
/// - Parameter condition: The focus state to bind. When focus moves
///   to the view, the binding sets the bound value to `true`. If a caller
///   sets the value to  `true` programmatically, then focus moves to the
///   modified view. When focus leaves the modified view, the binding
///   sets the value to `false`. If a caller sets the value to `false`,
///   SwiftUI automatically dismisses focus.
///
/// - Returns: The modified view.
public func focused(_ condition: FocusState<Bool>.Binding) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Offset this view by the horizontal and vertical amount specified in the
/// offset parameter.
///
/// Use `offset(_:)` to shift the displayed contents by the amount
/// specified in the `offset` parameter.
///
/// The original dimensions of the view aren't changed by offsetting the
/// contents; in the example below the gray border drawn by this view
/// surrounds the original position of the text:
///
///     Text("Offset by passing CGSize()")
///         .border(Color.green)
///         .offset(CGSize(width: 20, height: 25))
///         .border(Color.gray)
///
/// ![A screenshot showing a view that offset from its original position a
/// CGPoint to specify the x and y offset.](SwiftUI-View-offset.png)
///
/// - Parameter offset: The distance to offset this view.
///
/// - Returns: A view that offsets this view by `offset`.
@inlinable public func offset(_ offset: CGSize) -> some View
/// Offset this view by the specified horizontal and vertical distances.
///
/// Use `offset(x:y:)` to shift the displayed contents by the amount
/// specified in the `x` and `y` parameters.
///
/// The original dimensions of the view aren't changed by offsetting the
/// contents; in the example below the gray border drawn by this view
/// surrounds the original position of the text:
///
///     Text("Offset by passing horizontal & vertical distance")
///         .border(Color.green)
///         .offset(x: 20, y: 50)
///         .border(Color.gray)
///
/// ![A screenshot showing a view that offset from its original position
/// using and x and y offset.](swiftui-offset-xy.png)
///
/// - Parameters:
///   - x: The horizontal distance to offset this view.
///   - y: The vertical distance to offset this view.
///
/// - Returns: A view that offsets this view by `x` and `y`.
@inlinable public func offset(x: CGFloat = 0, y: CGFloat = 0) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Positions the center of this view at the specified point in its parent's
/// coordinate space.
///
/// Use the `position(_:)` modifier to place the center of a view at a
/// specific coordinate in the parent view using a
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGPoint> to specify the `x`
/// and `y` offset.
///
///     Text("Position by passing a CGPoint()")
///         .position(CGPoint(x: 175, y: 100))
///         .border(Color.gray)
///
/// - Parameter position: The point at which to place the center of this
///   view.
///
/// - Returns: A view that fixes the center of this view at `position`.
@inlinable public func position(_ position: CGPoint) -> some View
/// Positions the center of this view at the specified coordinates in its
/// parent's coordinate space.
///
/// Use the `position(x:y:)` modifier to place the center of a view at a
/// specific coordinate in the parent view using an `x` and `y` offset.
///
///     Text("Position by passing the x and y coordinates")
///         .position(x: 175, y: 100)
///         .border(Color.gray)
///
/// - Parameters:
///   - x: The x-coordinate at which to place the center of this view.
///   - y: The y-coordinate at which to place the center of this view.
///
/// - Returns: A view that fixes the center of this view at `x` and `y`.
@inlinable public func position(x: CGFloat = 0, y: CGFloat = 0) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the submit label for this view.
///
///     Form {
///         TextField("Username", $viewModel.username)
///             .submitLabel(.continue)
///         SecureField("Password", $viewModel.password)
///             .submitLabel(.done)
///     }
///
/// - Parameter submitLabel: One of the cases specified in ``SubmitLabel``.
public func submitLabel(_ submitLabel: SubmitLabel) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Marks this view as refreshable.
///
/// Apply this modifier to a view to set the ``EnvironmentValues/refresh``
/// value in the view's environment to a ``RefreshAction`` instance that
/// uses the specified `action` as its handler. Views that detect the
/// presence of the instance can change their appearance to provide a
/// way for the user to execute the handler.
///
/// For example, when you apply this modifier on iOS and iPadOS to a
/// ``List``, the list enables a standard pull-to-refresh gesture that
/// refreshes the list contents. When the user drags the top of the
/// scrollable area downward, the view reveals a progress indicator
/// and executes the specified handler. The indicator remains visible
/// for the duration of the refresh, which runs asynchronously:
///
///     List(mailbox.conversations) { conversation in
///         ConversationCell(conversation)
///     }
///     .refreshable {
///         await mailbox.fetch()
///     }
///
/// You can add refresh capability to your own views as well. For
/// information on how to do that, see ``RefreshAction``.
///
/// - Parameters:
///   - action: An asynchronous handler that SwiftUI executes when the
///   user requests a refresh. Use this handler to initiate
///   an update of model data displayed in the modified view. Use
///   `await` in front of any asynchronous calls inside the handler.
/// - Returns: A view with a new refresh action in its environment.
public func refreshable(action: @escaping @Sendable () async -> Void) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Isolates the geometry (e.g. position and size) of the view
/// from its parent view.
///
/// By default SwiftUI views push position and size changes down
/// through the view hierarchy, so that only views that draw
/// something (known as leaf views) apply the current animation to
/// their frame rectangle. However in some cases this coalescing
/// behavior can give undesirable results; inserting a geometry
/// group can correct that. A group acts as a barrier between the
/// parent view and its subviews, forcing the position and size
/// values to be resolved and animated by the parent, before being
/// passed down to each subview.
///
/// The example below shows one use of this function: ensuring that
/// the member views of each row in the stack apply (and animate
/// as) a single geometric transform from their ancestor view,
/// rather than letting the effects of the ancestor views be
/// applied separately to each leaf view. If the members of
/// `ItemView` may be added and removed at different times the
/// group ensures that they stay locked together as animations are
/// applied.
///
///     VStack {
///         ForEach(items) { item in
///             ItemView(item: item)
///                 .geometryGroup()
///         }
///     }
///
/// Returns: a new view whose geometry is isolated from that of its
/// parent view.
public func geometryGroup() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies a projection transformation to this view's rendered output.
///
/// Use `projectionEffect(_:)` to apply a 3D transformation to the view.
///
/// The example below rotates the text 30˚ around the `z` axis, which is the
/// axis pointing out of the screen:
///
///     // This transform represents a 30˚ rotation around the z axis.
///     let transform = CATransform3DMakeRotation(
///         -30 * (.pi / 180), 0.0, 0.0, 1.0)
///
///     Text("Projection effects using transforms")
///         .projectionEffect(.init(transform))
///         .border(Color.gray)
///
/// ![A screenshot showing text rotated 30 degrees around the axis pointing
/// out of the screen.](SwiftUI-View-projectionEffect.png)
///
/// - Parameter transform: A ``ProjectionTransform`` to apply to the view.
@inlinable public func projectionEffect(_ transform: ProjectionTransform) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies an affine transformation to this view's rendered output.
///
/// Use `transformEffect(_:)` to rotate, scale, translate, or skew the
/// output of the view according to the provided
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGAffineTransform>.
///
/// In the example below, the text is rotated at -30˚ on the `y` axis.
///
///     let transform = CGAffineTransform(rotationAngle: -30 * (.pi / 180))
///
///     Text("Projection effect using transforms")
///         .transformEffect(transform)
///         .border(Color.gray)
///
/// ![A screenshot of a view showing text that is rotated at -30 degrees on
/// the y axis.](SwiftUI-View-transformEffect.png)
///
/// - Parameter transform: A
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGAffineTransform> to
/// apply to the view.
@inlinable public func transformEffect(_ transform: CGAffineTransform) -> some View
}
@available(iOS 13.4, tvOS 16.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Applies a hover effect to this view.
///
/// By default, ``HoverEffect/automatic`` is used. You can control the
/// behavior of the automatic effect with the
/// ``View/defaultHoverEffect(_:)`` modifier.
///
/// - Parameters:
///   - effect: The effect to apply to this view.
///   - isEnabled: Whether the effect is enabled or not.
/// - Returns: A new view that applies a hover effect to `self`.
@available(iOS 13.4, tvOS 16.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public func hoverEffect(_ effect: HoverEffect = .automatic) -> some View
}
@available(iOS 17.0, tvOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Applies a hover effect to this view.
///
/// By default, ``HoverEffect/automatic`` is used. You can control the
/// behavior of the automatic effect with the
/// ``View/defaultHoverEffect(_:)`` modifier.
///
/// - Parameters:
///   - effect: The effect to apply to this view.
///   - isEnabled: Whether the effect is enabled or not.
/// - Returns: A new view that applies a hover effect to `self`.
public func hoverEffect(_ effect: HoverEffect = .automatic, isEnabled: Bool = true) -> some View
/// Sets the default hover effect to use for views within this view.
///
/// Use this modifier to set a specific hover effect for all views with the
/// ``View/hoverEffect(_:)`` modifier applied within a view. The default
/// effect is typically used when no ``HoverEffect`` was provided or if
/// ``HoverEffect/automatic`` is specified.
///
/// For example, this view uses ``HoverEffect/highlight`` for both the red
/// and green Color views:
///
///     HStack {
///         Color.red.hoverEffect()
///         Color.green.hoverEffect()
///     }
///     .defaultHoverEffect(.highlight)
///
/// This also works for customizing the default hover effect in views like
/// ``Button``s when using a SwiftUI-defined style like
/// ``ButtonStyle/bordered``, which can provide a hover effect by default.
/// For example, this view replaces the hover effect for a ``Button`` with
/// ``HoverEffect/highlight``:
///
///     Button("Next") {}
///         // perform action
///     }
///     .buttonStyle(.bordered)
///     .defaultHoverEffect(.highlight)
///
/// Use a `nil` effect to indicate that the default hover effect should not
/// be modified.
///
/// - Parameter effect: The default hover effect to use for views within
///   this view.
/// - Returns: A view that uses this effect as the default hover effect.
public func defaultHoverEffect(_ effect: HoverEffect?) -> some View
/// Adds a condition that controls whether this view can display hover
/// effects.
///
/// The higher views in a view hierarchy can override the value you set on
/// this view. In the following example, the button does not display a hover
/// effect because the outer `hoverEffectDisabled(_:)` modifier overrides
/// the inner one:
///
///     HStack {
///         Button("Press") {}
///             .hoverEffectDisabled(false)
///     }
///     .hoverEffectDisabled(true)
///
/// - Parameter disabled: A Boolean value that determines whether this view
///   can display hover effects.
///
/// - Returns: A view that controls whether hover effects can be displayed
///   in this view.
public func hoverEffectDisabled(_ disabled: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Rotates this view's rendered output around the specified point.
///
/// Use `rotationEffect(_:anchor:)` to rotate the view by a specific amount.
///
/// In the example below, the text is rotated by 22˚.
///
///     Text("Rotation by passing an angle in degrees")
///         .rotationEffect(.degrees(22))
///         .border(Color.gray)
///
/// ![A screenshot showing rotation effect rotating the text 22 degrees with
/// respect to its view.](SwiftUI-View-rotationEffect.png)
///
/// - Parameters:
///   - angle: The angle at which to rotate the view.
///   - anchor: The location with a default of ``UnitPoint/center`` that
///     defines a point at which the rotation is anchored.
@inlinable public func rotationEffect(_ angle: Angle, anchor: UnitPoint = .center) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Scales this view's rendered output by the given vertical and horizontal
/// size amounts, relative to an anchor point.
///
/// Use `scaleEffect(_:anchor:)` to scale a view by applying a scaling
/// transform of a specific size, specified by `scale`.
///
///     Image(systemName: "envelope.badge.fill")
///         .resizable()
///         .frame(width: 100, height: 100, alignment: .center)
///         .foregroundColor(Color.red)
///         .scaleEffect(CGSize(x: 0.9, y: 1.3), anchor: .leading)
///         .border(Color.gray)
///
/// ![A screenshot showing a red envelope scaled to a size of 90x130
/// pixels.](SwiftUI-View-scaleEffect.png)
///
/// - Parameters:
///   - scale: A <doc://com.apple.documentation/documentation/CoreGraphics/CGSize> that
///     represents the horizontal and vertical amount to scale the view.
///   - anchor: The point with a default of ``UnitPoint/center`` that
///     defines the location within the view from which to apply the
///     transformation.
@inlinable public func scaleEffect(_ scale: CGSize, anchor: UnitPoint = .center) -> some View
/// Scales this view's rendered output by the given amount in both the
/// horizontal and vertical directions, relative to an anchor point.
///
/// Use `scaleEffect(_:anchor:)` to apply a horizontally and vertically
/// scaling transform to a view.
///
///     Image(systemName: "envelope.badge.fill")
///         .resizable()
///         .frame(width: 100, height: 100, alignment: .center)
///         .foregroundColor(Color.red)
///         .scaleEffect(2, anchor: .leading)
///         .border(Color.gray)
///
/// ![A screenshot showing a 100x100 pixel red envelope scaled up to 2x the
/// size of its view.](SwiftUI-View-scaleEffect-cgfloat.png)
///
/// - Parameters:
///   - s: The amount to scale the view in the view in both the horizontal
///     and vertical directions.
///   - anchor: The anchor point with a default of ``UnitPoint/center`` that
///     indicates the starting position for the scale operation.
@inlinable public func scaleEffect(_ s: CGFloat, anchor: UnitPoint = .center) -> some View
/// Scales this view's rendered output by the given horizontal and vertical
/// amounts, relative to an anchor point.
///
/// Use `scaleEffect(x:y:anchor:)` to apply a scaling transform to a view by
/// a specific horizontal and vertical amount.
///
///     Image(systemName: "envelope.badge.fill")
///         .resizable()
///         .frame(width: 100, height: 100, alignment: .center)
///         .foregroundColor(Color.red)
///         .scaleEffect(x: 0.5, y: 0.5, anchor: .bottomTrailing)
///         .border(Color.gray)
///
/// ![A screenshot showing a 100x100 pixel red envelope scaled down 50% in
/// both the x and y axes.](SwiftUI-View-scaleEffect-xy.png)
///
/// - Parameters:
///   - x: An amount that represents the horizontal amount to scale the
///     view. The default value is `1.0`.
///   - y: An amount that represents the vertical amount to scale the view.
///     The default value is `1.0`.
///   - anchor: The anchor point that indicates the starting position for
///     the scale operation.
@inlinable public func scaleEffect(x: CGFloat = 1.0, y: CGFloat = 1.0, anchor: UnitPoint = .center) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies a Gaussian blur to this view.
///
/// Use `blur(radius:opaque:)` to apply a gaussian blur effect to the
/// rendering of this view.
///
/// The example below shows two ``Text`` views, the first with no blur
/// effects, the second with `blur(radius:opaque:)` applied with the
/// `radius` set to `2`. The larger the radius, the more diffuse the
/// effect.
///
///     struct Blur: View {
///         var body: some View {
///             VStack {
///                 Text("This is some text.")
///                     .padding()
///                 Text("This is some blurry text.")
///                     .blur(radius: 2.0)
///             }
///         }
///     }
///
/// ![A screenshot showing the effect of applying gaussian blur effect to
/// the rendering of a view.](SwiftUI-View-blurRadius.png)
///
/// - Parameters:
///   - radius: The radial size of the blur. A blur is more diffuse when its
///     radius is large.
///   - opaque: A Boolean value that indicates whether the blur renderer
///     permits transparency in the blur output. Set to `true` to create an
///     opaque blur, or set to `false` to permit transparency.
@inlinable public func blur(radius: CGFloat, opaque: Bool = false) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Brightens this view by the specified amount.
///
/// Use `brightness(_:)` to brighten the intensity of the colors in a view.
/// The example below shows a series of red squares, with their brightness
/// increasing from 0 (fully red) to 100% (white) in 20% increments.
///
///     struct Brightness: View {
///         var body: some View {
///             HStack {
///                 ForEach(0..<6) {
///                     Color.red.frame(width: 60, height: 60, alignment: .center)
///                         .brightness(Double($0) * 0.2)
///                         .overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"),
///                                  alignment: .bottom)
///                         .border(Color.gray)
///                 }
///             }
///         }
///     }
///
/// ![Rendering showing the effects of brightness adjustments in 20%
/// increments from fully-red to white.](SwiftUI-View-brightness.png)
///
/// - Parameter amount: A value between 0 (no effect) and 1 (full white
///   brightening) that represents the intensity of the brightness effect.
///
/// - Returns: A view that brightens this view by the specified amount.
@inlinable public func brightness(_ amount: Double) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an action to perform before this view appears.
///
/// The exact moment that SwiftUI calls this method
/// depends on the specific view type that you apply it to, but
/// the `action` closure completes before the first
/// rendered frame appears.
///
/// - Parameter action: The action to perform. If `action` is `nil`, the
///   call has no effect.
///
/// - Returns: A view that triggers `action` before it appears.
@inlinable public func onAppear(perform action: (() -> Void)? = nil) -> some View
/// Adds an action to perform after this view disappears.
///
/// The exact moment that SwiftUI calls this method
/// depends on the specific view type that you apply it to, but
/// the `action` closure doesn't execute until the view
/// disappears from the interface.
///
/// - Parameter action: The action to perform. If `action` is `nil`, the
///   call has no effect.
///
/// - Returns: A view that triggers `action` after it disappears.
@inlinable public func onDisappear(perform action: (() -> Void)? = nil) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Inverts the colors in this view.
///
/// The `colorInvert()` modifier inverts all of the colors in a view so that
/// each color displays as its complementary color. For example, blue
/// converts to yellow, and white converts to black.
///
/// In the example below, two red squares each have an interior green
/// circle. The inverted square shows the effect of the square's colors:
/// complimentary colors for red and green — teal and purple.
///
///     struct InnerCircleView: View {
///         var body: some View {
///             Circle()
///                 .fill(Color.green)
///                 .frame(width: 40, height: 40, alignment: .center)
///         }
///     }
///
///     struct ColorInvert: View {
///         var body: some View {
///             HStack {
///                 Color.red.frame(width: 100, height: 100, alignment: .center)
///                     .overlay(InnerCircleView(), alignment: .center)
///                     .overlay(Text("Normal")
///                                  .font(.callout),
///                              alignment: .bottom)
///                     .border(Color.gray)
///
///                 Spacer()
///
///                 Color.red.frame(width: 100, height: 100, alignment: .center)
///                     .overlay(InnerCircleView(), alignment: .center)
///                     .colorInvert()
///                     .overlay(Text("Inverted")
///                                  .font(.callout),
///                              alignment: .bottom)
///                     .border(Color.gray)
///             }
///             .padding(50)
///         }
///     }
///
/// ![Two red squares with centered green circles with one showing the
/// effect of color inversion, which yields teal and purple replacing the
/// red and green colors.](SwiftUI-View-colorInvert.png)
///
/// - Returns: A view that inverts its colors.
@inlinable public func colorInvert() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a color multiplication effect to this view.
///
/// The following example shows two versions of the same image side by side;
/// at left is the original, and at right is a duplicate with the
/// `colorMultiply(_:)` modifier applied with ``ShapeStyle/purple``.
///
///     struct InnerCircleView: View {
///         var body: some View {
///             Circle()
///                 .fill(Color.green)
///                 .frame(width: 40, height: 40, alignment: .center)
///         }
///     }
///
///     struct ColorMultiply: View {
///         var body: some View {
///             HStack {
///                 Color.red.frame(width: 100, height: 100, alignment: .center)
///                     .overlay(InnerCircleView(), alignment: .center)
///                     .overlay(Text("Normal")
///                                  .font(.callout),
///                              alignment: .bottom)
///                     .border(Color.gray)
///
///                 Spacer()
///
///                 Color.red.frame(width: 100, height: 100, alignment: .center)
///                     .overlay(InnerCircleView(), alignment: .center)
///                     .colorMultiply(Color.purple)
///                     .overlay(Text("Multiply")
///                                 .font(.callout),
///                              alignment: .bottom)
///                     .border(Color.gray)
///             }
///             .padding(50)
///         }
///     }
///
/// ![A screenshot showing two images showing the effect of multiplying the
/// colors of an image with another color.](SwiftUI-View-colorMultiply.png)
///
/// - Parameter color: The color to bias this view toward.
///
/// - Returns: A view with a color multiplication effect.
@inlinable public func colorMultiply(_ color: Color) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the contrast and separation between similar colors in this view.
///
/// Apply contrast to a view to increase or decrease the separation between
/// similar colors in the view.
///
/// In the example below, the `contrast(_:)` modifier is applied to a set of
/// red squares each containing a contrasting green inner circle. At each
/// step in the loop, the `contrast(_:)` modifier changes the contrast of
/// the circle/square view in 20% increments. This ranges from -20% contrast
/// (yielding inverted colors — turning the red square to pale-green and the
/// green circle to mauve), to neutral-gray at 0%, to 100% contrast
/// (bright-red square / bright-green circle). Applying negative contrast
/// values, as shown in the -20% square, will apply contrast in addition to
/// inverting colors.
///
///     struct CircleView: View {
///         var body: some View {
///             Circle()
///                 .fill(Color.green)
///                 .frame(width: 25, height: 25, alignment: .center)
///         }
///     }
///
///     struct Contrast: View {
///         var body: some View {
///             HStack {
///                 ForEach(-1..<6) {
///                     Color.red.frame(width: 50, height: 50, alignment: .center)
///                         .overlay(CircleView(), alignment: .center)
///                         .contrast(Double($0) * 0.2)
///                         .overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%")
///                                      .font(.callout),
///                                  alignment: .bottom)
///                         .border(Color.gray)
///                 }
///             }
///         }
///     }
///
/// ![Demonstration of the effect of contrast on a view applying contrast
/// values from -20% to 100% contrast.](SwiftUI-View-contrast.png)
///
/// - Parameter amount: The intensity of color contrast to apply. negative
///   values invert colors in addition to applying contrast.
///
/// - Returns: A view that applies color contrast to this view.
@inlinable public func contrast(_ amount: Double) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a grayscale effect to this view.
///
/// A grayscale effect reduces the intensity of colors in this view.
///
/// The example below shows a series of red squares with their grayscale
/// effect increasing from 0 (reddest) to 99% (fully desaturated) in
/// approximate 20% increments:
///
///     struct Saturation: View {
///         var body: some View {
///             HStack {
///                 ForEach(0..<6) {
///                     Color.red.frame(width: 60, height: 60, alignment: .center)
///                         .grayscale(Double($0) * 0.1999)
///                         .overlay(Text("\(Double($0) * 0.1999 * 100, specifier: "%.4f")%"),
///                                  alignment: .bottom)
///                         .border(Color.gray)
///                 }
///             }
///         }
///     }
///
/// ![Rendering showing the effects of grayscale adjustments in
/// approximately 20% increments from fully-red at 0% to fully desaturated
/// at 99%.](SwiftUI-View-grayscale.png)
///
/// - Parameter amount: The intensity of grayscale to apply from 0.0 to less
///   than 1.0. Values closer to 0.0 are more colorful, and values closer to
///   1.0 are less colorful.
///
/// - Returns: A view that adds a grayscale effect to this view.
@inlinable public func grayscale(_ amount: Double) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies a hue rotation effect to this view.
///
/// Use hue rotation effect to shift all of the colors in a view according
/// to the angle you specify.
///
/// The example below shows a series of squares filled with a linear
/// gradient. Each square shows the effect of a 36˚ hueRotation (a total of
/// 180˚ across the 5 squares) on the gradient:
///
///     struct HueRotation: View {
///         var body: some View {
///             HStack {
///                 ForEach(0..<6) {
///                     Rectangle()
///                         .fill(.linearGradient(
///                             colors: [.blue, .red, .green],
///                             startPoint: .top, endPoint: .bottom))
///                         .hueRotation((.degrees(Double($0 * 36))))
///                         .frame(width: 60, height: 60, alignment: .center)
///                 }
///             }
///         }
///     }
///
/// ![Shows the effect of hueRotation on a linear
/// gradient.](SwiftUI-hueRotation.png)
///
/// - Parameter angle: The hue rotation angle to apply to the colors in this
///   view.
///
/// - Returns: A view that applies a hue rotation effect to this view.
@inlinable public func hueRotation(_ angle: Angle) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
extension View {
/// Sets the style for navigation views within this view.
///
/// Use this modifier to change the appearance and behavior of navigation
/// views. For example, by default, navigation views appear with multiple
/// columns in wider environments, like iPad in landscape orientation:
///
/// ![A screenshot of an iPad in landscape orientation mode showing a
/// multicolumn navigation view. The left column lists the colors Purple,
/// Pink, and Orange, with Purple selected. The right column presents a
/// detail view that shows a purple square.](View-navigationViewStyle-1)
///
/// You can apply the ``NavigationViewStyle/stack`` style to force
/// single-column stack navigation in these environments:
///
///     NavigationView {
///         List {
///             NavigationLink("Purple", destination: ColorDetail(color: .purple))
///             NavigationLink("Pink", destination: ColorDetail(color: .pink))
///             NavigationLink("Orange", destination: ColorDetail(color: .orange))
///         }
///         .navigationTitle("Colors")
///
///         Text("Select a Color") // A placeholder to show before selection.
///     }
///     .navigationViewStyle(.stack)
///
/// ![A screenshot of an iPad in landscape orientation mode showing a
/// single column containing the list Purple, Pink, and
/// Orange.](View-navigationViewStyle-2)
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "replace styled NavigationView with NavigationStack or NavigationSplitView instead")
public func navigationViewStyle<S>(_ style: S) -> some View where S : NavigationViewStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the container shape to use for any container relative shape
/// within this view.
///
/// The example below defines a view that shows its content with a rounded
/// rectangle background and the same container shape. Any
/// ``ContainerRelativeShape`` within the `content` matches the rounded
/// rectangle shape from this container inset as appropriate.
///
///     struct PlatterContainer<Content: View> : View {
///         @ViewBuilder var content: Content
///         var body: some View {
///             content
///                 .padding()
///                 .containerShape(shape)
///                 .background(shape.fill(.background))
///         }
///         var shape: RoundedRectangle { RoundedRectangle(cornerRadius: 20) }
///     }
///
@inlinable public func containerShape<T>(_ shape: T) -> some View where T : InsettableShape
}
extension View {
/// Sets the preferred visibility of the non-transient system views
/// overlaying the app.
///
/// Use this modifier if you would like to customise the immersive
/// experience of your app by hiding or showing system overlays that may
/// affect user experience. The following example hides every persistent
/// system overlay.
///
///     struct ImmersiveView: View {
///         var body: some View {
///             Text("Maximum immersion")
///                 .persistentSystemOverlays(.hidden)
///         }
///     }
///
/// Note that this modifier only sets a preference and, ultimately the
/// system will decide if it will honour it or not.
///
/// These non-transient system views include:
/// - The Home indicator
/// - The SharePlay indicator
/// - The Multi-task indicator and Picture-in-picture on iPad
///
/// - Parameter visibility: A value that indicates the visibility of the
/// non-transient system views overlaying the app.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func persistentSystemOverlays(_ visibility: Visibility) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 14.0, *)
@available(watchOS, introduced: 6.0, deprecated: 7.0)
extension View {
/// Adds a context menu to a view.
///
/// Use this modifier to add a context menu to a view in your app's
/// user interface. Compose the menu by returning controls like ``Button``,
/// ``Toggle``, and ``Picker`` from the `menuItems` closure. You can also
/// use ``Menu`` to define submenus or ``Section`` to group items.
///
/// The following example creates a ``Text`` view that has a context menu
/// with two buttons:
///
///     Text("Turtle Rock")
///         .padding()
///         .contextMenu {
///             Button {
///                 // Add this item to a list of favorites.
///             } label: {
///                 Label("Add to Favorites", systemImage: "heart")
///             }
///             Button {
///                 // Open Maps and center it on this item.
///             } label: {
///                 Label("Show in Maps", systemImage: "mappin")
///             }
///         }
///
/// People can activate the menu with an action like Control-clicking, or
/// by using the touch and hold gesture in iOS and iPadOS:
///
/// ![A screenshot of a context menu showing two menu items: Add to
/// Favorites, and Show in Maps.](View-contextMenu-1-iOS)
///
/// The system dismisses the menu if someone makes a selection, or taps
/// or clicks outside the menu.
///
/// If you want to show a preview beside the menu, use
/// ``View/contextMenu(menuItems:preview:)``. To add a context menu to a
/// container that supports selection, like a ``List`` or a ``Table``, and
/// to distinguish between menu activation on a selection and
/// activation in an empty area of the container, use
/// ``View/contextMenu(forSelectionType:menu:primaryAction:)``.
///
/// - Parameter menuItems: A closure that produces the menu's contents. You
///   can deactivate the context menu by returning nothing from the closure.
///
/// - Returns: A view that can display a context menu.
public func contextMenu<MenuItems>(@ViewBuilder menuItems: () -> MenuItems) -> some View where MenuItems : View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(watchOS, unavailable)
extension View {
/// Adds a context menu with a preview to a view.
///
/// When you use this modifer to add a context menu to a view in your
/// app's user interface, the system shows a preview beside the menu.
/// Compose the menu by returning controls like ``Button``, ``Toggle``, and
/// ``Picker`` from the `menuItems` closure. You can also use ``Menu`` to
/// define submenus or ``Section`` to group items.
///
/// Define the preview by returning a view from the `preview` closure. The
/// system sizes the preview to match the size of its content. For example,
/// you can add a two button context menu to a ``Text`` view, and include
/// an ``Image`` as a preview:
///
///     Text("Turtle Rock")
///         .padding()
///         .contextMenu {
///             Button {
///                 // Add this item to a list of favorites.
///             } label: {
///                 Label("Add to Favorites", systemImage: "heart")
///             }
///             Button {
///                 // Open Maps and center it on this item.
///             } label: {
///                 Label("Show in Maps", systemImage: "mappin")
///             }
///         } preview: {
///             Image("turtlerock") // Loads the image from an asset catalog.
///         }
///
/// When someone activates the context menu with an action like touch and
/// hold in iOS or iPadOS, the system displays the image and the menu:
///
/// ![A screenshot of a context menu with two buttons that are labeled
/// Add to Favorites, and Show in Maps. An image of a Joshua Tree appears
/// above the menu.](View-contextMenu-2-iOS)
///
/// > Note: This view modifier produces a context menu on macOS, but that
/// platform doesn't display the preview.
///
/// If you don't need a preview, use ``View/contextMenu(menuItems:)``
/// instead. If you want to add a context menu to a container that supports
/// selection, like a ``List`` or a ``Table``, and you want to distinguish
/// between menu activation on a selection and activation in an empty area
/// of the container, use
/// ``View/contextMenu(forSelectionType:menu:primaryAction:)``.
///
/// - Parameters:
///   - menuItems: A closure that produces the menu's contents. You can
///     deactivate the context menu by returning nothing from the closure.
///   - preview: A view that the system displays along with the menu.
///
/// - Returns: A view that can display a context menu with a preview.
public func contextMenu<M, P>(@ViewBuilder menuItems: () -> M, @ViewBuilder preview: () -> P) -> some View where M : View, P : View
}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
@available(tvOS, unavailable)
@available(watchOS, introduced: 6.0, deprecated: 7.0)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")
extension View {
/// Adds a context menu to the view.
///
/// Use this method to attach a specified context menu to a view.
/// You can make the context menu unavailable by conditionally passing `nil`
/// as the value for the `contextMenu`.
///
/// The example below creates a ``ContextMenu`` that contains two items and
/// passes them into the modifier. The Boolean value `shouldShowMenu`,
/// which defaults to `true`, controls the context menu availability:
///
///     private let menuItems = ContextMenu {
///         Button {
///             // Add this item to a list of favorites.
///         } label: {
///             Label("Add to Favorites", systemImage: "heart")
///         }
///         Button {
///             // Open Maps and center it on this item.
///         } label: {
///             Label("Show in Maps", systemImage: "mappin")
///         }
///     }
///
///     private struct ContextMenuMenuItems: View {
///         @State private var shouldShowMenu = true
///
///         var body: some View {
///             Text("Turtle Rock")
///                 .contextMenu(shouldShowMenu ? menuItems : nil)
///         }
///     }
///
/// ![A screenshot of a context menu showing two menu items: Add to
/// Favorites, and Show in Maps.](View-contextMenu-1-iOS)
///
/// - Parameter contextMenu: A context menu container for views that you
///   present as menu items in a context menu.
///
/// - Returns: A view that can show a context menu.
public func contextMenu<MenuItems>(_ contextMenu: ContextMenu<MenuItems>?) -> some View where MenuItems : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a luminance to alpha effect to this view.
///
/// Use this modifier to create a semitransparent mask, with the opacity of
/// each part of the modified view controlled by the luminance of the
/// corresponding part of the original view. Regions of lower luminance
/// become more transparent, while higher luminance yields greater
/// opacity.
///
/// In particular, the modifier maps the red, green, and blue components of
/// each input pixel's color to a grayscale value, and that value becomes
/// the alpha component of a black pixel in the output. This modifier
/// produces an effect that's equivalent to using the `feColorMatrix`
/// filter primitive with the `luminanceToAlpha` type attribute, as defined
/// by the [Scalable Vector Graphics (SVG) 2](https://www.w3.org/TR/SVG2/)
/// specification.
///
/// The example below defines a `Palette` view as a series of rectangles,
/// each composed as a ``Color`` with a particular white value,
/// and then displays two versions of the palette over a blue background:
///
///     struct Palette: View {
///         var body: some View {
///             HStack(spacing: 0) {
///                 ForEach(0..<10) { index in
///                     Color(white: Double(index) / Double(9))
///                         .frame(width: 20, height: 40)
///                 }
///             }
///         }
///     }
///
///     struct LuminanceToAlphaExample: View {
///         var body: some View {
///             VStack(spacing: 20) {
///                 Palette()
///
///                 Palette()
///                     .luminanceToAlpha()
///             }
///             .padding()
///             .background(.blue)
///         }
///     }
///
/// The unmodified version of the palette contains rectangles that range
/// from solid black to solid white, thus with increasing luminance. The
/// second version of the palette, which has the `luminanceToAlpha()`
/// modifier applied, allows the background to show through in an amount
/// that corresponds inversely to the luminance of the input.
///
/// ![A screenshot of a blue background with two wide rectangles on it,
/// arranged vertically, with one above the other. Each is composed of a
/// series of smaller rectangles arranged from left to right. The component
/// rectangles of the first large rectangle range from black to white as
/// you scan from left to right, with each successive component rectangle
/// slightly whiter than the previous. The component rectangles of the
/// second large rectangle range from fully transparent to fully opaque,
/// scanning in the same direction.](View-luminanceToAlpha-1-iOS)
///
/// - Returns: A view with the luminance to alpha effect applied.
@inlinable public func luminanceToAlpha() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adjusts the color saturation of this view.
///
/// Use color saturation to increase or decrease the intensity of colors in
/// a view.
///
/// The example below shows a series of red squares with their saturation
/// increasing from 0 (gray) to 100% (fully-red) in 20% increments:
///
///     struct Saturation: View {
///         var body: some View {
///             HStack {
///                 ForEach(0..<6) {
///                     Color.red.frame(width: 60, height: 60, alignment: .center)
///                         .saturation(Double($0) * 0.2)
///                         .overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"),
///                                  alignment: .bottom)
///                         .border(Color.gray)
///                 }
///             }
///         }
///     }
///
/// ![Rendering showing the effects of saturation adjustments in 20%
/// increments from gray at 0% to fully-red at
/// 100%.](SwiftUI-View-saturation.png)
///
/// - SeeAlso: `contrast(_:)`
/// - Parameter amount: The amount of saturation to apply to this view.
///
/// - Returns: A view that adjusts the saturation of this view.
@inlinable public func saturation(_ amount: Double) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the transparency of this view.
///
/// Apply opacity to reveal views that are behind another view or to
/// de-emphasize a view.
///
/// When applying the `opacity(_:)` modifier to a view that has already had
/// its opacity transformed, the modifier multiplies the effect of the
/// underlying opacity transformation.
///
/// The example below shows yellow and red rectangles configured to overlap.
/// The top yellow rectangle has its opacity set to 50%, allowing the
/// occluded portion of the bottom rectangle to be visible:
///
///     struct Opacity: View {
///         var body: some View {
///             VStack {
///                 Color.yellow.frame(width: 100, height: 100, alignment: .center)
///                     .zIndex(1)
///                     .opacity(0.5)
///
///                 Color.red.frame(width: 100, height: 100, alignment: .center)
///                     .padding(-40)
///             }
///         }
///     }
///
/// ![Two overlaid rectangles, where the topmost has its opacity set to 50%,
/// which allows the occluded portion of the bottom rectangle to be
/// visible.](SwiftUI-View-opacity.png)
///
/// - Parameter opacity: A value between 0 (fully transparent) and 1 (fully
///   opaque).
///
/// - Returns: A view that sets the transparency of this view.
@inlinable public func opacity(_ opacity: Double) -> some View
}
extension View {
/// Specifies the preferred shape style of the background of a bar managed
/// by SwiftUI.
///
/// The preferred style flows up to the nearest container that
/// renders a bar. This could be a ``NavigationView`` or ``TabView``
/// in iOS, or the root view of a ``WindowGroup`` in macOS. This example
/// shows a view that renders the navigation bar with a blue background
/// and dark color scheme.
///
///     NavigationView {
///         ContentView()
///             .toolbarBackground(.white)
///             .toolbarColorScheme(.dark)
///     }
///
/// You can provide multiple ``ToolbarPlacement`` instances to customize
/// multiple bars at once.
///
///     TabView {
///         NavigationView {
///             ContentView()
///                 .toolbarBackground(
///                     .blue, for: .navigationBar, .tabBar)
///                 .toolbarColorScheme(
///                     .dark, for: .navigationBar, .tabBar)
///         }
///     }
///
/// When used within a ``TabView``, the specified style will be
/// preferred while the tab is currently active. You can use a ``Group``
/// to specify the same preferred background for every tab.
///
///     TabView {
///         Group {
///             MainView()
///             SettingsView()
///         }
///         .toolbarBackground(.blue, for: .tabBar)
///     }
///
/// Depending on the specified bars, the requested style may not be able to
/// be fullfilled.
///
/// - Parameters:
///   - style: The style to display as the background of the bar.
///   - bars: The bars to use the style for or
///     ``ToolbarPlacement/automatic`` if empty.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbarBackground<S>(_ style: S, for bars: ToolbarPlacement...) -> some View where S : ShapeStyle
/// Specifies the preferred visibility of backgrounds on a bar managed by
/// SwiftUI.
///
/// The preferred visibility flows up to the nearest container that
/// renders a bar. This could be a ``NavigationView`` or ``TabView``
/// in iOS, or the root view of a ``WindowGroup`` in macOS.
///
/// In iOS, a value of ``ToolbarPlacement/automatic`` makes the visibility
/// of a tab bar or navigation bar background depend on where a ``List`` or
/// ``ScrollView`` settles. For example, when aligned to the bottom edge of
/// of a scroll view's content, the background of a tab bar becomes
/// transparent.
///
/// Specify a value of ``Visibility/visible`` to ensure that the
/// background of a bar remains visible regardless of where any scroll
/// view or list stops scrolling.
///
/// This example shows a view that prefers to always have the tab bar
/// visible when the middle tab is selected:
///
///     TabView {
///         FirstTab()
///         MiddleTab()
///             .toolbarBackground(.visible, for: .tabBar)
///         LastTab()
///     }
///
/// You can provide multiple placements to customize multiple bars
/// at once, as in the following example:
///
///     TabView {
///         NavigationView {
///             ContentView()
///                 .toolbarBackground(
///                     .visible, for: .navigationBar, .tabBar)
///         }
///     }
///
/// - Parameters:
///   - visibility: The preferred visibility of the background of the bar.
///   - bars: The bars to update the color scheme of or
///     ``ToolbarPlacement/automatic`` if empty.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbarBackground(_ visibility: Visibility, for bars: ToolbarPlacement...) -> some View
/// Specifies the preferred color scheme of a bar managed by SwiftUI.
///
/// The preferred color scheme flows up to the nearest container
/// that renders a bar. This could be a ``NavigationView`` or ``TabView``
/// in iOS, or the root view of a ``WindowGroup`` in macOS. Pass in a value
/// of nil to match the current system's color scheme.
///
/// This examples shows a view that renders the navigation bar with a blue
/// background and dark color scheme:
///
///     TabView {
///         NavigationView {
///             ContentView()
///                 .toolbarBackground(.blue)
///                 .toolbarColorScheme(.dark)
///         }
///         // other tabs...
///     }
///
/// You can provide multiple ``ToolbarPlacement`` instances to customize
/// multiple bars at once.
///
///     TabView {
///         NavigationView {
///             ContentView()
///                 .toolbarBackground(
///                     .blue, for: .navigationBar, .tabBar)
///                 .toolbarColorScheme(
///                     .dark, for: .navigationBar, .tabBar)
///         }
///     }
///
/// Note that the provided color scheme is only respected while a
/// background is visible in the requested bar. As the background becomes
/// visible, the bar transitions from the color scheme of the app to the
/// requested color scheme. You can ensure that the color scheme is always
/// respected by specifying that the background of the bar always be
/// visible.
///
///     NavigationView {
///         ContentView()
///             .toolbarBackground(.visible)
///             .toolbarColorScheme(.dark)
///     }
///
/// Depending on the specified bars, the requested color scheme may not be
/// able to be fullfilled.
///
/// - Parameters:
///   - colorScheme: The preferred color scheme of the background
///     of the bar.
///   - bars: The bars to update the color scheme of or
///     ``ToolbarPlacement/automatic`` if empty.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbarColorScheme(_ colorScheme: ColorScheme?, for bars: ToolbarPlacement...) -> some View
/// Specifies the visibility of a bar managed by SwiftUI.
///
/// The preferred visibility flows up to the nearest container
/// that renders a bar. This could be a ``NavigationView`` or ``TabView``
/// in iOS, or the root view of a ``WindowGroup`` in macOS.
///
/// This examples shows a view that hides the navigation bar.
///
///     NavigationView {
///         ContentView()
///             .toolbar(.hidden)
///     }
///
/// You can provide multiple ``ToolbarPlacement`` instances to hide
/// multiple bars at once.
///
///     TabView {
///         NavigationView {
///             ContentView()
///                 .toolbar(
///                     .hidden, for: .navigationBar, .tabBar)
///         }
///     }
///
/// > Note: In macOS, if you provide ``ToolbarCommands`` to the scene
///   of your app, this modifier disables the toolbar visibility command
///   while the value of the modifier is not ``ToolbarPlacement/automatic``.
///
/// Depending on the specified bars, the requested visibility may not be
/// able to be fullfilled.
///
/// - Parameters:
///   - visibility: The preferred visibility of the bar.
///   - bars: The bars to update the visibility of or
///     ``ToolbarPlacement/automatic`` if empty.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbar(_ visibility: Visibility, for bars: ToolbarPlacement...) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Provides a closure that vends the drag representation to be used for a
/// particular data element.
@inlinable public func itemProvider(_ action: (() -> NSItemProvider?)?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies the given animation to this view when the specified value
/// changes.
///
/// - Parameters:
///   - animation: The animation to apply. If `animation` is `nil`, the view
///     doesn't animate.
///   - value: A value to monitor for changes.
///
/// - Returns: A view that applies `animation` to this view whenever `value`
///   changes.
@inlinable public func animation<V>(_ animation: Animation?, value: V) -> some View where V : Equatable
}
extension View where Self : Equatable {
/// Applies the given animation to this view when this view changes.
///
/// - Parameters:
///   - animation: The animation to apply. If `animation` is `nil`, the view
///     doesn't animate.
///
/// - Returns: A view that applies `animation` to this view whenever it
///   changes.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@inlinable public func animation(_ animation: Animation?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the blend mode for compositing this view with overlapping views.
///
/// Use `blendMode(_:)` to combine overlapping views and use a different
/// visual effect to produce the result. The ``BlendMode`` enumeration
/// defines many possible effects.
///
/// In the example below, the two overlapping rectangles have a
/// ``BlendMode/colorBurn`` effect applied, which effectively removes the
/// non-overlapping portion of the second image:
///
///     HStack {
///         Color.yellow.frame(width: 50, height: 50, alignment: .center)
///
///         Color.red.frame(width: 50, height: 50, alignment: .center)
///             .rotationEffect(.degrees(45))
///             .padding(-20)
///             .blendMode(.colorBurn)
///     }
///
/// ![Two overlapping rectangles showing the effect of the blend mode view
/// modifier applying the colorBurn effect.](SwiftUI-blendMode.png)
///
/// - Parameter blendMode: The ``BlendMode`` for compositing this view.
///
/// - Returns: A view that applies `blendMode` to this view.
@inlinable public func blendMode(_ blendMode: BlendMode) -> some View
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Specifies the selection effect to apply to a palette item.
///
/// ``PaletteSelectionEffect/automatic`` applies the system's default
/// appearance when selected. When using un-tinted SF Symbols or template
/// images, the current tint color is applied to the selected items' image.
/// If the provided SF Symbols have custom tints, a stroke is drawn around selected items.
///
/// If you wish to provide a specific image (or SF Symbol) to indicate
/// selection, use ``PaletteSelectionEffect/custom`` to forgo the system's
/// default selection appearance allowing the provided image to solely
/// indicate selection instead.
///
/// The following example creates a palette picker that disables the
/// system selection behavior:
///
///     Menu {
///         Picker("Palettes", selection: $selection) {
///             ForEach(palettes) { palette in
///                 Label(palette.title, image: selection == palette ?
///                       "selected-palette" : "palette")
///                 .tint(palette.tint)
///                 .tag(palette)
///             }
///         }
///         .pickerStyle(.palette)
///         .paletteSelectionEffect(.custom)
///     } label: {
///         ...
///     }
///
/// If a specific SF Symbol variant is preferable instead, use
/// ``PaletteSelectionEffect/symbolVariant(_:)``.
///
///     Menu {
///         ControlGroup {
///             ForEach(ColorTags.allCases) { colorTag in
///                 Toggle(isOn: $selectedColorTags[colorTag]) {
///                     Label(colorTag.name, systemImage: "circle")
///                 }
///                 .tint(colorTag.color)
///             }
///         }
///         .controlGroupStyle(.palette)
///         .paletteSelectionEffect(.symbolVariant(.fill))
///     }
///
/// - Parameter effect: The type of effect to apply when a palette item is selected.
public func paletteSelectionEffect(_ effect: PaletteSelectionEffect) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for buttons within this view to a button style with a
/// custom appearance and standard interaction behavior.
///
/// Use this modifier to set a specific style for all button instances
/// within a view:
///
///     HStack {
///         Button("Sign In", action: signIn)
///         Button("Register", action: register)
///     }
///     .buttonStyle(.bordered)
///
/// You can also use this modifier to set the style for controls with a button
/// style through composition:
///
///     VStack {
///         Menu("Terms and Conditions") {
///             Button("Open in Preview", action: openInPreview)
///             Button("Save as PDF", action: saveAsPDF)
///         }
///         Toggle("Remember Password", isOn: $isToggleOn)
///         Toggle("Flag", isOn: $flagged)
///         Button("Sign In", action: signIn)
///     }
///     .menuStyle(.button)
///     .toggleStyle(.button)
///     .buttonStyle(.bordered)
///
/// In this example, `.menuStyle(.button)` says that the Terms and
/// Conditions menu renders as a button, while
/// `.toggleStyle(.button)` says that the two toggles also render as
/// buttons. Finally, `.buttonStyle(.bordered)` says that the menu,
/// both toggles, and the Sign In button all render with the
/// bordered button style.```
public func buttonStyle<S>(_ style: S) -> some View where S : ButtonStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for text fields within this view.
public func textFieldStyle<S>(_ style: S) -> some View where S : TextFieldStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Composites this view's contents into an offscreen image before final
/// display.
///
/// The `drawingGroup(opaque:colorMode:)` modifier flattens a subtree of
/// views into a single view before rendering it.
///
/// In the example below, the contents of the view are composited to a
/// single bitmap; the bitmap is then displayed in place of the view:
///
///     VStack {
///         ZStack {
///             Text("DrawingGroup")
///                 .foregroundColor(.black)
///                 .padding(20)
///                 .background(Color.red)
///             Text("DrawingGroup")
///                 .blur(radius: 2)
///         }
///         .font(.largeTitle)
///         .compositingGroup()
///         .opacity(1.0)
///     }
///      .background(Color.white)
///      .drawingGroup()
///
/// > Note: Views backed by native platform views may not render into the
///   image. Instead, they log a warning and display a placeholder image to
///   highlight the error.
///
/// ![A screenshot showing the effects on several stacks configured as a
/// drawing group.](SwiftUI-View-drawingGroup.png)
///
/// - Parameters:
///   - opaque: A Boolean value that indicates whether the image is opaque.
///     The default is `false`; if set to `true`, the alpha channel of the
///     image must be `1`.
///   - colorMode: One of the working color space and storage formats
///     defined in ``ColorRenderingMode``. The default is
///     ``ColorRenderingMode/nonLinear``.
///
/// - Returns: A view that composites this view's contents into an offscreen
///   image before display.
public func drawingGroup(opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents an alert when a given condition is true, using a localized
/// string key for the title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     "Login failed.",
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
public func alert<A>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A) -> some View where A : View
/// Presents an alert when a given condition is true, using a string
/// variable as a title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///         let alertTitle: String = "Login failed."
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     alertTitle,
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// - Parameters:
///   - title: A text string used as the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
public func alert<S, A>(_ title: S, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A) -> some View where S : StringProtocol, A : View
/// Presents an alert when a given condition is true, using a text view for
/// the title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///         let alertTitle: String = "Login failed."
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     Text(alertTitle),
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// - Parameters:
///   - title: The title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
public func alert<A>(_ title: Text, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A) -> some View where A : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents an alert with a message when a given condition is true, using
/// a localized string key for a title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     "Login failed.",
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 } message: {
///                     Text("Please check your credentials and try again.")
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
///   - message: A ``ViewBuilder`` returning the message for the alert.
public func alert<A, M>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where A : View, M : View
/// Presents an alert with a message when a given condition is true using
/// a string variable as a title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///         let alertTitle: String = "Login failed."
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     alertTitle,
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 } message: {
///                     Text("Please check your credentials and try again.")
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// - Parameters:
///   - title: A text string used as the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
///   - message: A ``ViewBuilder`` returning the message for the alert.
public func alert<S, A, M>(_ title: S, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where S : StringProtocol, A : View, M : View
/// Presents an alert with a message when a given condition is true using
/// a text view as a title.
///
/// In the example below, a login form conditionally presents an alert by
/// setting the `didFail` state variable. When the form sets the value to
/// to `true`, the system displays an alert with an "OK" action.
///
///     struct Login: View {
///         @State private var didFail = false
///         let alertTitle: String = "Login failed."
///
///         var body: some View {
///             LoginForm(didFail: $didFail)
///                 .alert(
///                     Text(alertTitle),
///                     isPresented: $didFail
///                 ) {
///                     Button("OK") {
///                         // Handle the acknowledgement.
///                     }
///                 } message: {
///                    Text("Please check your credentials and try again.")
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// - Parameters:
///   - title: The title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
///   - message: A ``ViewBuilder`` returning the message for the alert.
public func alert<A, M>(_ title: Text, isPresented: Binding<Bool>, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where A : View, M : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents an alert using the given data to produce the alert's content
/// and a localized string key for a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///
///         var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 "Save failed.",
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             }
///         }
///     }
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
public func alert<A, T>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where A : View
/// Presents an alert using the given data to produce the alert's content
/// and a string variable as a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///         let alertTitle: String = "Save failed."
///
///         var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 alertTitle,
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// - Parameters:
///   - title: A text string used as the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
public func alert<S, A, T>(_ title: S, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where S : StringProtocol, A : View
/// Presents an alert using the given data to produce the alert's content
/// and a text view as a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///         let alertTitle: String = "Save failed."
///
///             var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 Text(alertTitle),
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// - Parameters:
///   - title: the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
public func alert<A, T>(_ title: Text, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where A : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents an alert with a message using the given data to produce the
/// alert's content and a localized string key for a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///
///         var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 "Save failed.",
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             } message: { details in
///                 Text(details.error)
///             }
///         }
///     }
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
///   - message: A ``ViewBuilder`` returning the message for the alert given
///     the currently available data.
public func alert<A, M, T>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where A : View, M : View
/// Presents an alert with a message using the given data to produce the
/// alert's content and a string variable as a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///         let alertTitle: String = "Save failed."
///
///         var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 alertTitle,
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             } message: { details in
///                 Text(details.error)
///             }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// - Parameters:
///   - title: A text string used as the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
///   - message: A ``ViewBuilder`` returning the message for the alert given
///     the currently available data.
public func alert<S, A, M, T>(_ title: S, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where S : StringProtocol, A : View, M : View
/// Presents an alert with a message using the given data to produce the
/// alert's content and a text view for a title.
///
/// For the alert to appear, both `isPresented` must be `true` and
/// `data` must not be `nil`. The data should not change after the
/// presentation occurs. Any changes that you make after the presentation
/// occurs are ignored.
///
/// Use this method when you need to populate the fields of an alert with
/// content from a data source. The example below shows a custom data
/// source, `SaveDetails`, that provides data to populate the alert:
///
///     struct SaveDetails: Identifiable {
///         let name: String
///         let error: String
///         let id = UUID()
///     }
///
///     struct SaveButton: View {
///         @State private var didError = false
///         @State private var details: SaveDetails?
///         let alertTitle: String = "Save failed."
///
///         var body: some View {
///             Button("Save") {
///                 details = model.save(didError: $didError)
///             }
///             .alert(
///                 Text(alertTitle),
///                 isPresented: $didError,
///                 presenting: details
///             ) { details in
///                 Button(role: .destructive) {
///                     // Handle the deletion.
///                 } label: {
///                     Text("Delete \(details.name)")
///                 }
///                 Button("Retry") {
///                     // Handle the retry action.
///                 }
///             } message: { details in
///                 Text(details.error)
///             }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// Only unstyled text is supported for the message.
///
/// - Parameters:
///   - title: the title of the alert.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - data: An optional source of truth for the alert. The system passes
///     the contents to the modifier's closures. You use this data to
///     populate the fields of an alert that you create that the system
///     displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions given the
///     currently available data.
///   - message: A ``ViewBuilder`` returning the message for the alert given
///     the currently available data.
public func alert<A, M, T>(_ title: Text, isPresented: Binding<Bool>, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where A : View, M : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents an alert when an error is present.
///
/// In the example below, a form conditionally presents an alert depending
/// upon the value of an error. When the error value isn't `nil`, the system
/// presents an alert with an "OK" action.
///
/// The title of the alert is inferred from the error's `errorDescription`.
///
///     struct TicketPurchase: View {
///         @State private var error: TicketPurchaseError? = nil
///         @State private var showAlert = false
///
///         var body: some View {
///             TicketForm(showAlert: $showAlert, error: $error)
///                 .alert(isPresented: $showAlert, error: error) {
///                     Button("OK") {
///                         // Handle acknowledgement.
///                     }
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - error: An optional localized Error that is used to generate the
///     alert's title.  The system passes the contents to the modifier's
///     closures. You use this data to populate the fields of an alert that
///     you create that the system displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
public func alert<E, A>(isPresented: Binding<Bool>, error: E?, @ViewBuilder actions: () -> A) -> some View where E : LocalizedError, A : View
/// Presents an alert with a message when an error is present.
///
/// In the example below, a form conditionally presents an alert depending
/// upon the value of an error. When the error value isn't `nil`, the system
/// presents an alert with an "OK" action.
///
/// The title of the alert is inferred from the error's `errorDescription`.
///
///     struct TicketPurchase: View {
///         @State private var error: TicketPurchaseError? = nil
///         @State private var showAlert = false
///
///         var body: some View {
///             TicketForm(showAlert: $showAlert, error: $error)
///                 .alert(isPresented: $showAlert, error: error) { _ in
///                     Button("OK") {
///                         // Handle acknowledgement.
///                     }
///                 } message: { error in
///                     Text(error.recoverySuggestion ?? "Try again later.")
///                 }
///         }
///     }
///
/// All actions in an alert dismiss the alert after the action runs.
/// The default button is shown with greater prominence.  You can
/// influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// If no actions are present, the system includes a standard "OK"
/// action. No default cancel action is provided. If you want to show a
/// cancel action, use a button with a role of ``ButtonRole/cancel``.
///
/// On iOS, tvOS, and watchOS, alerts only support controls with labels that
/// are ``Text``. Passing any other type of view results in the content
/// being omitted.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the alert. When the user presses or taps one of the alert's
///     actions, the system sets this value to `false` and dismisses.
///   - error: An optional localized Error that is used to generate the
///     alert's title.  The system passes the contents to the modifier's
///     closures. You use this data to populate the fields of an alert that
///     you create that the system displays to the user.
///   - actions: A ``ViewBuilder`` returning the alert's actions.
///   - message: A view builder returning the message for the alert given
///     the current error.
public func alert<E, A, M>(isPresented: Binding<Bool>, error: E?, @ViewBuilder actions: (E) -> A, @ViewBuilder message: (E) -> M) -> some View where E : LocalizedError, A : View, M : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Wraps this view in a compositing group.
///
/// A compositing group makes compositing effects in this view's ancestor
/// views, such as opacity and the blend mode, take effect before this view
/// is rendered.
///
/// Use `compositingGroup()` to apply effects to a parent view before
/// applying effects to this view.
///
/// In the example below the `compositingGroup()` modifier separates the
/// application of effects into stages. It applies the ``View/opacity(_:)``
/// effect to the VStack before the `blur(radius:)` effect is applied to the
/// views inside the enclosed ``ZStack``. This limits the scope of the
/// opacity change to the outermost view.
///
///     VStack {
///         ZStack {
///             Text("CompositingGroup")
///                 .foregroundColor(.black)
///                 .padding(20)
///                 .background(Color.red)
///             Text("CompositingGroup")
///                 .blur(radius: 2)
///         }
///         .font(.largeTitle)
///         .compositingGroup()
///         .opacity(0.9)
///     }
///
/// ![A view showing the effect of the compositingGroup modifier in applying
/// compositing effects to parent views before child views are
/// rendered.](SwiftUI-View-compositingGroup.png)
///
/// - Returns: A view that wraps this view in a compositing group.
@inlinable public func compositingGroup() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a shadow to this view.
///
/// Use this modifier to add a shadow of a specified color behind a view.
/// You can offset the shadow from its view independently in the horizontal
/// and vertical dimensions using the `x` and `y` parameters. You can also
/// blur the edges of the shadow using the `radius` parameter. Use a
/// radius of zero to create a sharp shadow. Larger radius values produce
/// softer shadows.
///
/// The example below creates a grid of boxes with varying offsets and blur.
/// Each box displays its radius and offset values for reference.
///
///     struct Shadow: View {
///         let steps = [0, 5, 10]
///
///         var body: some View {
///             VStack(spacing: 50) {
///                 ForEach(steps, id: \.self) { offset in
///                     HStack(spacing: 50) {
///                         ForEach(steps, id: \.self) { radius in
///                             Color.blue
///                                 .shadow(
///                                     color: .primary,
///                                     radius: CGFloat(radius),
///                                     x: CGFloat(offset), y: CGFloat(offset))
///                                 .overlay {
///                                     VStack {
///                                         Text("\(radius)")
///                                         Text("(\(offset), \(offset))")
///                                     }
///                                 }
///                         }
///                     }
///                 }
///             }
///         }
///     }
///
/// ![A three by three grid of blue boxes with shadows.
/// All the boxes display an integer that indicates the shadow's radius and
/// an ordered pair that indicates the shadow's offset. The boxes in the
/// first row show zero offset and have shadows directly below the box;
/// the boxes in the second row show an offset of five in both directions
/// and have shadows with a small offset toward the right and down; the
/// boxes in the third row show an offset of ten in both directions and have
/// shadows with a large offset toward the right and down. The boxes in
/// the first column show a radius of zero have shadows with sharp edges;
/// the boxes in the second column show a radius of five and have shadows
/// with slightly blurry edges; the boxes in the third column show a radius
/// of ten and have very blurry edges. Because the shadow of the box in the
/// upper left is both completely sharp and directly below the box, it isn't
/// visible.](View-shadow-1-iOS)
///
/// The example above uses ``Color/primary`` as the color to make the
/// shadow easy to see for the purpose of illustration. In practice,
/// you might prefer something more subtle, like ``Color/gray-8j2b``.
/// If you don't specify a color, the method uses a semi-transparent
/// black.
///
/// - Parameters:
///   - color: The shadow's color.
///   - radius: A measure of how much to blur the shadow. Larger values
///     result in more blur.
///   - x: An amount to offset the shadow horizontally from the view.
///   - y: An amount to offset the shadow vertically from the view.
///
/// - Returns: A view that adds a shadow to this view.
@inlinable public func shadow(color: Color = Color(.sRGBLinear, white: 0, opacity: 0.33), radius: CGFloat, x: CGFloat = 0, y: CGFloat = 0) -> some View
}
extension View {
/// Configures the search suggestions for this view.
///
/// You can suggest search terms during a search operation by providing a
/// collection of view to this modifier. The interface presents the
/// suggestion views as a list of choices when someone activates the
/// search interface. Associate a string with each suggestion
/// view by adding the ``View/searchCompletion(_:)-2uaf3`` modifier to
/// the view. For example, you can suggest fruit types by displaying their
/// emoji, and provide the corresponding search string as a search
/// completion in each case:
///
///     ProductList()
///         .searchable(text: $text)
///         .searchSuggestions {
///             Text("🍎").searchCompletion("apple")
///             Text("🍐").searchCompletion("pear")
///             Text("🍌").searchCompletion("banana")
///         }
///
/// When someone chooses a suggestion, SwiftUI replaces the text in the
/// search field with the search completion string. If you omit the search
/// completion modifier for a particular suggestion view, SwiftUI displays
/// the suggestion, but the suggestion view doesn't react to taps or clicks.
///
/// > Important: In tvOS, searchable modifiers only support suggestion views
/// of type ``Text``, like in the above example. Other platforms can use any
/// view for the suggestions, including custom views.
///
/// You can update the suggestions that you provide as conditions change.
///
/// For example, you can specify an array of suggestions that you store
/// in a model:
///
///     ProductList()
///         .searchable(text: $text)
///         .searchSuggestions {
///             ForEach(model.suggestedSearches) { suggestion in
///                 Label(suggestion.title,  image: suggestion.image)
///                     .searchCompletion(suggestion.text)
///             }
///         }
///
/// If the model's `suggestedSearches` begins as an empty array, the
/// interface doesn't display any suggestions to start. You can then provide
/// logic that updates the array based on some condition. For example, you
/// might update the completions based on the current search text. Note that
/// certain events or actions, like when someone moves a macOS window, might
/// dismiss the suggestion view.
///
/// For more information about using search modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - suggestions: A view builder that produces content that
///     populates a list of suggestions.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func searchSuggestions<S>(@ViewBuilder _ suggestions: () -> S) -> some View where S : View
}
extension View {
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: Where the search field should attempt to be
///     placed based on the containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - suggestions: A view builder that produces content that
///     populates a list of suggestions.
@available(iOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(macOS, introduced: 12.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(tvOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(watchOS, introduced: 8.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
public func searchable<S>(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder suggestions: () -> S) -> some View where S : View
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: Where the search field should attempt to be
///     placed based on the containing view hierarchy.
///   - prompt: A key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - suggestions: A view builder that produces content that
///     populates a list of suggestions.
@available(iOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(macOS, introduced: 12.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(tvOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(watchOS, introduced: 8.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
public func searchable<S>(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder suggestions: () -> S) -> some View where S : View
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - placement: Where the search field should attempt to be
///     placed based on the containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - suggestions: A view builder that produces content that
///     populates a list of suggestions.
@available(iOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(macOS, introduced: 12.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(tvOS, introduced: 15.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
@available(watchOS, introduced: 8.0, deprecated: 100000.0, message: "Use the searchable modifier with the searchSuggestions modifier")
public func searchable<V, S>(text: Binding<String>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder suggestions: () -> V) -> some View where V : View, S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
extension View {
/// Sets the tab bar item associated with this view.
///
/// Use `tabItem(_:)` to configure a view as a tab bar item in a
/// ``TabView``. The example below adds two views as tabs in a ``TabView``:
///
///     struct View1: View {
///         var body: some View {
///             Text("View 1")
///         }
///     }
///
///     struct View2: View {
///         var body: some View {
///             Text("View 2")
///         }
///     }
///
///     struct TabItem: View {
///         var body: some View {
///             TabView {
///                 View1()
///                     .tabItem {
///                         Label("Menu", systemImage: "list.dash")
///                     }
///
///                 View2()
///                     .tabItem {
///                         Label("Order", systemImage: "square.and.pencil")
///                     }
///             }
///         }
///     }
///
/// ![A screenshot of a two views configured as tab items in a tab
/// view.](SwiftUI-View-tabItem.png)
///
/// - Parameter label: The tab bar item to associate with this view.
public func tabItem<V>(@ViewBuilder _ label: () -> V) -> some View where V : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets a value for the specified preference key, the value is a
/// function of a geometry value tied to the current coordinate
/// space, allowing readers of the value to convert the geometry to
/// their local coordinates.
///
/// - Parameters:
///   - key: the preference key type.
///   - value: the geometry value in the current coordinate space.
///   - transform: the function to produce the preference value.
///
/// - Returns: a new version of the view that writes the preference.
@inlinable public func anchorPreference<A, K>(key _: K.Type = K.self, value: Anchor<A>.Source, transform: @escaping (Anchor<A>) -> K.Value) -> some View where K : PreferenceKey
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a condition for whether the view's view hierarchy is movable.
@inlinable public func moveDisabled(_ isDisabled: Bool) -> some View
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension View {
/// Specifies the visibility of the background for scrollable views within
/// this view.
///
/// The following example hides the standard system background of the List.
///
///     List {
///         Text("One")
///         Text("Two")
///         Text("Three")
///     }
///     .scrollContentBackground(.hidden)
///
/// - Parameters:
///    - visibility: the visibility to use for the background.
public func scrollContentBackground(_ visibility: Visibility) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Rotates this view's rendered output in three dimensions around the given
/// axis of rotation.
///
/// Use `rotation3DEffect(_:axis:anchor:anchorZ:perspective:)` to rotate the
/// view in three dimensions around the given axis of rotation, and
/// optionally, position the view at a custom display order and perspective.
///
/// In the example below, the text is rotated 45˚ about the `y` axis,
/// front-most (the default `zIndex`) and default `perspective` (`1`):
///
///     Text("Rotation by passing an angle in degrees")
///         .rotation3DEffect(.degrees(45), axis: (x: 0.0, y: 1.0, z: 0.0))
///         .border(Color.gray)
///
/// ![A screenshot showing the rotation of text 45 degrees about the
/// y-axis.](SwiftUI-View-rotation3DEffect.png)
///
/// - Parameters:
///   - angle: The angle at which to rotate the view.
///   - axis: The `x`, `y` and `z` elements that specify the axis of
///     rotation.
///   - anchor: The location with a default of ``UnitPoint/center`` that
///     defines a point in 3D space about which the rotation is anchored.
///   - anchorZ: The location with a default of `0` that defines a point in
///     3D space about which the rotation is anchored.
///   - perspective: The relative vanishing point with a default of `1` for
///     this rotation.
@inlinable public func rotation3DEffect(_ angle: Angle, axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint = .center, anchorZ: CGFloat = 0, perspective: CGFloat = 1) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the priority by which a parent layout should apportion space to
/// this child.
///
/// Views typically have a default priority of `0` which causes space to be
/// apportioned evenly to all sibling views. Raising a view's layout
/// priority encourages the higher priority view to shrink later when the
/// group is shrunk and stretch sooner when the group is stretched.
///
///     HStack {
///         Text("This is a moderately long string.")
///             .font(.largeTitle)
///             .border(Color.gray)
///
///         Spacer()
///
///         Text("This is a higher priority string.")
///             .font(.largeTitle)
///             .layoutPriority(1)
///             .border(Color.gray)
///     }
///
/// In the example above, the first ``Text`` element has the default
/// priority `0` which causes its view to shrink dramatically due to the
/// higher priority of the second ``Text`` element, even though all of their
/// other attributes (font, font size and character count) are the same.
///
/// ![A screenshot showing twoText views different layout
/// priorities.](SwiftUI-View-layoutPriority.png)
///
/// A parent layout offers the child views with the highest layout priority
/// all the space offered to the parent minus the minimum space required for
/// all its lower-priority children.
///
/// - Parameter value: The priority by which a parent layout apportions
///   space to the child.
@inlinable public func layoutPriority(_ value: Double) -> some View
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, unavailable)
extension View {
/// Inserts an inspector at the applied position in the view hierarchy.
///
/// Apply this modifier to declare an inspector with a context-dependent
/// presentation. For example, an inspector can present as a trailing
/// column in a horizontally regular size class, but adapt to a sheet in a
/// horizontally compact size class.
///
///     struct ShapeEditor: View {
///         @State var presented: Bool = false
///         var body: some View {
///             MyEditorView()
///                 .inspector(isPresented: $presented) {
///                     TextTraitsInspectorView()
///                 }
///         }
///     }
///
/// - Parameters:
///   - isPresented: A binding to `Bool` controlling the presented state.
///   - content: The inspector content.
///
/// - Note: Trailing column inspectors have their presentation state
/// restored by the framework.
/// - Seealso: ``InspectorCommands`` for including the default inspector
/// commands and keyboard shortcuts.
public func inspector<V>(isPresented: Binding<Bool>, @ViewBuilder content: () -> V) -> some View where V : View
/// Sets a flexible, preferred width for the inspector in a trailing-column
/// presentation.
///
/// Apply this modifier on the content of a
/// ``View/inspector(isPresented:content:)`` to specify a preferred flexible
/// width for the column. Use ``View/inspectorColumnWidth(_:)`` if you need
/// to specify a fixed width.
///
/// The following example shows an editor interface with an inspector, which
/// when presented as a trailing-column, has a preferred width of 225
/// points, maximum of 400, and a minimum of 150 at which point it will
/// collapse, if allowed.
///
///     MyEditorView()
///         .inspector {
///             TextTraitsInspectorView()
///                 .inspectorColumnWidth(min: 150, ideal: 225, max: 400)
///         }
///
/// Only some platforms enable flexible inspector columns. If
/// you specify a width that the current presentation environment doesn't
/// support, SwiftUI may use a different width for your column.
/// - Parameters:
///   - min: The minimum allowed width for the trailing column inspector
///   - ideal: The initial width of the inspector in the absence of state
///   restoration. `ideal` influences the resulting width on macOS when a
///   user double-clicks the divider on the leading edge of the inspector.
///   clicks a divider to readjust
///   - max: The maximum allowed width for the trailing column inspector
public func inspectorColumnWidth(min: CGFloat? = nil, ideal: CGFloat, max: CGFloat? = nil) -> some View
/// Sets a fixed, preferred width for the inspector containing this view
/// when presented as a trailing column.
///
/// Apply this modifier on the content of a
/// ``View/inspector(isPresented:content:)`` to specify a fixed preferred
/// width for the trailing column. Use
/// ``View/navigationSplitViewColumnWidth(min:ideal:max:)`` if
/// you need to specify a flexible width.
///
/// The following example shows an editor interface with an inspector, which
/// when presented as a trailing-column, has a fixed width of 225
/// points. The example also uses ``View/interactiveDismissDisabled(_:)`` to
/// prevent the inspector from being collapsed by user action like dragging
/// a divider.
///
///     MyEditorView()
///         .inspector {
///             TextTraitsInspectorView()
///                 .inspectorColumnWidth(225)
///                 .interactiveDismissDisabled()
///         }
///
/// - Parameter width: The preferred fixed width for the inspector if
/// presented as a trailing column.
/// - Note: A fixed width does not prevent the user collapsing the
/// inspector on macOS. See ``View/interactiveDismissDisabled(_:)``.
public func inspectorColumnWidth(_ width: CGFloat) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Scales images within the view according to one of the relative sizes
/// available including small, medium, and large images sizes.
///
/// The example below shows the relative scaling effect. The system renders
/// the image at a relative size based on the available space and
/// configuration options of the image it is scaling.
///
///     VStack {
///         HStack {
///             Image(systemName: "heart.fill")
///                 .imageScale(.small)
///             Text("Small")
///         }
///         HStack {
///             Image(systemName: "heart.fill")
///                 .imageScale(.medium)
///             Text("Medium")
///         }
///
///         HStack {
///             Image(systemName: "heart.fill")
///                 .imageScale(.large)
///             Text("Large")
///         }
///     }
///
/// ![A view showing small, medium, and large hearts rendered at a size
/// relative to the available space.](SwiftUI-View-imageScale.png)
///
/// - Parameter scale: One of the relative sizes provided by the image scale
///   enumeration.
@available(macOS 11.0, *)
@inlinable public func imageScale(_ scale: Image.Scale) -> some View
/// Sets the default font for text in this view.
///
/// Use `font(_:)` to apply a specific font to all of the text in a view.
///
/// The example below shows the effects of applying fonts to individual
/// views and to view hierarchies. Font information flows down the view
/// hierarchy as part of the environment, and remains in effect unless
/// overridden at the level of an individual view or view container.
///
/// Here, the outermost ``VStack`` applies a 16-point system font as a
/// default font to views contained in that ``VStack``. Inside that stack,
/// the example applies a ``Font/largeTitle`` font to just the first text
/// view; this explicitly overrides the default. The remaining stack and the
/// views contained with it continue to use the 16-point system font set by
/// their containing view:
///
///     VStack {
///         Text("Font applied to a text view.")
///             .font(.largeTitle)
///
///         VStack {
///             Text("These 2 text views have the same font")
///             Text("applied to their parent hierarchy")
///         }
///     }
///     .font(.system(size: 16, weight: .light, design: .default))
///
/// ![A screenshot showing the application fonts to an individual text field
/// and view hierarchy.](SwiftUI-view-font.png)
///
/// - Parameter font: The default font to use in this view.
///
/// - Returns: A view with the default font set to the value you supply.
@inlinable public func font(_ font: Font?) -> some View
/// Modifies the fonts of all child views to use fixed-width digits, if
/// possible, while leaving other characters proportionally spaced.
///
/// Using fixed-width digits allows you to easily align numbers of the
/// same size in a table-like arrangement. This feature is also known as
/// "tabular figures" or "tabular numbers."
///
/// This modifier only affects numeric characters, and leaves all other
/// characters unchanged.
///
/// The following example shows the effect of `monospacedDigit()` on
/// multiple child views. The example consists of two ``VStack`` views
/// inside an ``HStack``. Each `VStack` contains two ``Button`` views, with
/// the second `VStack` applying the `monospacedDigit()` modifier to its
/// contents. As a result, the digits in the buttons in the trailing
/// `VStack` are the same width, which in turn gives the buttons equal widths.
///
///     var body: some View {
///         HStack(alignment: .top) {
///             VStack(alignment: .leading) {
///                 Button("Delete 111 messages") {}
///                 Button("Delete 222 messages") {}
///             }
///             VStack(alignment: .leading) {
///                 Button("Delete 111 messages") {}
///                 Button("Delete 222 messages") {}
///             }
///             .monospacedDigit()
///         }
///         .padding()
///         .navigationTitle("monospacedDigit() Child Views")
///     }
///
/// ![A macOS window showing four buttons, arranged in two columns. Each
/// column's buttons contain the same text: Delete 111 messages and Delete
/// 222 messages. The right column's buttons have fixed width, or
/// monospaced, digits, which make the 1 characters wider than they would be
/// in a proportional font. Because the 1 and 2 characters are the same
/// width in the right column, the buttons are the same
/// width.](View-monospacedDigit-1)
///
/// If a child view's base font doesn't support fixed-width digits, the font
/// remains unchanged.
///
/// - Returns: A view whose child views' fonts use fixed-width numeric
/// characters, while leaving other characters proportionally spaced.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func monospacedDigit() -> some View
/// Modifies the fonts of all child views to use the fixed-width variant of
/// the current font, if possible.
///
/// If a child view's base font doesn't support fixed-width, the font
/// remains unchanged.
///
/// - Returns: A view whose child views' fonts use fixed-width characters,
/// while leaving other characters proportionally spaced.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func monospaced(_ isActive: Bool = true) -> some View
/// Sets the font weight of the text in this view.
///
/// - Parameter weight: One of the available font weights.
///   Providing `nil` removes the effect of any font weight
///   modifier applied higher in the view hierarchy.
///
/// - Returns: A view that uses the font weight you specify.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func fontWeight(_ weight: Font.Weight?) -> some View
/// Sets the font width of the text in this view.
///
/// - Parameter width: One of the available font widths.
///   Providing `nil` removes the effect of any font width
///   modifier applied higher in the view hierarchy.
///
/// - Returns: A view that uses the font width you specify.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func fontWidth(_ width: Font.Width?) -> some View
/// Applies a bold font weight to the text in this view.
///
/// - Parameter isActive: A Boolean value that indicates
///   whether bold font styling is added. The default value is `true`.
///
/// - Returns: A view with bold text.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func bold(_ isActive: Bool = true) -> some View
/// Applies italics to the text in this view.
///
/// - Parameter isActive: A Boolean value that indicates
///   whether italic styling is added. The default value is `true`.
///
/// - Returns: A View with italic text.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func italic(_ isActive: Bool = true) -> some View
/// Sets the font design of the text in this view.
///
/// - Parameter design: One of the available font designs.
///   Providing `nil` removes the effect of any font design
///   modifier applied higher in the view hierarchy.
///
/// - Returns: A view that uses the font design you specify.
@available(iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1, *)
public func fontDesign(_ design: Font.Design?) -> some View
/// Sets the spacing, or kerning, between characters for the text in this view.
///
/// - Parameter kerning: The spacing to use between individual characters in text.
///   Value of `0` sets the kerning to the system default value.
///
/// - Returns: A view where text has the specified amount of kerning.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func kerning(_ kerning: CGFloat) -> some View
/// Sets the tracking for the text in this view.
///
/// - Parameter tracking: The amount of additional space, in points, that
///   the view should add to each character cluster after layout. Value of `0`
///   sets the tracking to the system default value.
///
/// - Returns: A view where text has the specified amount of tracking.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func tracking(_ tracking: CGFloat) -> some View
/// Sets the vertical offset for the text relative to its baseline
/// in this view.
///
/// - Parameter baselineOffset: The amount to shift the text
///   vertically (up or down) relative to its baseline.
///
/// - Returns: A view where text is above or below its baseline.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func baselineOffset(_ baselineOffset: CGFloat) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets the style for progress views in this view.
///
/// For example, the following code creates a progress view that uses the
/// "circular" style:
///
///     ProgressView()
///         .progressViewStyle(.circular)
///
/// - Parameter style: The progress view style to use for this view.
public func progressViewStyle<S>(_ style: S) -> some View where S : ProgressViewStyle
}
extension View {
/// Marks this view as searchable with text and tokens.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
/// Marks this view as searchable with text and tokens.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
/// Marks this view as searchable with text and tokens.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T, S>(text: Binding<String>, tokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, S : StringProtocol, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: some StringProtocol, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
}
extension View {
/// Marks this view as searchable with text and tokens, as well as
/// programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` which controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
/// Marks this view as searchable with text and tokens, as well as
/// programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` which controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
/// Marks this view as searchable with text and tokens, as well as
/// programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T, S>(text: Binding<String>, tokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, S : StringProtocol, C.Element : Identifiable
/// Marks this view as searchable, which configures the display of a
/// search field.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - editableTokens: A collection of tokens to display and edit in the
///     search field.
///   - isPresenting: A ``Binding`` which controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C>(text: Binding<String>, editableTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: some StringProtocol, @ViewBuilder token: @escaping (Binding<C.Element>) -> some View) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable
}
extension View {
/// Marks this view as searchable with text, tokens, and suggestions.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : MutableCollection, C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable with text, tokens, and suggestions.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : MutableCollection, C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable with text, tokens, and suggestions.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T, S>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : MutableCollection, C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, S : StringProtocol, C.Element : Identifiable
/// Marks this view as searchable with text, tokens, and suggestions, as
/// well as programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A ``Text`` view representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: Text? = nil, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable with text, tokens, and suggestions, as
/// well as programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: The key for the localized prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: LocalizedStringKey, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, C.Element : Identifiable
/// Marks this view as searchable with text, tokens, and suggestions, as
/// well as programmatic presentation.
///
/// For more information about using searchable modifiers, see
/// <doc:Adding-a-search-interface-to-your-app>.
/// For information about presenting a search field programmatically, see
/// <doc:Managing-search-interface-activation>.
///
/// - Parameters:
///   - text: The text to display and edit in the search field.
///   - tokens: A collection of tokens to display and edit in the
///     search field.
///   - suggestedTokens: A collection of tokens to display as suggestions.
///   - isPresenting: A ``Binding`` that controls the presented state
///     of search.
///   - placement: The preferred placement of the search field within the
///     containing view hierarchy.
///   - prompt: A string representing the prompt of the search field
///     which provides users with guidance on what to search for.
///   - token: A view builder that creates a view given an element in
///     tokens.
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchable<C, T, S>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : MutableCollection, C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, S : StringProtocol, C.Element : Identifiable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Overrides the device for a preview.
///
/// By default, Xcode automatically chooses a preview device based
/// on your currently selected run destination. If you want to
/// choose a device that doesn't change based on Xcode settings,
/// provide a ``PreviewDevice`` instance that you initialize with
/// the name or model of a specific device:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)"))
///         }
///     }
///
/// You can get a list of supported preview device names, like "iPhone 11",
/// "iPad Pro (11-inch)", and "Apple Watch Series 5 - 44mm", by using the
/// `xcrun` command in the Terminal app:
///
///     % xcrun simctl list devicetypes
///
/// Additionally, you can use the following values for macOS platform
/// development:
/// - "Mac"
/// - "Mac Catalyst"
///
/// - Parameter value: A device to use for preview, or `nil` to let Xcode
///   automatically choose a device based on the run destination.
/// - Returns: A preview that uses the given device.
@inlinable public func previewDevice(_ value: PreviewDevice?) -> some View
/// Overrides the size of the container for the preview.
///
/// By default, previews use the ``PreviewLayout/device`` layout,
/// which places the view inside a visual representation of the chosen
/// device. You can instead tell a preview to use a different layout
/// by choosing one of the ``PreviewLayout`` values, like
/// ``PreviewLayout/sizeThatFits``:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewLayout(.sizeThatFits)
///         }
///     }
///
/// - Parameter value: A layout to use for preview.
/// - Returns: A preview that uses the given layout.
@inlinable public func previewLayout(_ value: PreviewLayout) -> some View
/// Sets a user visible name to show in the canvas for a preview.
///
/// Apply this modifier to a view inside your ``PreviewProvider``
/// implementation to associate a display name with that view's preview:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewDisplayName("Circle")
///         }
///     }
///
/// ![A screenshot of the Xcode preview canvas cropped to just the top of a
/// preview, highlighting the name in the preview's title bar, which is set
/// to the word circle.](View-previewDisplayName-1)
///
/// Add a name when you have multiple previews together in the canvas that
/// you need to tell apart. The default value is `nil`, in which case
/// Xcode displays a default string.
///
/// - Parameter value: A name for the preview.
/// - Returns: A preview that uses the given name.
@inlinable public func previewDisplayName(_ value: String?) -> some View
/// Declares a context for the preview.
///
/// - Parameter value: The context for the preview; the default is `nil`.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@inlinable public func previewContext<C>(_ value: C) -> some View where C : PreviewContext
/// Overrides the orientation of the preview.
///
/// By default, device previews appear right side up, using orientation
/// ``InterfaceOrientation/portrait``. You can
/// change the orientation of a preview using one of the values in
/// the ``InterfaceOrientation`` structure:
///
///     struct CircleImage_Previews: PreviewProvider {
///         static var previews: some View {
///             CircleImage()
///                 .previewInterfaceOrientation(.landscapeRight)
///         }
///     }
///
/// - Parameter value: An orientation to use for preview.
/// - Returns: A preview that uses the given orientation.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func previewInterfaceOrientation(_ value: InterfaceOrientation) -> some View
}
@available(iOS 13.0, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a popover using the given item as a data source for the
/// popover's content.
///
/// Use this method when you need to present a popover with content
/// from a custom data source. The example below uses data in
/// the `PopoverModel` structure to populate the view in the `content`
/// closure that the popover displays to the user:
///
///     struct PopoverExample: View {
///         @State private var popover: PopoverModel?
///
///         var body: some View {
///             Button("Show Popover") {
///                 popover = PopoverModel(message: "Custom Message")
///             }
///             .popover(item: $popover) { detail in
///                 Text("\(detail.message)")
///                     .padding()
///             }
///         }
///     }
///
///     struct PopoverModel: Identifiable {
///         var id: String { message }
///         let message: String
///     }
///
/// ![A screenshot showing a popover that says Custom Message hovering
/// over a Show Popover button.](View-popover-2)
///
/// - Parameters:
///   - item: A binding to an optional source of truth for the popover.
///     When `item` is non-`nil`, the system passes the contents to
///     the modifier's closure. You use this content to populate the fields
///     of a popover that you create that the system displays to the user.
///     If `item` changes, the system dismisses the currently presented
///     popover and replaces it with a new popover using the same process.
///   - attachmentAnchor: The positioning anchor that defines the
///     attachment point of the popover. The default is
///     ``Anchor/Source/bounds``.
///   - arrowEdge: The edge of the `attachmentAnchor` that defines the
///     location of the popover's arrow in macOS. The default is ``Edge/top``.
///     iOS ignores this parameter.
///   - content: A closure returning the content of the popover.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func popover<Item, Content>(item: Binding<Item?>, attachmentAnchor: PopoverAttachmentAnchor = .rect(.bounds), arrowEdge: Edge = .top, @ViewBuilder content: @escaping (Item) -> Content) -> some View where Item : Identifiable, Content : View
/// Presents a popover when a given condition is true.
///
/// Use this method to show a popover whose contents are a SwiftUI view
/// that you provide when a bound Boolean variable is `true`. In the
/// example below, a popover displays whenever the user toggles
/// the `isShowingPopover` state variable by pressing the
/// "Show Popover" button:
///
///     struct PopoverExample: View {
///         @State private var isShowingPopover = false
///
///         var body: some View {
///             Button("Show Popover") {
///                 self.isShowingPopover = true
///             }
///             .popover(isPresented: $isShowingPopover) {
///                 Text("Popover Content")
///                     .padding()
///             }
///         }
///     }
///
/// ![A screenshot showing a popover that says Popover Content hovering
/// over a Show Popover button.](View-popover-1)
///
/// - Parameters:
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the popover content that you return from the modifier's
///     `content` closure.
///   - attachmentAnchor: The positioning anchor that defines the
///     attachment point of the popover. The default is
///     ``Anchor/Source/bounds``.
///   - arrowEdge: The edge of the `attachmentAnchor` that defines the
///     location of the popover's arrow in macOS. The default is ``Edge/top``.
///     iOS ignores this parameter.
///   - content: A closure returning the content of the popover.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func popover<Content>(isPresented: Binding<Bool>, attachmentAnchor: PopoverAttachmentAnchor = .rect(.bounds), arrowEdge: Edge = .top, @ViewBuilder content: @escaping () -> Content) -> some View where Content : View
}
extension View {
/// Sets an observable object of the environment to the given value.
///
/// - Important: This modifier only accepts objects conforming to the
///   `Observable` protocol. For reading environment objects that conform to
///   `ObservableObject`, use ``View/environmentObject(_:)`` instead.
///
/// Use this modifier to set custom objects in a view's environment. For
/// example, you could set the environment object for a custom `Profile`
/// class:
///
///     @Observable final class Profile { ... }
///
///     struct RootView: View {
///         @State private var currentProfile: Profile?
///
///         var body: some View {
///             ContentView()
///                 .environment(currentProfile)
///         }
///     }
///
/// You then read the object inside `ContentView` or one of its descendants
/// using the ``Environment`` property wrapper:
///
///     struct ContentView: View {
///         @Environment(Account.self) private var currentAccount: Account
///
///         var body: some View { ... }
///     }
///
/// This modifier affects the given view, as
/// well as that view's descendant views. It has no effect outside the view
/// hierarchy on which you call it.
///
/// - Parameter object: The new object to set for this object's type in the
///   environment, or `nil` to clear the object from the environment.
///
/// - Returns: A view that has the given object set in its environment.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func environment<T>(_ object: T?) -> some View where T : AnyObject, T : Observable
}
extension View {
/// Sets the maximum number of lines that text can occupy in this view.
///
/// Use this modifier to cap the number of lines that an individual text
/// element can display.
///
/// The line limit applies to all ``Text`` instances within a hierarchy. For
/// example, an ``HStack`` with multiple pieces of text longer than three
/// lines caps each piece of text to three lines rather than capping the
/// total number of lines across the ``HStack``.
///
/// In the example below, the modifier limits the very long
/// line in the ``Text`` element to the 2 lines that fit within the view's
/// bounds:
///
///     Text("This is a long string that demonstrates the effect of SwiftUI's lineLimit(:_) operator.")
///         .frame(width: 200, height: 200, alignment: .leading)
///         .lineLimit(2)
///
/// ![A screenshot showing showing the effect of the line limit operator on
/// a very long string in a view.](SwiftUI-view-lineLimit.png)
///
/// - Parameter number: The line limit. If `nil`, no line limit applies.
///
/// - Returns: A view that limits the number of lines that ``Text``
///   instances display.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@inlinable public func lineLimit(_ number: Int?) -> some View
/// Sets to a partial range the number of lines that text can occupy in
/// this view.
///
/// Use this modifier to specify a partial range of lines that a ``Text``
/// view or a vertical ``TextField`` can occupy. When the text of such
/// views occupies less space than the provided limit, that view expands to
/// occupy the minimum number of lines.
///
///     Form {
///         TextField("Title", text: $model.title)
///         TextField("Notes", text: $model.notes, axis: .vertical)
///             .lineLimit(3...)
///     }
///
/// - Parameter limit: The line limit.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func lineLimit(_ limit: PartialRangeFrom<Int>) -> some View
/// Sets to a partial range the number of lines that text can occupy
/// in this view.
///
/// Use this modifier to specify a partial range of lines that a
/// ``Text`` view or a vertical ``TextField`` can occupy. When the text of
/// such views occupies more space than the provided limit, a ``Text`` view
/// truncates its content while a ``TextField`` becomes scrollable.
///
///     Form {
///         TextField("Title", text: $model.title)
///         TextField("Notes", text: $model.notes, axis: .vertical)
///             .lineLimit(...3)
///     }
///
/// > Note: This modifier is equivalent to the ``View/lineLimit(_:)-513mb``
/// modifier taking just an integer.
///
/// - Parameter limit: The line limit.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func lineLimit(_ limit: PartialRangeThrough<Int>) -> some View
/// Sets to a closed range the number of lines that text can occupy in
/// this view.
///
/// Use this modifier to specify a closed range of lines that a ``Text``
/// view or a vertical ``TextField`` can occupy. When the text of such
/// views occupies more space than the provided limit, a ``Text`` view
/// truncates its content while a ``TextField`` becomes scrollable.
///
///     Form {
///         TextField("Title", text: $model.title)
///         TextField("Notes", text: $model.notes, axis: .vertical)
///             .lineLimit(1...3)
///     }
///
/// - Parameter limit: The line limit.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func lineLimit(_ limit: ClosedRange<Int>) -> some View
/// Sets a limit for the number of lines text can occupy in this view.
///
/// Use this modifier to specify a limit to the lines that a
/// ``Text`` or a vertical ``TextField`` may occupy. If passed a
/// value of true for the `reservesSpace` parameter, and the text of such
/// views occupies less space than the provided limit, that view expands
/// to occupy the minimum number of lines. When the text occupies
/// more space than the provided limit, a ``Text`` view truncates its
/// content while a ``TextField`` becomes scrollable.
///
///     GroupBox {
///         Text("Title")
///             .font(.headline)
///             .lineLimit(2, reservesSpace: true)
///         Text("Subtitle")
///             .font(.subheadline)
///             .lineLimit(4, reservesSpace: true)
///     }
///
/// - Parameter limit: The line limit.
/// - Parameter reservesSpace: Whether text reserves space so that
///   it always occupies the height required to display the specified
///   number of lines.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func lineLimit(_ limit: Int, reservesSpace: Bool) -> some View
}
extension View {
/// Sets the visibility of scroll indicators within this view.
///
/// Use this modifier to hide or show scroll indicators on scrollable
/// content in views like a ``ScrollView``, ``List``, or ``TextEditor``.
/// This modifier applies the prefered visibility to any
/// scrollable content within a view hierarchy.
///
///     ScrollView {
///         VStack(alignment: .leading) {
///             ForEach(0..<100) {
///                 Text("Row \($0)")
///             }
///         }
///     }
///     .scrollIndicators(.hidden)
///
/// Use the ``ScrollIndicatorVisibility/hidden`` value to indicate that you
/// prefer that views never show scroll indicators along a given axis.
/// Use ``ScrollIndicatorVisibility/visible`` when you prefer that
/// views show scroll indicators. Depending on platform conventions,
/// visible scroll indicators might only appear while scrolling. Pass
/// ``ScrollIndicatorVisibility/automatic`` to allow views to
/// decide whether or not to show their indicators.
///
/// - Parameters:
///   - visibility: The visibility to apply to scrollable views.
///   - axes: The axes of scrollable views that the visibility applies to.
///
/// - Returns: A view with the specified scroll indicator visibility.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func scrollIndicators(_ visibility: ScrollIndicatorVisibility, axes: Axis.Set = [.vertical, .horizontal]) -> some View
}
extension View {
/// Flashes the scroll indicators of scrollable views when a value changes.
///
/// When the value that you provide to this modifier changes, the scroll
/// indicators of any scrollable views within the modified view hierarchy
/// briefly flash. The following example configures the scroll indicators
/// to flash any time `flashCount` changes:
///
///     @State private var isPresented = false
///     @State private var flashCount = 0
///
///     ScrollView {
///         // ...
///     }
///     .scrollIndicatorsFlash(trigger: flashCount)
///     .sheet(isPresented: $isPresented) {
///         // ...
///     }
///     .onChange(of: isPresented) { newValue in
///         if newValue {
///             flashCount += 1
///         }
///     }
///
/// Only scroll indicators that you configure to be visible flash.
/// To flash scroll indicators when a scroll view initially appears,
/// use ``View/scrollIndicatorsFlash(onAppear:)`` instead.
///
/// - Parameter value: The value that causes scroll indicators to flash.
///   The value must conform to the
///   <doc://com.apple.documentation/documentation/Swift/Equatable>
///   protocol.
///
/// - Returns: A view that flashes any visible scroll indicators when a
///   value changes.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollIndicatorsFlash(trigger value: some Equatable) -> some View
/// Flashes the scroll indicators of a scrollable view when it appears.
///
/// Use this modifier to control whether the scroll indicators of a scroll
/// view briefly flash when the view first appears. For example, you can
/// make the indicators flash by setting the `onAppear` parameter to `true`:
///
///     ScrollView {
///         // ...
///     }
///     .scrollIndicatorsFlash(onAppear: true)
///
/// Only scroll indicators that you configure to be visible flash.
/// To flash scroll indicators when a value changes, use
/// ``View/scrollIndicatorsFlash(trigger:)`` instead.
///
/// - Parameter onAppear: A Boolean value that indicates whether the scroll
///   indicators flash when the scroll view appears.
///
/// - Returns: A view that flashes any visible scroll indicators when it
///   first appears.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollIndicatorsFlash(onAppear: Bool) -> some View
}
extension View {
/// Disables or enables scrolling in scrollable views.
///
/// Use this modifier to control whether a ``ScrollView`` can scroll:
///
///     @State private var isScrollDisabled = false
///
///     var body: some View {
///         ScrollView {
///             VStack {
///                 Toggle("Disable", isOn: $isScrollDisabled)
///                 MyContent()
///             }
///         }
///         .scrollDisabled(isScrollDisabled)
///     }
///
/// SwiftUI passes the disabled property through the environment, which
/// means you can use this modifier to disable scrolling for all scroll
/// views within a view hierarchy. In the following example, the modifier
/// affects both scroll views:
///
///      ScrollView {
///          ForEach(rows) { row in
///              ScrollView(.horizontal) {
///                  RowContent(row)
///              }
///          }
///      }
///      .scrollDisabled(true)
///
/// You can also use this modifier to disable scrolling for other kinds
/// of scrollable views, like a ``List`` or a ``TextEditor``.
///
/// - Parameter disabled: A Boolean that indicates whether scrolling is
///   disabled.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func scrollDisabled(_ disabled: Bool) -> some View
}
extension View {
/// Sets whether a scroll view clips its content to its bounds.
///
/// By default, a scroll view clips its content to its bounds, but you can
/// disable that behavior by using this modifier. For example, if the views
/// inside the scroll view have shadows that extend beyond the bounds of the
/// scroll view, you can use this modifier to avoid clipping the shadows:
///
///     struct ContentView: View {
///         var disabled: Bool
///         let colors: [Color] = [.red, .green, .blue, .mint, .teal]
///
///         var body: some View {
///             ScrollView(.horizontal) {
///                 HStack(spacing: 20) {
///                     ForEach(colors, id: \.self) { color in
///                         Rectangle()
///                             .frame(width: 100, height: 100)
///                             .foregroundStyle(color)
///                             .shadow(color: .primary, radius: 20)
///                     }
///                 }
///             }
///             .scrollClipDisabled(disabled)
///         }
///     }
///
/// The scroll view in the above example clips when the
/// content view's `disabled` input is `false`, as it does
/// if you omit the modifier, but not when the input is `true`:
///
/// @TabNavigator {
///     @Tab("True") {
///         ![A horizontal row of uniformly sized, evenly spaced, vertically aligned squares inside a bounding box that's about twice the height of the squares, and almost four times the width. From left to right, three squares appear in full, while only the first quarter of a fourth square appears at the far right. All the squares have shadows that fade away before reaching the top or the bottom of the bounding box.](View-scrollClipDisabled-1-iOS)
///     }
///     @Tab("False") {
///         ![A horizontal row of uniformly sized, evenly spaced, vertically aligned squares inside a bounding box that's about twice the height of the squares, and almost four times the width. From left to right, three squares appear in full, while only the first quarter of a fourth square appears at the far right. All the squares have shadows that are visible in between squares, but clipped at the top and bottom of the squares.](View-scrollClipDisabled-2-iOS)
///     }
/// }
///
/// While you might want to avoid clipping parts of views that exceed the
/// bounds of the scroll view, like the shadows in the above example, you
/// typically still want the scroll view to clip at some point.
/// Create custom clipping by using the ``View/clipShape(_:style:)``
/// modifier to add a different clip shape. The following code disables
/// the default clipping and then adds rectangular clipping that exceeds
/// the bounds of the scroll view by the default padding amount:
///
///     ScrollView(.horizontal) {
///         // ...
///     }
///     .scrollClipDisabled()
///     .padding()
///     .clipShape(Rectangle())
///
/// - Parameter disabled: A Boolean value that specifies whether to disable
///   scroll view clipping.
///
/// - Returns: A view that disables or enables scroll view clipping.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func scrollClipDisabled(_ disabled: Bool = true) -> some View
}
extension View {
/// Configures the behavior in which scrollable content interacts with
/// the software keyboard.
///
/// You use this modifier to customize how scrollable content interacts
/// with the software keyboard. For example, you can specify a value of
/// ``ScrollDismissesKeyboardMode/immediately`` to indicate that you
/// would like scrollable content to immediately dismiss the keyboard if
/// present when a scroll drag gesture begins.
///
///     @State private var text = ""
///
///     ScrollView {
///         TextField("Prompt", text: $text)
///         ForEach(0 ..< 50) { index in
///             Text("\(index)")
///                 .padding()
///         }
///     }
///     .scrollDismissesKeyboard(.immediately)
///
/// You can also use this modifier to customize the keyboard dismissal
/// behavior for other kinds of scrollable views, like a ``List`` or a
/// ``TextEditor``.
///
/// By default, a ``TextEditor`` is interactive while other kinds
/// of scrollable content always dismiss the keyboard on a scroll
/// when linked against iOS 16 or later. Pass a value of
/// ``ScrollDismissesKeyboardMode/never`` to indicate that scrollable
/// content should never automatically dismiss the keyboard.
///
/// - Parameter mode: The keyboard dismissal mode that scrollable content
///   uses.
///
/// - Returns: A view that uses the specified keyboard dismissal mode.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@available(visionOS, unavailable)
public func scrollDismissesKeyboard(_ mode: ScrollDismissesKeyboardMode) -> some View
}
extension View {
/// Associates an anchor to control which part of the scroll view's
/// content should be rendered by default.
///
/// Use this modifier to specify an anchor to control both which part of
/// the scroll view's content should be visible initially and how
/// the scroll view handles content size changes.
///
/// Provide a value of `UnitPoint/center`` to have the scroll
/// view start in the center of its content when a scroll view
/// is scrollable in both axes.
///
///     ScrollView([.horizontal, .vertical]) {
///         // initially centered content
///     }
///     .defaultScrollAnchor(.center)
///
/// Provide a value of `UnitPoint/bottom` to have the scroll view
/// start at the bottom of its content when scrollable in the
/// vertical axis.
///
///     @Binding var items: [Item]
///     @Binding var scrolledID: Item.ID?
///
///     ScrollView {
///         LazyVStack {
///             ForEach(items) { item in
///                 ItemView(item)
///             }
///         }
///     }
///     .defaultScrollAnchor(.bottom)
///
/// The user may scroll away from the initial defined scroll position.
/// When the content size of the scroll view changes, it may consult
/// the anchor to know how to reposition the content.
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func defaultScrollAnchor(_ anchor: UnitPoint?) -> some View
}
extension View {
/// Configures the bounce behavior of scrollable views along the specified
/// axis.
///
/// Use this modifier to indicate whether scrollable views bounce when
/// people scroll to the end of the view's content, taking into account the
/// relative sizes of the view and its content. For example, the following
/// ``ScrollView`` only enables bounce behavior if its content is large
/// enough to require scrolling:
///
///     ScrollView {
///         Text("Small")
///         Text("Content")
///     }
///     .scrollBounceBehavior(.basedOnSize)
///
/// The modifier passes the scroll bounce mode through the ``Environment``,
/// which means that the mode affects any scrollable views in the modified
/// view hierarchy. Provide an axis to the modifier to constrain the kinds
/// of scrollable views that the mode affects. For example, all the scroll
/// views in the following example can access the mode value, but
/// only the two nested scroll views are affected, because only they use
/// horizontal scrolling:
///
///     ScrollView { // Defaults to vertical scrolling.
///         ScrollView(.horizontal) {
///             ShelfContent()
///         }
///         ScrollView(.horizontal) {
///             ShelfContent()
///         }
///     }
///     .scrollBounceBehavior(.basedOnSize, axes: .horizontal)
///
/// You can use this modifier to configure any kind of scrollable view,
/// including ``ScrollView``, ``List``, ``Table``, and ``TextEditor``:
///
///     List {
///         Text("Hello")
///         Text("World")
///     }
///     .scrollBounceBehavior(.basedOnSize)
///
/// - Parameters:
///   - behavior: The bounce behavior to apply to any scrollable views
///     within the configured view. Use one of the ``ScrollBounceBehavior``
///     values.
///   - axes: The set of axes to apply `behavior` to. The default is
///     ``Axis/vertical``.
///
/// - Returns: A view that's configured with the specified scroll bounce
///   behavior.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public func scrollBounceBehavior(_ behavior: ScrollBounceBehavior, axes: Axis.Set = [.vertical]) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Explicitly set whether this accessibility element is a direct touch
/// area. Direct touch areas passthrough touch events to the app rather
/// than being handled through an assistive technology, such as VoiceOver.
/// The modifier accepts an optional `AccessibilityDirectTouchOptions`
/// option set to customize the functionality of the direct touch area.
///
/// For example, this is how a direct touch area would allow a VoiceOver
/// user to interact with a view with a `rotationEffect` controlled by a
/// `RotationGesture`. The direct touch area would require a user to
/// activate the area before using the direct touch area.
///
///     var body: some View {
///         Rectangle()
///             .frame(width: 200, height: 200, alignment: .center)
///             .rotationEffect(angle)
///             .gesture(rotation)
///             .accessibilityDirectTouch(options: .requiresActivation)
///     }
///
public func accessibilityDirectTouch(_ isDirectTouchArea: Bool = true, options: AccessibilityDirectTouchOptions = []) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets the tint effect associated with specific content in a list.
///
/// The containing list's style will apply that tint as appropriate. watchOS
/// uses the tint color for its background platter appearance. Sidebars on
/// iOS and macOS apply the tint color to their `Label` icons, which
/// otherwise use the accent color by default.
///
/// - Parameter tint: The tint effect to use, or nil to not override the
///   inherited tint.
@inlinable public func listItemTint(_ tint: ListItemTint?) -> some View
/// Sets a fixed tint color associated with specific content in a list.
///
/// This is equivalent to using a tint of `ListItemTint.fixed(_:)` with the
/// provided `tint` color.
///
/// The containing list's style will apply that tint as appropriate. watchOS
/// uses the tint color for its background platter appearance. Sidebars on
/// iOS and macOS apply the tint color to their `Label` icons, which
/// otherwise use the accent color by default.
///
/// - Parameter color: The color to use to tint the content, or nil to not
///   override the inherited tint.
@inlinable public func listItemTint(_ tint: Color?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Hides the labels of any controls contained within this view.
///
/// Use this modifier when you want to omit a label from one or more
/// controls in your user interface. For example, the first ``Toggle`` in
/// the following example hides its label:
///
///     VStack {
///         Toggle(isOn: $toggle1) {
///             Text("Toggle 1")
///         }
///         .labelsHidden()
///
///         Toggle(isOn: $toggle2) {
///             Text("Toggle 2")
///         }
///     }
///
/// The ``VStack`` in the example above centers the first toggle's control
/// element in the available space, while it centers the second toggle's
/// combined label and control element:
///
/// ![A screenshot showing a view with two toggle controls where one label
///   is visible and the other label is hidden.](View-labelsHidden-1.png)
///
/// Always provide a label for controls, even when you hide the label,
/// because SwiftUI uses labels for other purposes, including accessibility.
///
/// > Note: This modifier doesn't work for all labels. It applies to
///   labels that are separate from the rest of the control's interface,
///   like they are for ``Toggle``, but not to controls like a bordered
///   button where the label is inside the button's border.
public func labelsHidden() -> some View
}
extension View {
/// Sets the container background of the enclosing container using a view.
///
/// The following example uses a ``LinearGradient`` as a background:
///
///     struct ContentView: View {
///         var body: some View {
///             NavigationStack {
///                 List {
///                     NavigationLink("Blue") {
///                         Text("Blue")
///                         .containerBackground(.blue.gradient, for: .navigation)
///                     }
///                     NavigationLink("Red") {
///                         Text("Red")
///                         .containerBackground(.red.gradient, for: .navigation)
///                     }
///                 }
///             }
///         }
///     }
///
/// The `.containerBackground(_:for:)` modifier differs from the
/// ``View/background(_:ignoresSafeAreaEdges:)`` modifier by automatically
/// filling an entire parent container. ``ContainerBackgroundPlacement``
/// describes the available containers.
///
/// - Parameters
///   - style: The shape style to use as the container background.
///   - container: The container that will use the background.
@available(iOS 17.0, tvOS 17.0, macOS 14.0, watchOS 10.0, *)
public func containerBackground<S>(_ style: S, for container: ContainerBackgroundPlacement) -> some View where S : ShapeStyle
/// Sets the container background of the enclosing container using a view.
///
/// The following example uses a custom ``View`` as a background:
///
///     struct ContentView: View {
///         var body: some View {
///             NavigationStack {
///                 List {
///                     NavigationLink("Image") {
///                         Text("Image")
///                         .containerBackground(for: .navigation) {
///                             Image(name: "ImageAsset")
///                         }
///                     }
///                 }
///             }
///         }
///     }
///
/// The `.containerBackground(for:alignment:content:)` modifier differs from
/// the ``View/background(_:ignoresSafeAreaEdges:)`` modifier by
/// automatically filling an entire parent container.
/// ``ContainerBackgroundPlacement`` describes the available containers.
///
/// - Parameters:
///   - alignment: The alignment that the modifier uses to position the
///     implicit ``ZStack`` that groups the background views. The default is
///     ``Alignment/center``.
///   - container: The container that will use the background.
///   - content: The view to use as the background of the container.
@available(iOS 17.0, tvOS 17.0, macOS 14.0, watchOS 10.0, *)
public func containerBackground<V>(for container: ContainerBackgroundPlacement, alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View where V : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the unique tag value of this view.
///
/// Use this modifier to differentiate among certain selectable views,
/// like the possible values of a ``Picker`` or the tabs of a ``TabView``.
/// Tag values can be of any type that conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Hashable> protocol.
///
/// In the example below, the ``ForEach`` loop in the ``Picker`` view
/// builder iterates over the `Flavor` enumeration. It extracts the string
/// value of each enumeration element for use in constructing the row
/// label, and uses the enumeration value, cast as an optional, as input
/// to the `tag(_:)` modifier. The ``Picker`` requires the tags to have a
/// type that exactly matches the selection type, which in this case is an
/// optional `Flavor`.
///
///     struct FlavorPicker: View {
///         enum Flavor: String, CaseIterable, Identifiable {
///             case chocolate, vanilla, strawberry
///             var id: Self { self }
///         }
///
///         @State private var selectedFlavor: Flavor? = nil
///
///         var body: some View {
///             Picker("Flavor", selection: $selectedFlavor) {
///                 ForEach(Flavor.allCases) { flavor in
///                     Text(flavor.rawValue).tag(Optional(flavor))
///                 }
///             }
///         }
///     }
///
/// If you change `selectedFlavor` to be non-optional, you need to
/// remove the <doc://com.apple.documentation/documentation/Swift/Optional>
/// cast from the tag input to match.
///
/// A ``ForEach`` automatically applies a default tag to each enumerated
/// view using the `id` parameter of the corresponding element. If
/// the element's `id` parameter and the picker's `selection` input
/// have exactly the same type, you can omit the explicit tag modifier.
/// To see examples that don't require an explicit tag, see ``Picker``.
///
/// - Parameter tag: A <doc://com.apple.documentation/documentation/Swift/Hashable>
///   value to use as the view's tag.
///
/// - Returns: A view with the specified tag set.
@inlinable public func tag<V>(_ tag: V) -> some View where V : Hashable
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the style for pickers within this view.
public func pickerStyle<S>(_ style: S) -> some View where S : PickerStyle
}
@available(iOS 17.0, watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
extension View {
/// Sets the spacing between adjacent sections in a List.
///
/// Pass `.default` for the default spacing, or use `.compact` for
/// a compact appearance between sections.
///
/// The following example creates a List with compact spacing between
/// sections:
///
///     List {
///         Section("Colors") {
///             Text("Blue")
///             Text("Red")
///         }
///
///         Section("Shapes") {
///             Text("Square")
///             Text("Circle")
///         }
///     }
///     .listSectionSpacing(.compact)
@inlinable public func listSectionSpacing(_ spacing: ListSectionSpacing) -> some View
/// Sets the spacing to a custom value between adjacent sections in a List.
///
/// The following example creates a List with 5 pts of spacing between
/// sections:
///
///     List {
///         Section("Colors") {
///             Text("Blue")
///             Text("Red")
///         }
///
///         Section("Shapes") {
///             Text("Square")
///             Text("Circle")
///         }
///     }
///     .listSectionSpacing(5.0)
///
/// Spacing can also be specified on a per-section basis. The following
/// example creates a List with compact spacing for its second section:
///
///     List {
///         Section("Colors") {
///             Text("Blue")
///             Text("Red")
///         }
///
///         Section("Borders") {
///             Text("Dashed")
///             Text("Solid")
///         }
///         .listSectionSpacing(.compact)
///
///         Section("Shapes") {
///             Text("Square")
///             Text("Circle")
///         }
///     }
///
/// If adjacent sections have different spacing value, the smaller value on
/// the shared edge is used. Spacing specified inside the List is preferred
/// over any List-wide value.
///
/// - Parameter spacing: the amount of spacing to apply.
@inlinable public func listSectionSpacing(_ spacing: CGFloat) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Specifies whether to hide this view from system accessibility features.
public func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Binds a view's identity to the given proxy value.
///
/// When the proxy value specified by the `id` parameter changes, the
/// identity of the view — for example, its state — is reset.
@inlinable public func id<ID>(_ id: ID) -> some View where ID : Hashable
}
extension View {
/// Tells a menu whether to dismiss after performing an action.
///
/// Use this modifier to control the dismissal behavior of a menu.
/// In the example below, the menu doesn't dismiss after someone
/// chooses either the increase or decrease action:
///
///     Menu("Font size") {
///         Button(action: increase) {
///             Label("Increase", systemImage: "plus.magnifyingglass")
///         }
///         .menuActionDismissBehavior(.disabled)
///
///         Button("Reset", action: reset)
///
///         Button(action: decrease) {
///             Label("Decrease", systemImage: "minus.magnifyingglass")
///         }
///         .menuActionDismissBehavior(.disabled)
///     }
///
/// You can use this modifier on any controls that present a menu, like a
/// ``Picker`` that uses the ``PickerStyle/menu`` style or a
/// ``ControlGroup``. For example, the code below creates a picker that
/// disables dismissal when someone selects one of the options:
///
///     Picker("Flavor", selection: $selectedFlavor) {
///         ForEach(Flavor.allCases) { flavor in
///             Text(flavor.rawValue.capitalized)
///                 .tag(flavor)
///         }
///     }
///     .pickerStyle(.menu)
///     .menuActionDismissBehavior(.disabled)
///
/// You can also use this modifier on context menus. The example below
/// creates a context menu that stays presented after someone selects an
/// action to run:
///
///     Text("Favorite Card Suit")
///         .padding()
///         .contextMenu {
///             Button("♥️ - Hearts", action: increaseHeartsCount)
///             Button("♣️ - Clubs", action: increaseClubsCount)
///             Button("♠️ - Spades", action: increaseSpadesCount)
///             Button("♦️ - Diamonds", action: increaseDiamondsCount)
///         }
///         .menuActionDismissBehavior(.disabled)
///
/// - Parameter dismissal: The menu action dismissal behavior to apply.
///
/// - Returns: A view that has the specified menu dismissal behavior.
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
public func menuActionDismissBehavior(_ behavior: MenuActionDismissBehavior) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the accent color for this view and the views it contains.
///
/// Use `accentColor(_:)` when you want to apply a broad theme color to
/// your app's user interface. Some styles of controls use the accent color
/// as a default tint color.
///
/// > Note: In macOS, SwiftUI applies customization of the accent color
/// only if the user chooses Multicolor under General > Accent color
/// in System Preferences.
///
/// In the example below, the outer ``VStack`` contains two child views. The
/// first is a button with the default accent color. The second is a ``VStack``
/// that contains a button and a slider, both of which adopt the purple
/// accent color of their containing view. Note that the ``Text`` element
/// used as a label alongside the `Slider` retains its default color.
///
///     VStack(spacing: 20) {
///         Button(action: {}) {
///             Text("Regular Button")
///         }
///         VStack {
///             Button(action: {}) {
///                 Text("Accented Button")
///             }
///             HStack {
///                 Text("Accented Slider")
///                 Slider(value: $sliderValue, in: -100...100, step: 0.1)
///             }
///         }
///         .accentColor(.purple)
///     }
///
/// ![A VStack showing two child views: one VStack containing a default
/// accented button, and a second VStack where the VStack has a purple
/// accent color applied. The accent color modifies the enclosed button and
/// slider, but not the color of a Text item used as a label for the
/// slider.](View-accentColor-1)
///
/// - Parameter accentColor: The color to use as an accent color. Set the
///   value to `nil` to use the inherited accent color.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use the asset catalog's accent color or View.tint(_:) instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use the asset catalog's accent color or View.tint(_:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use the asset catalog's accent color or View.tint(_:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use the asset catalog's accent color or View.tint(_:) instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use the asset catalog's accent color or View.tint(_:) instead.")
@inlinable public func accentColor(_ accentColor: Color?) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets a clipping shape for this view.
///
/// Use `clipShape(_:style:)` to clip the view to the provided shape. By
/// applying a clipping shape to a view, you preserve the parts of the view
/// covered by the shape, while eliminating other parts of the view. The
/// clipping shape itself isn't visible.
///
/// For example, this code applies a circular clipping shape to a `Text`
/// view:
///
///     Text("Clipped text in a circle")
///         .frame(width: 175, height: 100)
///         .foregroundColor(Color.white)
///         .background(Color.black)
///         .clipShape(Circle())
///
/// The resulting view shows only the portion of the text that lies within
/// the bounds of the circle.
///
/// ![A screenshot of text clipped to the shape of a
/// circle.](SwiftUI-View-clipShape.png)
///
/// - Parameters:
///   - shape: The clipping shape to use for this view. The `shape` fills
///     the view's frame, while maintaining its aspect ratio.
///   - style: The fill style to use when rasterizing `shape`.
///
/// - Returns: A view that clips this view to `shape`, using `style` to
///   define the shape's rasterization.
@inlinable public func clipShape<S>(_ shape: S, style: FillStyle = FillStyle()) -> some View where S : Shape
/// Clips this view to its bounding rectangular frame.
///
/// Use the `clipped(antialiased:)` modifier to hide any content that
/// extends beyond the layout bounds of the shape.
///
/// By default, a view's bounding frame is used only for layout, so any
/// content that extends beyond the edges of the frame is still visible.
///
///     Text("This long text string is clipped")
///         .fixedSize()
///         .frame(width: 175, height: 100)
///         .clipped()
///         .border(Color.gray)
///
/// ![Screenshot showing text clipped to its
/// frame.](SwiftUI-View-clipped.png)
///
/// - Parameter antialiased: A Boolean value that indicates whether the
///   rendering system applies smoothing to the edges of the clipping
///   rectangle.
///
/// - Returns: A view that clips this view to its bounding frame.
@inlinable public func clipped(antialiased: Bool = false) -> some View
/// Clips this view to its bounding frame, with the specified corner radius.
///
/// By default, a view's bounding frame only affects its layout, so any
/// content that extends beyond the edges of the frame remains visible. Use
/// `cornerRadius(_:antialiased:)` to hide any content that extends beyond
/// these edges while applying a corner radius.
///
/// The following code applies a corner radius of 25 to a text view:
///
///     Text("Rounded Corners")
///         .frame(width: 175, height: 75)
///         .foregroundColor(Color.white)
///         .background(Color.black)
///         .cornerRadius(25)
///
/// ![A screenshot of a rectangle with rounded corners bounding a text
/// view.](SwiftUI-View-cornerRadius.png)
///
/// - Parameter antialiased: A Boolean value that indicates whether the
///   rendering system applies smoothing to the edges of the clipping
///   rectangle.
///
/// - Returns: A view that clips this view to its bounding frame with the
///   specified corner radius.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `clipShape` or `fill` instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `clipShape` or `fill` instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use `clipShape` or `fill` instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use `clipShape` or `fill` instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use `clipShape` or `fill` instead.")
@inlinable public func cornerRadius(_ radius: CGFloat, antialiased: Bool = true) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Defines a group of views with synchronized geometry using an
/// identifier and namespace that you provide.
///
/// This method sets the geometry of each view in the group from the
/// inserted view with `isSource = true` (known as the "source" view),
/// updating the values marked by `properties`.
///
/// If inserting a view in the same transaction that another view
/// with the same key is removed, the system will interpolate their
/// frame rectangles in window space to make it appear that there
/// is a single view moving from its old position to its new
/// position. The usual transition mechanisms define how each of
/// the two views is rendered during the transition (e.g. fade
/// in/out, scale, etc), the `matchedGeometryEffect()` modifier
/// only arranges for the geometry of the views to be linked, not
/// their rendering.
///
/// If the number of currently-inserted views in the group with
/// `isSource = true` is not exactly one results are undefined, due
/// to it not being clear which is the source view.
///
/// - Parameters:
///   - id: The identifier, often derived from the identifier of
///     the data being displayed by the view.
///   - namespace: The namespace in which defines the `id`. New
///     namespaces are created by adding an `@Namespace` variable
///     to a ``View`` type and reading its value in the view's body
///     method.
///   - properties: The properties to copy from the source view.
///   - anchor: The relative location in the view used to produce
///     its shared position value.
///   - isSource: True if the view should be used as the source of
///     geometry for other views in the group.
///
/// - Returns: A new view that defines an entry in the global
///   database of views synchronizing their geometry.
///
@inlinable public func matchedGeometryEffect<ID>(id: ID, in namespace: Namespace.ID, properties: MatchedGeometryProperties = .frame, anchor: UnitPoint = .center, isSource: Bool = true) -> some View where ID : Hashable
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Associates a fully formed string with the value of this view.
///
/// Use this method to associate a fully formed string with a
/// view that is within a search suggestion list context. The system
/// uses this value when the view is selected to replace the
/// partial text being currently edited of the associated search field.
///
/// On tvOS, the string that you provide to the this modifier is
/// used when displaying the associated suggestion and when
/// replacing the partial text of the search field.
///
///     SearchPlaceholderView()
///         .searchable(text: $text) {
///             Text("🍎").searchCompletion("apple")
///             Text("🍐").searchCompletion("pear")
///             Text("🍌").searchCompletion("banana")
///         }
///
/// - Parameters:
///   - text: A string to use as the view’s completion.
public func searchCompletion(_ completion: String) -> some View
}
extension View {
/// Associates a search token with the value of this view.
///
/// Use this method to associate a search token with a view that is
/// within a search suggestion list context. The system uses this value
/// when the view is selected to replace the partial text being currently
/// edited of the associated search field.
///
///     enum FruitToken: Hashable, Identifiable, CaseIterable {
///         case apple
///         case pear
///         case banana
///
///         var id: Self { self }
///     }
///
///     @State private var text = ""
///     @State private var tokens: [FruitToken] = []
///
///     SearchPlaceholderView()
///         .searchable(text: $text, tokens: $tokens) { token in
///             switch token {
///             case .apple: Text("Apple")
///             case .pear: Text("Pear")
///             case .banana: Text("Banana")
///             }
///         }
///         .searchSuggestions {
///             Text("🍎").searchCompletion(FruitToken.apple)
///             Text("🍐").searchCompletion(FruitToken.pear)
///             Text("🍌").searchCompletion(FruitToken.banana)
///         }
///
/// - Parameters:
///   - token: Data to use as the view’s completion.
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func searchCompletion<T>(_ token: T) -> some View where T : Identifiable
/// Configures how to display search suggestions within this view.
///
/// SwiftUI presents search suggestions differently depending on several
/// factors, like the platform, the position of the search field, and the
/// size class. Use this modifier when you want to only display suggestions
/// in certain ways under certain conditions. For example, you might choose
/// to display suggestions in a menu when possible, but directly filter
/// your data source otherwise.
///
///     enum FruitSuggestion: String, Identifiable {
///         case apple, banana, orange
///         var id: Self { self }
///     }
///
///     @State private var text = ""
///     @State private var suggestions: [FruitSuggestion] = []
///
///     var body: some View {
///         MainContent()
///             .searchable(text: $text) {
///                 ForEach(suggestions) { suggestion
///                     Text(suggestion.rawValue)
///                         .searchCompletion(suggestion.rawValue)
///                 }
///                 .searchSuggestions(.hidden, for: .content)
///             }
///     }
///
/// - Parameters:
///   - visibility: The visibility of the search suggestions
///     for the specified locations.
///   - placements: The set of locations in which to set the visibility of
///     search suggestions.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func searchSuggestions(_ visibility: Visibility, for placements: SearchSuggestionsPlacement.Set) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Defines an explicit identifier tying an Accessibility element for this
/// view to an entry in an Accessibility Rotor.
///
/// Use this when creating an AccessibilityRotorEntry without a namespace
/// does not allow SwiftUI to automatically find and reveal the element,
/// or when the Rotor entry should be associated with a sub-element of
/// a complex view generated in a ForEach, for example.
///
/// - Parameter id: An arbitrary hashable identifier. Pass this same value
/// when initializing an AccessibilityRotorEntry.
/// - Parameter namespace: A namespace created with `@Namespace()`. Pass this
/// same namespace when initializing an `AccessibilityRotorEntry`.
public func accessibilityRotorEntry<ID>(id: ID, in namespace: Namespace.ID) -> some View where ID : Hashable
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Associates a value with a custom layout property.
///
/// Use this method to set a value for a custom property that
/// you define with ``LayoutValueKey``. For example, if you define
/// a `Flexibility` key, you can set the key on a ``Text`` view
/// using the key's type and a value:
///
///     Text("Another View")
///         .layoutValue(key: Flexibility.self, value: 3)
///
/// For convenience, you might define a method that does this in an
/// extension to ``View``:
///
///     extension View {
///         func layoutFlexibility(_ value: CGFloat?) -> some View {
///             layoutValue(key: Flexibility.self, value: value)
///         }
///     }
///
/// This method makes the call site easier to read:
///
///     Text("Another View")
///         .layoutFlexibility(3)
///
/// If you perform layout operations in a type that conforms to the
/// ``Layout`` protocol, you can read the key's associated value for
/// each subview of your custom layout type. Do this by indexing the
/// subview's proxy with the key. For more information, see
/// ``LayoutValueKey``.
///
/// - Parameters:
///   - key: The type of the key that you want to set a value for.
///     Create the key as a type that conforms to the ``LayoutValueKey``
///     protocol.
///   - value: The value to assign to the key for this view.
///     The value must be of the type that you establish for the key's
///     associated value when you implement the key's
///     ``LayoutValueKey/defaultValue`` property.
///
/// - Returns: A view that has the specified value for the specified key.
@inlinable public func layoutValue<K>(key: K.Type, value: K.Value) -> some View where K : LayoutValueKey
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the border shape for buttons in this view.
///
/// The border shape is used to draw the platter for a bordered button.
/// On macOS, the specified border shape is only applied to bordered
/// buttons in widgets.
///
/// - Parameter shape: the shape to use.
/// - Note:This will only reflect on explicitly-set `.bordered` or
///   `borderedProminent` styles. Setting a shape without
///   explicitly setting the above styles will have no effect.
@inlinable public func buttonBorderShape(_ shape: ButtonBorderShape) -> some View
}
extension View {
/// Assigns a name to the view's coordinate space, so other code can operate
/// on dimensions like points and sizes relative to the named space.
///
/// Use `coordinateSpace(name:)` to allow another function to find and
/// operate on a view and operate on dimensions relative to that view.
///
/// The example below demonstrates how a nested view can find and operate on
/// its enclosing view's coordinate space:
///
///     struct ContentView: View {
///         @State private var location = CGPoint.zero
///
///         var body: some View {
///             VStack {
///                 Color.red.frame(width: 100, height: 100)
///                     .overlay(circle)
///                 Text("Location: \(Int(location.x)), \(Int(location.y))")
///             }
///             .coordinateSpace(name: "stack")
///         }
///
///         var circle: some View {
///             Circle()
///                 .frame(width: 25, height: 25)
///                 .gesture(drag)
///                 .padding(5)
///         }
///
///         var drag: some Gesture {
///             DragGesture(coordinateSpace: .named("stack"))
///                 .onChanged { info in location = info.location }
///         }
///     }
///
/// Here, the ``VStack`` in the `ContentView` named “stack” is composed of a
/// red frame with a custom ``Circle`` view ``View/overlay(_:alignment:)``
/// at its center.
///
/// The `circle` view has an attached ``DragGesture`` that targets the
/// enclosing VStack's coordinate space. As the gesture recognizer's closure
/// registers events inside `circle` it stores them in the shared `location`
/// state variable and the ``VStack`` displays the coordinates in a ``Text``
/// view.
///
/// ![A screenshot showing an example of finding a named view and tracking
/// relative locations in that view.](SwiftUI-View-coordinateSpace.png)
///
/// - Parameter name: A name used to identify this coordinate space.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "use coordinateSpace(_:) instead")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "use coordinateSpace(_:) instead")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "use coordinateSpace(_:) instead")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "use coordinateSpace(_:) instead")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use coordinateSpace(_:) instead")
@inlinable public func coordinateSpace<T>(name: T) -> some View where T : Hashable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Assigns a name to the view's coordinate space, so other code can operate
/// on dimensions like points and sizes relative to the named space.
///
/// Use `coordinateSpace(_:)` to allow another function to find and
/// operate on a view and operate on dimensions relative to that view.
///
/// The example below demonstrates how a nested view can find and operate on
/// its enclosing view's coordinate space:
///
///     struct ContentView: View {
///         @State private var location = CGPoint.zero
///
///         var body: some View {
///             VStack {
///                 Color.red.frame(width: 100, height: 100)
///                     .overlay(circle)
///                 Text("Location: \(Int(location.x)), \(Int(location.y))")
///             }
///             .coordinateSpace(.named("stack"))
///         }
///
///         var circle: some View {
///             Circle()
///                 .frame(width: 25, height: 25)
///                 .gesture(drag)
///                 .padding(5)
///         }
///
///         var drag: some Gesture {
///             DragGesture(coordinateSpace: .named("stack"))
///                 .onChanged { info in location = info.location }
///         }
///     }
///
/// Here, the ``VStack`` in the `ContentView` named “stack” is composed of a
/// red frame with a custom ``Circle`` view ``View/overlay(_:alignment:)``
/// at its center.
///
/// The `circle` view has an attached ``DragGesture`` that targets the
/// enclosing VStack's coordinate space. As the gesture recognizer's closure
/// registers events inside `circle` it stores them in the shared `location`
/// state variable and the ``VStack`` displays the coordinates in a ``Text``
/// view.
///
/// ![A screenshot showing an example of finding a named view and tracking
/// relative locations in that view.](SwiftUI-View-coordinateSpace.png)
///
/// - Parameter name: A name used to identify this coordinate space.
public func coordinateSpace(_ name: NamedCoordinateSpace) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Supplies an observable object to a view's hierarchy.
///
/// Use this modifier to add an observable object to a view's environment.
/// The object must conform to the
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject>
/// protocol.
///
/// Adding an object to a view's environment makes the object available to
/// subviews in the view's hierarchy. To retrieve the object in a subview,
/// use the ``EnvironmentObject`` property wrapper.
///
/// > Note: If the observable object conforms to the
/// <doc://com.apple.documentation/documentation/Observation/Observable>
/// protocol, use either ``View/environment(_:)`` or the
/// ``View/environment(_:_:)`` modifier to add the object to the view's
/// environment.
///
/// - Parameter object: The object to store and make available to
///     the view's hierarchy.
@inlinable public func environmentObject<T>(_ object: T) -> some View where T : ObservableObject
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Create an Accessibility Rotor with the specified user-visible label,
/// and entries generated from the content closure.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs") {
///         // Not all the MessageViews are generated at once, the model knows
///         // about all the messages.
///         ForEach(messages) { message in
///             // If the Message is from a VIP, make a Rotor entry for it.
///             if message.isVIP {
///                 AccessibilityRotorEntry(message.subject, id: message.id)
///             }
///         }
///     }
///
/// - Parameters:
///   - label: Localized label identifying this Rotor to the user.
///   - entries: Content used to generate Rotor entries. This can
///     include AccessibilityRotorEntry structs, as well as constructs such
///     as if and ForEach.
public func accessibilityRotor<Content>(_ label: Text, @AccessibilityRotorContentBuilder entries: @escaping () -> Content) -> some View where Content : AccessibilityRotorContent
/// Create an Accessibility Rotor replacing the specified system-provided
/// Rotor.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
/// Replacing system Rotors this way is useful when the System Rotor
/// does not automatically pick up elements that aren't on-screen,
/// such as elements far down in a `LazyVStack` or `List`.
///
/// In the following example, a Message application adds a Rotor allowing
/// the user to navigate through all the ranges of text containing
/// headings.
///
///     extension Message {
///         // Ranges of special areas in the `content` text. Calculated
///         // when `content` is set and then cached so that we don't have
///         // to re-compute them.
///         var contentHeadingRanges: [Range<String.Index>]
///     }
///
///     struct MessageContentView: View {
///         TextEditor(.constant(message.content))
///             .accessibilityRotor(.heading) {
///                 ForEach(range in message.contentHeadingRanges) {
///                     AccessibilityRotorEntry(textRange: range)
///                 }
///             }
///     }
///
/// - Parameters:
///   - systemRotor: The system-provided Rotor that will be overridden
///     by this custom Rotor.
///   - entries: Content used to generate Rotor entries. This can
///     include AccessibilityRotorEntry structs, as well as constructs such
///     as if and ForEach.
public func accessibilityRotor<Content>(_ systemRotor: AccessibilitySystemRotor, @AccessibilityRotorContentBuilder entries: @escaping () -> Content) -> some View where Content : AccessibilityRotorContent
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s that have a
///     // `subject`.
///     // `vipMessages` is a filtered version of that list containing only
///     // messages from VIPs.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages, label: \.subject)
///
/// - Parameters:
///   - rotorLabel: Localized label identifying this Rotor to the user.
///   - entries: An array of identifiable values that will be
///     used to generate the entries of the Rotor. The identifiers
///     of the `Identifiable` values must match up with identifiers in a
///     `ForEach` or explicit `id` calls within the `ScrollView`.
///     When the user navigates to entries from this Rotor, SwiftUI will
///     automatically scroll them into place as needed.
///   - entryLabel: Key path on the `Identifiable` type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel>(_ rotorLabel: Text, entries: [EntryModel], entryLabel: KeyPath<EntryModel, String>) -> some View where EntryModel : Identifiable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
/// When the user navigates to entries from this Rotor, SwiftUI will
/// automatically scroll them into place as needed.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Message`s that have a `subject` and a
///     // `uuid`. `vipMessages` is a filtered version of that list
///     // containing only messages from VIPs.
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages,
///         id: \.uuid, label: \.subject)
///
/// - Parameters:
///   - rotorLabel: Localized label identifying this Rotor to the user.
///   - entries: An array of values that will be used to generate
///     the entries of the Rotor.
///   - entryID: Key path on the entry type that can be used
///     to generate an identifier for the Entry. The identifiers
///     must match up with identifiers in `ForEach` or explicit `id` calls
///     within the `ScrollView`.
///   - entryLabel: Key path on the entry type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel, ID>(_ rotorLabel: Text, entries: [EntryModel], entryID: KeyPath<EntryModel, ID>, entryLabel: KeyPath<EntryModel, String>) -> some View where ID : Hashable
/// Create an Accessibility Rotor replacing the specified system-provided
/// Rotor.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to the headings in its vertical stack of
/// messages.
///
///     // `messageListItems` is a list of `Identifiable` `MessageListItem`s
///     // that are either a `Message` or a heading, containing a `subject`.
///     // `headingMessageListItems` is a filtered list of
///     // `messageListItems` containing just the headings.
///     ScrollView {
///         LazyVStack {
///             ForEach(messageListItems) { messageListItem in
///                 switch messageListItem {
///                     case .heading(let subject):
///                         Text(subject)
///                     case .message(let message):
///                         MessageView(message)
///                 }
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor(
///         .heading, entries: headingMessageListItems, label: \.subject)
///
/// - Parameters:
///   - systemRotor: The system-provided Rotor that will be overridden
///     by this custom Rotor.
///   - entries: An array of identifiable values that will be
///     used to generate the entries of the Rotor. The identifiers
///     of the `Identifiable` values must match up with identifiers in a
///     `ForEach` or explicit `id` calls within the `ScrollView`.
///     When the user navigates to entries from this Rotor, SwiftUI will
///     automatically scroll them into place as needed.
///   - entryLabel: Key path on the `Identifiable` type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel>(_ systemRotor: AccessibilitySystemRotor, entries: [EntryModel], entryLabel: KeyPath<EntryModel, String>) -> some View where EntryModel : Identifiable
/// Create an Accessibility Rotor replacing the specified system-provided
/// Rotor.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
/// When the user navigates to entries from this Rotor, SwiftUI will
/// automatically scroll them into place as needed.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to the headings in its vertical stack of
/// messages.
///
///     // `messageListItems` is a list of `MessageListItem`s
///     // that are either a `Message` or a heading, containing a `subject`
///     // and a `uuid`.
///     // `headingMessageListItems` is a filtered list of
///     // `messageListItems` containing just the headings.
///     ScrollView {
///         LazyVStack {
///             ForEach(messageListItems) { messageListItem in
///                 switch messageListItem {
///                     case .heading(let subject):
///                         Text(subject)
///                     case .message(let message):
///                         MessageView(message)
///                 }
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor(
///         .heading, entries: headingMessageListItems,
///         entryID: \.uuid, label: \.subject
///     )
///
/// - Parameters:
///   - systemRotor: The system-provided Rotor that will be overridden
///     by this custom Rotor.
///   - entries: An array of values that will be used to generate
///     the entries of the Rotor.
///   - entryID: Key path on the entry type that can be used
///     to generate an identifier for the Entry. The identifiers
///     must match up with identifiers in `ForEach` or explicit `id` calls
///     within the `ScrollView`.
///   - entryLabel: Key path on the entry type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel, ID>(_ systemRotor: AccessibilitySystemRotor, entries: [EntryModel], entryID: KeyPath<EntryModel, ID>, entryLabel: KeyPath<EntryModel, String>) -> some View where ID : Hashable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries for each of the specified ranges. The Rotor will be attached
/// to the current Accessibility element, and each entry will go the
/// specified range of that element.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application adds a Rotor allowing
/// the user to navigate through all the ranges of text containing
/// email addresses.
///
///     extension Message {
///         // Ranges of special areas in the `content` text. Calculated
///         // when `content` is set and then cached so that we don't have
///         // to re-compute them.
///         var emailAddressRanges: [Range<String.Index>]
///     }
///
///     struct MessageContentView: View {
///         TextEditor(.constant(message.content))
///             .accessibilityRotor("Email Addresses",
///                 textRanges: message.emailAddressRanges)
///     }
///
/// - Parameters:
///   - label: Localized label identifying this Rotor to the user.
///   - textRanges: An array of ranges that will be used to generate
///     the entries of the Rotor.
public func accessibilityRotor(_ label: Text, textRanges: [Range<String.Index>]) -> some View
/// Create an Accessibility Rotor replacing the specified system-provided
/// Rotor. The Rotor will be attached to the current Accessibility element,
/// and each entry will go the specified range of that element.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application adds a Rotor allowing
/// the user to navigate through all the ranges of text containing headings.
///
///     extension Message {
///         // Ranges of special areas in the `content` text. Calculated when
///         // `content` is set and then cached so that we don't have to
///         // re-compute them.
///         var headingRanges: [Range<String.Index>]
///     }
///
///     struct MessageContentView: View {
///         TextEditor(.constant(message.content))
///             .accessibilityRotor(
///                 .heading,
///                 textRanges: message.headingRanges
///             )
///     }
///
/// - Parameters:
///   - systemRotor: The system-provided Rotor that will be overridden
///     by this custom Rotor.
///   - textRanges: An array of ranges that will be used to generate
///     the entries of the Rotor.
public func accessibilityRotor(_ systemRotor: AccessibilitySystemRotor, textRanges: [Range<String.Index>]) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Create an Accessibility Rotor with the specified user-visible label,
/// and entries generated from the content closure.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs") {
///         // Not all the MessageViews are generated at once, the model
///         // knows about all the messages.
///         ForEach(messages) { message in
///             // If the Message is from a VIP, make a Rotor entry for it.
///             if message.isVIP {
///                 AccessibilityRotorEntry(message.subject, id: message.id)
///             }
///         }
///     }
///
/// - Parameters:
///   - labelKey: Localized label identifying this Rotor to the user.
///   - entries: Content used to generate Rotor entries. This can
///     include AccessibilityRotorEntry structs, as well as constructs such
///     as if and ForEach.
public func accessibilityRotor<Content>(_ labelKey: LocalizedStringKey, @AccessibilityRotorContentBuilder entries: @escaping () -> Content) -> some View where Content : AccessibilityRotorContent
/// Create an Accessibility Rotor with the specified user-visible label,
/// and entries generated from the content closure.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs") {
///         // Not all the MessageViews are generated at once, the model
///         // knows about all the messages.
///         ForEach(messages) { message in
///             // If the Message is from a VIP, make a Rotor entry for it.
///             if message.isVIP {
///                 AccessibilityRotorEntry(message.subject, id: message.id)
///             }
///         }
///     }
///
/// - Parameters:
///   - label: Localized label identifying this Rotor to the user.
///   - entries: Content used to generate Rotor entries. This can
///     include AccessibilityRotorEntry structs, as well as constructs such
///     as if and ForEach.
public func accessibilityRotor<L, Content>(_ label: L, @AccessibilityRotorContentBuilder entries: @escaping () -> Content) -> some View where L : StringProtocol, Content : AccessibilityRotorContent
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s that have a
///     // `subject`.
///     // `vipMessages` is a filtered version of that list containing only
///     // messages from VIPs.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages,
///         entryLabel: \.subject)
///
/// - Parameters:
///   - rotorLabelKey: Localized label identifying this Rotor to the user.
///   - entries: An array of identifiable values that will be
///     used to generate the entries of the Rotor. The identifiers
///     of the `Identifiable` values must match up with identifiers in a
///     `ForEach` or explicit `id` calls within the `ScrollView`.
///     When the user navigates to entries from this Rotor, SwiftUI will
///     automatically scroll them into place as needed.
///   - entryLabel: Key path on the `Identifiable` type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel>(_ rotorLabelKey: LocalizedStringKey, entries: [EntryModel], entryLabel: KeyPath<EntryModel, String>) -> some View where EntryModel : Identifiable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Identifiable` `Message`s that have a
///     // `subject`.
///     // `vipMesages` is a filtered version of that list containing only
///     // messages from VIPs.
///
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages, label: \.subject)
///
/// - Parameters:
///   - rotorLabel: Localized label identifying this Rotor to the user.
///   - entries: An array of identifiable values that will be
///     used to generate the entries of the Rotor. The identifiers
///     of the `Identifiable` values must match up with identifiers in a
///     `ForEach` or explicit `id` calls within the `ScrollView`.
///     When the user navigates to entries from this Rotor, SwiftUI will
///     automatically scroll them into place as needed.
///   - entry: Key path on the `Identifiable` type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<L, EntryModel>(_ rotorLabel: L, entries: [EntryModel], entryLabel: KeyPath<EntryModel, String>) -> some View where L : StringProtocol, EntryModel : Identifiable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires that the Rotor be attached to a
/// `ScrollView`, or an Accessibility Element directly within a
/// `ScrollView`, such as a `ForEach`. When the user navigates to entries
/// from this Rotor, SwiftUI will automatically scroll them into place as
/// needed.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///
///     // `messages` is a list of `Message`s that have a `subject` and a
///     // `uuid`. `vipMesages` is a filtered version of that list
///     // containing only messages from VIPs.
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages,
///         entryID: \.uuid, entryLabel: \.subject)
///
/// - Parameters:
///   - labelKey: Localized label identifying this Rotor to the user.
///   - entries: An array of values that will be used to generate
///     the entries of the Rotor.
///   - entryID: Key path on the entry type that can be used
///     to generate an identifier for the Entry. The identifiers
///     must match up with identifiers in `ForEach` or explicit `id` calls
///     within the `ScrollView`.
///   - entryLabel: Key path on the entry type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<EntryModel, ID>(_ rotorLabelKey: LocalizedStringKey, entries: [EntryModel], entryID: KeyPath<EntryModel, ID>, entryLabel: KeyPath<EntryModel, String>) -> some View where ID : Hashable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// Using this modifier requires
/// that the Rotor be attached to a `ScrollView`, or an Accessibility
/// Element directly within a `ScrollView`, such as a `ForEach`.
/// When the user navigates to entries from this Rotor, SwiftUI will
/// automatically scroll them into place as needed.
///
/// In the following example, a Message application creates a Rotor
/// allowing users to navigate to specifically the messages originating from
/// VIPs.
///     // `messages` is a list of `Message`s that have a `subject` and a
///     // `uuid`. `vipMessages` is a filtered version of that list
///     // containing only messages from VIPs.
///     ScrollView {
///         LazyVStack {
///             ForEach(messages) { message in
///                 MessageView(message)
///             }
///         }
///     }
///     .accessibilityElement(children: .contain)
///     .accessibilityRotor("VIPs", entries: vipMessages,
///         id: \.uuid, label: \.subject)
///
/// - Parameters:
///   - rotorLabel: Localized label identifying this Rotor to the user.
///   - entries: An array of values that will be used to generate
///     the entries of the Rotor.
///   - entryID: Key path on the entry type that can be used
///     to generate an identifier for the Entry. The identifiers
///     must match up with identifiers in `ForEach` or explicit `id` calls
///     within the `ScrollView`.
///   - entryLabel: Key path on the entry type that can be
///     used to get a user-visible label for every Rotor entry. This is used
///     on macOS when the user opens the list of entries for the Rotor.
public func accessibilityRotor<L, EntryModel, ID>(_ rotorLabel: L, entries: [EntryModel], entryID: KeyPath<EntryModel, ID>, entryLabel: KeyPath<EntryModel, String>) -> some View where L : StringProtocol, ID : Hashable
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries for each of the specified ranges. The Rotor will be attached
/// to the current Accessibility element, and each entry will go the
/// specified range of that element.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application adds a Rotor allowing
/// the user to navigate through all the ranges of text containing
/// email addresses.
///
///     extension Message {
///         // Ranges of special areas in the `content` text. Calculated
///         // when `content` is set and then cached so that we don't have
///         // to re-compute them.
///         var emailAddressRanges: [Range<String.Index>]
///     }
///
///     struct MessageContentView: View {
///         TextEditor(.constant(message.content))
///             .accessibilityRotor("Email Addresses",
///                 textRanges: message.emailAddressRanges)
///     }
///
/// - Parameters:
///   - labelKey: Localized label identifying this Rotor to the user.
///   - textRanges: An array of ranges that will be used to generate
///     the entries of the Rotor.
public func accessibilityRotor(_ labelKey: LocalizedStringKey, textRanges: [Range<String.Index>]) -> some View
/// Create an Accessibility Rotor with the specified user-visible label
/// and entries for each of the specified ranges. The Rotor will be attached
/// to the current Accessibility element, and each entry will go the
/// specified range of that element.
///
/// An Accessibility Rotor is a shortcut for Accessibility users to
/// quickly navigate to specific elements of the user interface,
/// and optionally specific ranges of text within those elements.
///
/// In the following example, a Message application adds a Rotor allowing
/// the user to navigate through all the ranges of text containing
/// email addresses.
///
///     extension Message {
///         // Ranges of special areas in the `content` text. Calculated
///         // when `content` is set and then cached so that we don't have
///         // to re-compute them.
///         var emailAddressRanges: [Range<String.Index>]
///     }
///
///     struct MessageContentView: View {
///         TextEditor(.constant(message.content))
///             .accessibilityRotor("Email Addresses",
///                 textRanges: message.emailAddressRanges)
///     }
///
/// - Parameters:
///   - label: Localized label identifying this Rotor to the user.
///   - textRanges: An array of ranges that will be used to generate
///     the entries of the Rotor.
public func accessibilityRotor<L>(_ label: L, textRanges: [Range<String.Index>]) -> some View where L : StringProtocol
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets the style for forms in a view hierarchy.
///
/// - Parameter style: The form style to set.
/// - Returns: A view that uses the specified form style for itself
///   and its child views.
public func formStyle<S>(_ style: S) -> some View where S : FormStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View where Self : Equatable {
/// Prevents the view from updating its child view when its new value is the
/// same as its old value.
@inlinable public func equatable() -> EquatableView<Self>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets a view's foreground elements to use a given style.
///
/// Use this method to style
/// foreground content like text, shapes, and template images
/// (including symbols):
///
///     HStack {
///         Image(systemName: "triangle.fill")
///         Text("Hello, world!")
///         RoundedRectangle(cornerRadius: 5)
///             .frame(width: 40, height: 20)
///     }
///     .foregroundStyle(.teal)
///
/// The example above creates a row of ``ShapeStyle/teal`` foreground
/// elements:
///
/// ![A screenshot of a teal triangle, string, and rounded
/// rectangle.](View-foregroundStyle-1)
///
/// You can use any style that conforms to the ``ShapeStyle`` protocol,
/// like the ``ShapeStyle/teal`` color in the example above, or the
/// ``ShapeStyle/linearGradient(colors:startPoint:endPoint:)`` gradient
/// shown below:
///
///     Text("Gradient Text")
///         .font(.largeTitle)
///         .foregroundStyle(
///             .linearGradient(
///                 colors: [.yellow, .blue],
///                 startPoint: .top,
///                 endPoint: .bottom
///             )
///         )
///
/// ![A screenshot of the words Gradient Text, with letters that
///   appear yellow at the top, and transition to blue
///   toward the bottom.](View-foregroundStyle-2)
///
/// > Tip: If you want to fill a single ``Shape`` instance with a style,
/// use the ``Shape/fill(style:)`` shape modifier instead because it's more
/// efficient.
///
/// SwiftUI creates a context-dependent render for a given style.
/// For example, a ``Color`` that you load from an asset catalog
/// can have different light and dark appearances, while some styles
/// also vary by platform.
///
/// Hierarchical foreground styles like ``ShapeStyle/secondary``
/// don't impose a style of their own, but instead modify other styles.
/// In particular, they modify the primary
/// level of the current foreground style to the degree given by
/// the hierarchical style's name.
/// To find the current foreground style to modify, SwiftUI looks for
/// the innermost containing style that you apply with the
/// `foregroundStyle(_:)` or the ``View/foregroundColor(_:)`` modifier.
/// If you haven't specified a style, SwiftUI uses the default foreground
/// style, as in the following example:
///
///     VStack(alignment: .leading) {
///         Label("Primary", systemImage: "1.square.fill")
///         Label("Secondary", systemImage: "2.square.fill")
///             .foregroundStyle(.secondary)
///     }
///
/// ![A screenshot of two labels with the text primary and secondary.
/// The first appears in a brighter shade than the
/// second, both in a grayscale color.](View-foregroundStyle-3)
///
/// If you add a foreground style on the enclosing
/// ``VStack``, the hierarchical styling responds accordingly:
///
///     VStack(alignment: .leading) {
///         Label("Primary", systemImage: "1.square.fill")
///         Label("Secondary", systemImage: "2.square.fill")
///             .foregroundStyle(.secondary)
///     }
///     .foregroundStyle(.blue)
///
/// ![A screenshot of two labels with the text primary and secondary.
/// The first appears in a brighter shade than the
/// second, both tinted blue.](View-foregroundStyle-4)
///
/// When you apply a custom style to a view, the view disables the vibrancy
/// effect for foreground elements in that view, or in any of its child
/// views, that it would otherwise gain from adding a background material
/// --- for example, using the ``View/background(_:ignoresSafeAreaEdges:)``
/// modifier. However, hierarchical styles applied to the default foreground
/// don't disable vibrancy.
///
/// - Parameter style: The color or pattern to use when filling in the
///   foreground elements. To indicate a specific value, use ``Color`` or
///   ``ShapeStyle/image(_:sourceRect:scale:)``, or one of the gradient
///   types, like
///   ``ShapeStyle/linearGradient(colors:startPoint:endPoint:)``. To set a
///   style that’s relative to the containing view's style, use one of the
///   semantic styles, like ``ShapeStyle/primary``.
///
/// - Returns: A view that uses the given foreground style.
@inlinable public func foregroundStyle<S>(_ style: S) -> some View where S : ShapeStyle
/// Sets the primary and secondary levels of the foreground
/// style in the child view.
///
/// SwiftUI uses these styles when rendering child views
/// that don't have an explicit rendering style, like images,
/// text, shapes, and so on.
///
/// Symbol images within the view hierarchy use the
/// ``SymbolRenderingMode/palette`` rendering mode when you apply this
/// modifier, if you don't explicitly specify another mode.
///
/// - Parameters:
///   - primary: The primary color or pattern to use when filling in
///     the foreground elements. To indicate a specific value, use ``Color``
///     or ``ShapeStyle/image(_:sourceRect:scale:)``, or one of the gradient
///     types, like
///     ``ShapeStyle/linearGradient(colors:startPoint:endPoint:)``. To set a
///     style that’s relative to the containing view's style, use one of the
///     semantic styles, like ``ShapeStyle/primary``.
///   - secondary: The secondary color or pattern to use when
///     filling in the foreground elements.
///
/// - Returns: A view that uses the given foreground styles.
@inlinable public func foregroundStyle<S1, S2>(_ primary: S1, _ secondary: S2) -> some View where S1 : ShapeStyle, S2 : ShapeStyle
/// Sets the primary, secondary, and tertiary levels of
/// the foreground style.
///
/// SwiftUI uses these styles when rendering child views
/// that don't have an explicit rendering style, like images,
/// text, shapes, and so on.
///
/// Symbol images within the view hierarchy use the
/// ``SymbolRenderingMode/palette`` rendering mode when you apply this
/// modifier, if you don't explicitly specify another mode.
///
/// - Parameters:
///   - primary: The primary color or pattern to use when filling in
///     the foreground elements. To indicate a specific value, use ``Color``
///     or ``ShapeStyle/image(_:sourceRect:scale:)``, or one of the gradient
///     types, like
///     ``ShapeStyle/linearGradient(colors:startPoint:endPoint:)``. To set a
///     style that’s relative to the containing view's style, use one of the
///     semantic styles, like ``ShapeStyle/primary``.
///   - secondary: The secondary color or pattern to use when
///     filling in the foreground elements.
///   - tertiary: The tertiary color or pattern to use when
///     filling in the foreground elements.
///
/// - Returns: A view that uses the given foreground styles.
@inlinable public func foregroundStyle<S1, S2, S3>(_ primary: S1, _ secondary: S2, _ tertiary: S3) -> some View where S1 : ShapeStyle, S2 : ShapeStyle, S3 : ShapeStyle
}
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@available(tvOS, unavailable)
extension View {
/// Adds custom swipe actions to a row in a list.
///
/// Use this method to add swipe actions to a view that acts as a row in a
/// list. Indicate the ``HorizontalEdge`` where the swipe action
/// originates, and define individual actions with ``Button`` instances.
/// For example, if you have a list of messages,
/// you can add an action to toggle a message as unread
/// on a swipe from the leading edge,
/// and actions to delete or flag messages on a trailing edge swipe:
///
///     List {
///         ForEach(store.messages) { message in
///             MessageCell(message: message)
///                 .swipeActions(edge: .leading) {
///                     Button { store.toggleUnread(message) } label: {
///                         if message.isUnread {
///                             Label("Read", systemImage: "envelope.open")
///                         } else {
///                             Label("Unread", systemImage: "envelope.badge")
///                         }
///                     }
///                 }
///                 .swipeActions(edge: .trailing) {
///                     Button(role: .destructive) {
///                         store.delete(message)
///                     } label: {
///                         Label("Delete", systemImage: "trash")
///                     }
///                     Button { store.flag(message) } label: {
///                         Label("Flag", systemImage: "flag")
///                     }
///                 }
///             }
///         }
///     }
///
/// Actions appear in the order you list them, starting from the swipe's
/// originating edge. In the example above, the Delete action appears
/// closest to the screen's trailing edge:
///
/// ![A screenshot of a list of messages, where one of the messages has been
///   swiped from the trailing edge, revealing a Flag and Delete button.
///   The Flag button is grey, while the Delete button is
///   red.](View-swipeActions-1)
///
/// For labels or images that appear in swipe actions, SwiftUI automatically
/// applies the ``SymbolVariants/fill-swift.type.property`` symbol variant,
/// as shown above.
///
/// By default, the user can perform the first action for a given swipe
/// direction with a full swipe. For the example above, the user can perform
/// both the toggle unread and delete actions with full swipes.
/// You can opt out of this behavior for an edge by setting
/// the `allowsFullSwipe` parameter to `false`. For example, you can
/// disable the full swipe on the leading edge:
///
///     .swipeActions(edge: .leading, allowsFullSwipe: false) {
///         Button { store.toggleUnread(message) } label: {
///             if message.isUnread {
///                 Label("Read", systemImage: "envelope.open")
///             } else {
///                 Label("Unread", systemImage: "envelope.badge")
///             }
///         }
///     }
///
/// When you set a role for a button using one of the values from the
/// ``ButtonRole`` enumeration, SwiftUI styles the button according to
/// its role. In the example above, the delete action appears in
/// ``ShapeStyle/red`` because it has the ``ButtonRole/destructive`` role.
/// If you want to set a different color — for example, to match the
/// overall theme of your app's UI — add the ``View/tint(_:)``
/// modifier to the button:
///
///     MessageCell(message: message)
///         .swipeActions(edge: .leading) {
///             Button { store.toggleUnread(message) } label: {
///                 if message.isUnread {
///                     Label("Read", systemImage: "envelope.open")
///                 } else {
///                     Label("Unread", systemImage: "envelope.badge")
///                 }
///             }
///             .tint(.blue)
///         }
///         .swipeActions(edge: .trailing) {
///             Button(role: .destructive) { store.delete(message) } label: {
///                 Label("Delete", systemImage: "trash")
///             }
///             Button { store.flag(message) } label: {
///                 Label("Flag", systemImage: "flag")
///             }
///             .tint(.orange)
///         }
///
/// The modifications in the code above make the toggle unread action
/// ``ShapeStyle/blue`` and the flag action ``ShapeStyle/orange``:
///
/// ![A screenshot of a row that the user swiped from the leading edge
///   to reveal a blue Unread button, and another screenshot of the same
///   row after the user swiped from the trailing edge to reveal an
///   orange Flag button and a red Delete button.](View-swipeActions-2)
///
/// When you add swipe actions, SwiftUI no longer synthesizes the Delete
/// actions that otherwise appear when using the
/// ``ForEach/onDelete(perform:)`` method on a ``ForEach`` instance.
/// You become responsible for creating a Delete
/// action, if appropriate, among your swipe actions.
///
/// Actions accumulate for a given edge if you call the modifier multiple
/// times on the same list row view.
///
/// - Parameters:
///     - edge: The edge of the view to associate the swipe actions with.
///         The default is ``HorizontalEdge/trailing``.
///     - allowsFullSwipe: A Boolean value that indicates whether a full swipe
///         automatically performs the first action. The default is `true`.
///     - content: The content of the swipe actions.
public func swipeActions<T>(edge: HorizontalEdge = .trailing, allowsFullSwipe: Bool = true, @ViewBuilder content: () -> T) -> some View where T : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a condition for whether the view's view hierarchy is deletable.
@inlinable public func deleteDisabled(_ isDisabled: Bool) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets whether this view should ignore the system Smart Invert setting.
///
/// Use this modifier to suppress Smart Invert in a view that shouldn't
/// be inverted. Or pass an `active` argument of `false` to begin following
/// the Smart Invert setting again when it was previously disabled.
///
/// - Parameter active: A true value ignores the system Smart Invert
///   setting. A false value follows the system setting.
@inlinable public func accessibilityIgnoresInvertColors(_ active: Bool = true) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the Dynamic Type size within the view to the given value.
///
/// As an example, you can set a Dynamic Type size in `ContentView` to be
/// ``DynamicTypeSize/xLarge`` (this can be useful in previews to see your
/// content at a different size) like this:
///
///     ContentView()
///         .dynamicTypeSize(.xLarge)
///
/// If a Dynamic Type size range is applied after setting a value,
/// the value is limited by that range:
///
///     ContentView() // Dynamic Type size will be .large
///         .dynamicTypeSize(...DynamicTypeSize.large)
///         .dynamicTypeSize(.xLarge)
///
/// When limiting the Dynamic Type size, consider if adding a
/// large content view with ``View/accessibilityShowsLargeContentViewer()``
/// would be appropriate.
///
/// - Parameter size: The size to set for this view.
///
/// - Returns: A view that sets the Dynamic Type size to the specified
///   `size`.
public func dynamicTypeSize(_ size: DynamicTypeSize) -> some View
/// Limits the Dynamic Type size within the view to the given range.
///
/// As an example, you can constrain the maximum Dynamic Type size in
/// `ContentView` to be no larger than ``DynamicTypeSize/large``:
///
///     ContentView()
///         .dynamicTypeSize(...DynamicTypeSize.large)
///
/// If the Dynamic Type size is limited to multiple ranges, the result is
/// their intersection:
///
///     ContentView() // Dynamic Type sizes are from .small to .large
///         .dynamicTypeSize(.small...)
///         .dynamicTypeSize(...DynamicTypeSize.large)
///
/// A specific Dynamic Type size can still be set after a range is applied:
///
///     ContentView() // Dynamic Type size is .xLarge
///         .dynamicTypeSize(.xLarge)
///         .dynamicTypeSize(...DynamicTypeSize.large)
///
/// When limiting the Dynamic Type size, consider if adding a
/// large content view with ``View/accessibilityShowsLargeContentViewer()``
/// would be appropriate.
///
/// - Parameter range: The range of sizes that are allowed in this view.
///
/// - Returns: A view that constrains the Dynamic Type size of this view
///   within the specified `range`.
public func dynamicTypeSize<T>(_ range: T) -> some View where T : RangeExpression, T.Bound == DynamicTypeSize
}
extension View {
/// Applies an underline to the text in this view.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether underline
///     is added. The default value is `true`.
///   - pattern: The pattern of the line. The default value is `solid`.
///   - color: The color of the underline. If `color` is `nil`, the
///     underline uses the default foreground color.
///
/// - Returns: A view where text has a line running along its baseline.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func underline(_ isActive: Bool = true, pattern: Text.LineStyle.Pattern = .solid, color: Color? = nil) -> some View
/// Applies a strikethrough to the text in this view.
///
/// - Parameters:
///   - isActive: A Boolean value that indicates whether
///     strikethrough is added. The default value is `true`.
///   - pattern: The pattern of the line. The default value is `solid`.
///   - color: The color of the strikethrough. If `color` is `nil`, the
///     strikethrough uses the default foreground color.
///
/// - Returns: A view where text has a line through its center.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func strikethrough(_ isActive: Bool = true, pattern: Text.LineStyle.Pattern = .solid, color: Color? = nil) -> some View
}
extension View {
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The transferable content associated to the
///     navigation title.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
public func navigationDocument<D>(_ document: D) -> some View where D : Transferable
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The transferable content associated to the
///     navigation title.
///   - preview: The preview of the document to use when sharing.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public func navigationDocument<D>(_ document: D, preview: SharePreview<Never, Never>) -> some View where D : Transferable
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The transferable content associated to the
///     navigation title.
///   - preview: The preview of the document to use when sharing.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public func navigationDocument<D, I>(_ document: D, preview: SharePreview<Never, I>) -> some View where D : Transferable, I : Transferable
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The transferable content associated to the
///     navigation title.
///   - preview: The preview of the document to use when sharing.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public func navigationDocument<D, I>(_ document: D, preview: SharePreview<I, Never>) -> some View where D : Transferable, I : Transferable
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The transferable content associated to the
///     navigation title.
///   - preview: The preview of the document to use when sharing.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public func navigationDocument<D, I1, I2>(_ document: D, preview: SharePreview<I1, I2>) -> some View where D : Transferable, I1 : Transferable, I2 : Transferable
}
extension View {
/// Configures the view's document for purposes of navigation.
///
/// In iOS, iPadOS, this populates the title menu with a header
/// previewing the document. In macOS, this populates a proxy icon.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation document modifiers.
///
/// - Parameters:
///   - document: The URL content associated to the
///     navigation title.
///   - preview: The preview of the document to use when sharing.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
public func navigationDocument(_ url: URL) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Uses the string you specify to identify the view.
///
/// Use this value for testing. It isn't visible to the user.
public func accessibilityIdentifier(_ identifier: String) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the vertical spacing between two adjacent rows in a List.
///
/// The following example creates a List with 10 pts of spacing between each
/// row:
///
///     List {
///         Text("Blue")
///         Text("Red")
///     }
///     .listRowSpacing(10.0)
///
/// - Parameter spacing: The spacing value to use. A value of `nil` uses
///   the default spacing.
@inlinable public func listRowSpacing(_ spacing: CGFloat?) -> some View
}
extension View {
/// Remove a toolbar item present by default
///
/// Use this modifier to remove toolbar items other `View`s add
/// by default. For example, to remove the sidebar toggle toolbar
/// item provided by `NavigationSplitView`:
///
///     NavigationSplitView {
///         SidebarView()
///             .toolbar(removing: .sidebarToggle)
///     } detail: {
///         DetailView()
///     }
///
/// - Parameters:
///   - defaultItemKind: The kind of default item to remove
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func toolbar(removing defaultItemKind: ToolbarDefaultItemKind?) -> some View
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *)
extension View {
/// Adds an action to perform when this view recognizes a long press
/// gesture.
///
/// - Parameters:
///     - minimumDuration: The minimum duration of the long press that must
///     elapse before the gesture succeeds.
///     - maximumDistance: The maximum distance that the fingers or cursor
///     performing the long press can move before the gesture fails.
///     - action: The action to perform when a long press is recognized.
///     - onPressingChanged:  A closure to run when the pressing state of the
///     gesture changes, passing the current state as a parameter.
@available(tvOS, unavailable)
public func onLongPressGesture(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10, perform action: @escaping () -> Void, onPressingChanged: ((Bool) -> Void)? = nil) -> some View
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *)
extension View {
/// Adds an action to perform when this view recognizes a long press
/// gesture.
@available(iOS, deprecated: 100000.0, renamed: "onLongPressGesture(minimumDuration:maximumDuration:perform:onPressingChanged:)")
@available(macOS, deprecated: 100000.0, renamed: "onLongPressGesture(minimumDuration:maximumDuration:perform:onPressingChanged:)")
@available(tvOS, unavailable)
@available(watchOS, deprecated: 100000.0, renamed: "onLongPressGesture(minimumDuration:maximumDuration:perform:onPressingChanged:)")
@available(visionOS, deprecated: 100000.0, renamed: "onLongPressGesture(minimumDuration:maximumDuration:perform:onPressingChanged:)")
public func onLongPressGesture(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10, pressing: ((Bool) -> Void)? = nil, perform action: @escaping () -> Void) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents a confirmation dialog when a given condition is true, using a
/// localized string key for the title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 "Permanently erase the items in the Trash?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are ``Text``. Passing any other type of view results in
/// the content being omitted.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
public func confirmationDialog<A>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A) -> some View where A : View
/// Presents a confirmation dialog when a given condition is true, using a
/// string variable as a title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var title: String
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 title,
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// - Parameters:
///   - title: A text string used as the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
public func confirmationDialog<S, A>(_ title: S, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A) -> some View where S : StringProtocol, A : View
/// Presents a confirmation dialog when a given condition is true, using a
/// text view for the title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 Text("Permanently erase the items in the trash?"),
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// - Parameters:
///   - title: the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
public func confirmationDialog<A>(_ title: Text, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A) -> some View where A : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents a confirmation dialog with a message when a given condition is
/// true, using a localized string key for the title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 "Permanently erase the items in the Trash?",
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///             } message: {
///                 Text("You cannot undo this action.")
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
///   - message: A view builder returning the message for the dialog.
public func confirmationDialog<A, M>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where A : View, M : View
/// Presents a confirmation dialog with a message when a given condition is
/// true, using a string variable for the title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var title: String
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 title,
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///                 Button("Cancel", role: .cancel) {
///                     isShowingDialog = false
///                 }
///             } message: {
///                 Text("You cannot undo this action.")
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// - Parameters:
///   - title: A text string used as the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether to
///     present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
///   - message: A view builder returning the message for the dialog.
public func confirmationDialog<S, A, M>(_ title: S, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where S : StringProtocol, A : View, M : View
/// Presents a confirmation dialog with a message when a given condition is
/// true, using a text view for the title.
///
/// In the example below, a button conditionally presents a confirmation
/// dialog depending upon the value of a bound Boolean variable. When the
/// Boolean value is set to `true`, the system displays a confirmation
/// dialog with a cancel action and a destructive action.
///
///     struct ConfirmEraseItems: View {
///         @State private var isShowingDialog = false
///         var body: some View {
///             Button("Empty Trash") {
///                 isShowingDialog = true
///             }
///             .confirmationDialog(
///                 Text("Permanently erase the items in the trash?"),
///                 isPresented: $isShowingDialog
///             ) {
///                 Button("Empty Trash", role: .destructive) {
///                     // Handle empty trash action.
///                 }
///             } message: {
///                 Text("You cannot undo this action.")
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// - Parameters:
///   - title: the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - actions: A view builder returning the dialog's actions.
///   - message: A view builder returning the message for the dialog.
public func confirmationDialog<A, M>(_ title: Text, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, @ViewBuilder actions: () -> A, @ViewBuilder message: () -> M) -> some View where A : View, M : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents a confirmation dialog using data to produce the dialog's
/// content and a localized string key for the title.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 "Are you sure you want to import this file?",
///                 isPresented: $isConfirming, presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("""
///                     Import \(detail.name)
///                     File Type: \(detail.fileType.description)
///                     """)
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             }
///         }
///     }
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
public func confirmationDialog<A, T>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where A : View
/// Presents a confirmation dialog using data to produce the dialog's
/// content and a string variable for the title.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         var title: String
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 title, isPresented: $isConfirming,
///                 presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("""
///                     Import \(detail.name)
///                     File Type: \(detail.fileType.description)
///                     """)
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - title: A text string used as the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
public func confirmationDialog<S, A, T>(_ title: S, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where S : StringProtocol, A : View
/// Presents a confirmation dialog using data to produce the dialog's
/// content and a text view for the title.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 Text("Import New File?"),
///                 isPresented: $isConfirming, presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("""
///                     Import \(detail.name)
///                     File Type: \(detail.fileType.description)
///                     """)
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - title: the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
public func confirmationDialog<A, T>(_ title: Text, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A) -> some View where A : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Presents a confirmation dialog with a message using data to produce the
/// dialog's content and a localized string key for the title.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 "Are you sure you want to import this file?",
///                 isPresented: $isConfirming, presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("Import \(detail.name)")
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             } message: { detail in
///                 Text(
///                     """
///                     This will add \(detail.name).\(detail.fileType) \
///                     to your library.
///                     """)
///             }
///         }
///     }
///
/// This modifier creates a ``Text`` view for the title on your behalf, and
/// treats the localized key similar to
/// ``Text/init(_:tableName:bundle:comment:)``. See ``Text`` for more
/// information about localizing strings.
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - titleKey: The key for the localized string that describes the title
///     of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
///   - message: A view builder returning the message for the dialog given
///     the currently available data.
public func confirmationDialog<A, M, T>(_ titleKey: LocalizedStringKey, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where A : View, M : View
/// Presents a confirmation dialog with a message using data to produce the
/// dialog's content and a string variable for the title.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         var title: String
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 title, isPresented: $isConfirming,
///                 presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("Import \(detail.name)")
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             } message: { detail in
///                 Text(
///                     """
///                     This will add \(detail.name).\(detail.fileType) \
///                     to your library.
///                     """)
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - title: A text string used as the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
///   - message: A view builder returning the message for the dialog given
///     the currently available data.
public func confirmationDialog<S, A, M, T>(_ title: S, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where S : StringProtocol, A : View, M : View
/// Presents a confirmation dialog with a message using data to produce the
/// dialog's content and a text view for the message.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `data` must not be `nil`. `data` should not change after the
/// presentation occurs. Any changes which occur after the presentation
/// occurs will be ignored.
///
/// Use this method when you need to populate the fields of a confirmation
/// dialog with content from a data source. The example below shows a custom
/// data source, `FileDetails`, that provides data to populate the dialog:
///
///     struct FileDetails: Identifiable {
///         var id: String { name }
///         let name: String
///         let fileType: UTType
///     }
///     struct ConfirmFileImport: View {
///         @State private var isConfirming = false
///         @State private var dialogDetail: FileDetails?
///         var body: some View {
///             Button("Import File") {
///                 dialogDetail = FileDetails(
///                     name: "MyImageFile.png", fileType: .png)
///                 isConfirming = true
///             }
///             .confirmationDialog(
///                 Text("Import New File?"),
///                 isPresented: $isConfirming, presenting: dialogDetail
///             ) { detail in
///                 Button {
///                     // Handle import action.
///                 } label: {
///                     Text("Import \(detail.name)")
///                 }
///                 Button("Cancel", role: .cancel) {
///                     dialogDetail = nil
///                 }
///             } message: { detail in
///                 Text(
///                     """
///                     This will add \(detail.name).\(detail.fileType) \
///                     to your library.
///                     """)
///             }
///         }
///     }
///
/// All actions in a confirmation dialog will dismiss the dialog after the
/// action runs. The default button will be shown with greater prominence.
/// You can influence the default button by assigning it the
/// ``KeyboardShortcut/defaultAction`` keyboard shortcut.
///
/// The system may reorder the buttons based on their role and prominence.
///
/// Dialogs include a standard dismiss action by default. If you provide a
/// button with a role of ``ButtonRole/cancel``, that button takes the place
/// of the default dismiss action. You don't have to dismiss the
/// presentation with the cancel button's action.
///
/// > Note: In regular size classes in iOS, the system renders confirmation
/// dialogs as a popover that the user dismisses by tapping anywhere outside
/// the popover, rather than displaying the standard dismiss action.
///
/// On iOS, tvOS, and watchOS, confirmation dialogs only support controls
/// with labels that are `Text`. Passing any other type of view results in
/// the content being omitted.
///
/// - Parameters:
///   - title: the title of the dialog.
///   - isPresented: A binding to a Boolean value that determines whether
///     to present the dialog. When the user presses or taps the dialog's
///     default action button, the system sets this value to `false`,
///     dismissing the dialog.
///   - titleVisibility: The visibility of the dialog's title. The default
///     value is ``Visibility/automatic``.
///   - data: An optional source of truth for the confirmation dialog. The
///     system passes the contents to the modifier's closures. You use this
///     data to populate the fields of a confirmation dialog that you create
///     that the system displays to the user.
///   - actions: A view builder returning the dialog's actions given the
///     currently available data.
///   - message: A view builder returning the message for the dialog given
///     the currently available data.
public func confirmationDialog<A, M, T>(_ title: Text, isPresented: Binding<Bool>, titleVisibility: Visibility = .automatic, presenting data: T?, @ViewBuilder actions: (T) -> A, @ViewBuilder message: (T) -> M) -> some View where A : View, M : View
}
extension View {
/// Changes the view's proposed area to extend outside the screen's safe
/// areas.
///
/// Use `edgesIgnoringSafeArea(_:)` to change the area proposed for this
/// view so that — were the proposal accepted — this view could extend
/// outside the safe area to the bounds of the screen for the specified
/// edges.
///
/// For example, you can propose that a text view ignore the safe area's top
/// inset:
///
///     VStack {
///         Text("This text is outside of the top safe area.")
///             .edgesIgnoringSafeArea([.top])
///             .border(Color.purple)
///         Text("This text is inside VStack.")
///             .border(Color.yellow)
///     }
///     .border(Color.gray)
///
/// ![A screenshot showing a view whose bounds exceed the safe area of the
/// screen.](SwiftUI-View-edgesIgnoringSafeArea.png)
///
/// Depending on the surrounding view hierarchy, SwiftUI may not honor an
/// `edgesIgnoringSafeArea(_:)` request. This can happen, for example, if
/// the view is inside a container that respects the screen's safe area. In
/// that case you may need to apply `edgesIgnoringSafeArea(_:)` to the
/// container instead.
///
/// - Parameter edges: The set of the edges in which to expand the size
///   requested for this view.
///
/// - Returns: A view that may extend outside of the screen's safe area
///   on the edges specified by `edges`.
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")
@inlinable public func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Expands the view out of its safe area.
///
/// - Parameters:
///   - regions: the kinds of rectangles removed from the safe area
///     that should be ignored (i.e. added back to the safe area
///     of the new child view).
///   - edges: the edges of the view that may be outset, any edges
///     not in this set will be unchanged, even if that edge is
///     abutting a safe area listed in `regions`.
///
/// - Returns: a new view with its safe area expanded.
///
@inlinable public func ignoresSafeArea(_ regions: SafeAreaRegions = .all, edges: Edge.Set = .all) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Tells a view that acts as a cell in a grid to span the specified
/// number of columns.
///
/// By default, each view that you put into the content closure of a
/// ``GridRow`` corresponds to exactly one column of the grid. Apply the
/// `gridCellColumns(_:)` modifier to a view that you want to span more
/// than one column, as in the following example of a typical macOS
/// configuration view:
///
///     Grid(alignment: .leadingFirstTextBaseline) {
///         GridRow {
///             Text("Regular font:")
///                 .gridColumnAlignment(.trailing)
///             Text("Helvetica 12")
///             Button("Select...") { }
///         }
///         GridRow {
///             Text("Fixed-width font:")
///             Text("Menlo Regular 11")
///             Button("Select...") { }
///         }
///         GridRow {
///             Color.clear
///                 .gridCellUnsizedAxes([.vertical, .horizontal])
///             Toggle("Use fixed-width font for new documents", isOn: $isOn)
///                 .gridCellColumns(2) // Span two columns.
///         }
///     }
///
/// The ``Toggle`` in the example above spans the column that contains
/// the font names and the column that contains the buttons:
///
/// ![A screenshot of a configuration view, arranged in a grid. The grid
/// has three colums and three rows. Scanning from top to bottom, the
/// left-most column contains a cell with the text Regular font, a cell with
/// the text Fixed-width font, and a blank cell. The middle row contains
/// a cell with the text Helvetica 12, a cell with the text Menlo Regular
/// 11, and a cell with a labeled checkbox. The label says Use fixed-width
/// font for new documents. The label spans its own cell and the cell to
/// its right. The right-most column contains two cells with buttons
/// labeled Select. The last column's bottom cell is merged with the cell
/// from the middle columnn that holds the labeled
/// checkbox.](View-gridCellColumns-1-macOS)
///
/// > Important: When you tell a cell to span multiple columns, the grid
/// changes the merged cell to use anchor alignment, rather than the
/// usual alignment guides. For information about the behavior of
/// anchor alignment, see ``View/gridCellAnchor(_:)``.
///
/// As a convenience you can cause a view to span all of the ``Grid``
/// columns by placing the view directly in the content closure of the
/// ``Grid``, outside of a ``GridRow``, and omitting the modifier. To do
/// the opposite and include more than one view in a cell, group the views
/// using an appropriate layout container, like an ``HStack``, so that
/// they act as a single view.
///
/// - Parameters:
///   - count: The number of columns that the view should consume
///     when placed in a grid row.
///
/// - Returns: A view that occupies the specified number of columns in a
///   grid row.
@inlinable public func gridCellColumns(_ count: Int) -> some View
/// Specifies a custom alignment anchor for a view that acts as a grid cell.
///
/// Grids, like stacks and other layout containers, perform most alignment
/// operations using alignment guides. The grid moves the contents of each
/// cell in a row in the y direction until the specified
/// ``VerticalAlignment`` guide of each view in the row aligns with the same
/// guide of all the other views in the row. Similarly, the grid aligns the
/// ``HorizontalAlignment`` guides of views in a column by adjusting views
/// in the x direction. See the guide types for more information about
/// typical SwiftUI alignment operations.
///
/// When you use the `gridCellAnchor(_:)` modifier on a
/// view in a grid, the grid changes to an anchor-based alignment strategy
/// for the associated cell. With anchor alignment, the grid projects a
/// ``UnitPoint`` that you specify onto both the view and the cell, and
/// aligns the two projections. For example, consider the following grid:
///
///     Grid(horizontalSpacing: 1, verticalSpacing: 1) {
///         GridRow {
///             Color.red.frame(width: 60, height: 60)
///             Color.red.frame(width: 60, height: 60)
///         }
///         GridRow {
///             Color.red.frame(width: 60, height: 60)
///             Color.blue.frame(width: 10, height: 10)
///                 .gridCellAnchor(UnitPoint(x: 0.25, y: 0.75))
///         }
///     }
///
/// The grid creates red reference squares in the first row and column to
/// establish row and column sizes. Without the anchor modifier, the blue
/// marker in the remaining cell would appear at the center of its cell,
/// because of the grid's default ``Alignment/center`` alignment. With
/// the anchor modifier shown in the code above, the grid aligns the one
/// quarter point of the marker with the one quarter point of its cell in
/// the x direction, as measured from the origin at the top left of the
/// cell. The grid also aligns the three quarters point of the marker
/// with the three quarters point of the cell in the y direction:
///
/// ![A screenshot of a grid with two rows and two columns. The cells in
/// the top row and left-most column are each completely filled with a red
/// rectangle. The lower-right cell contains a small blue square that's
/// horizontally placed about one quarter of the way from the left to the
/// right, and about three quarters of the way from the top to the
/// bottom of the cell it occupies.](View-gridCellAnchor-1-iOS)
///
/// ``UnitPoint`` defines many convenience points that correspond to the
/// typical alignment guides, which you can use as well. For example, you
/// can use ``UnitPoint/topTrailing`` to align the top and trailing edges
/// of a view in a cell with the top and trailing edges of the cell:
///
///     Color.blue.frame(width: 10, height: 10)
///         .gridCellAnchor(.topTrailing)
///
/// ![A screenshot of a grid with two rows and two columns. The cells in
/// the top row and left-most column are each completely filled with a red
/// rectangle. The lower-right cell contains a small blue square that's
/// horizontally aligned with the trailing edge, and vertically aligned
/// with the top edge of the cell.](View-gridCellAnchor-2-iOS)
///
/// Applying the anchor-based alignment strategy to a single cell
/// doesn't affect the alignment strategy that the grid uses on other cells.
///
/// ### Anchor alignment for merged cells
///
/// If you use the ``View/gridCellColumns(_:)`` modifier to cause
/// a cell to span more than one column, or if you place a view in a grid
/// outside of a row so that the view spans the entire grid, the grid
/// automatically converts its vertical and horizontal alignment guides
/// to the unit point equivalent for the merged cell, and uses an
/// anchor-based approach for that cell. For example, the following grid
/// places the marker at the center of the merged cell by converting the
/// grid's default ``Alignment/center`` alignment guide to a
/// ``UnitPoint/center`` anchor for the blue marker in the merged cell:
///
///     Grid(alignment: .center, horizontalSpacing: 1, verticalSpacing: 1) {
///         GridRow {
///             Color.red.frame(width: 60, height: 60)
///             Color.red.frame(width: 60, height: 60)
///             Color.red.frame(width: 60, height: 60)
///         }
///         GridRow {
///             Color.red.frame(width: 60, height: 60)
///             Color.blue.frame(width: 10, height: 10)
///                 .gridCellColumns(2)
///         }
///     }
///
/// The grid makes this conversion in part to avoid ambiguity. Each column
/// has its own horizontal guide, and it isn't clear which of these
/// a cell that spans multiple columns should align with. Further, in
/// the example above, neither of the center alignment guides for the
/// second or third column would provide the expected behavior, which is
/// to center the marker in the merged cell. Anchor alignment provides
/// this behavior:
///
/// ![A screenshot of a grid with two rows and three columns. The cells in
/// the top row and left-most column are each completely filled with a red
/// rectangle. The other two cells are meged into a single cell that
/// contains a small blue square that's centered in the merged
/// cell.](View-gridCellAnchor-3-iOS)
///
/// - Parameters:
///   - anchor: The unit point that defines how to align the view
///     within the bounds of its grid cell.
///
/// - Returns: A view that uses the specified anchor point to align its
///   content.
@inlinable public func gridCellAnchor(_ anchor: UnitPoint) -> some View
/// Overrides the default horizontal alignment of the grid column that
/// the view appears in.
///
/// You set a default alignment for the cells in a grid in both vertical
/// and horizontal dimensions when you create the grid with the
/// ``Grid/init(alignment:horizontalSpacing:verticalSpacing:content:)``
/// initializer. However, you can use the `gridColumnAlignment(_:)` modifier
/// to override the horizontal alignment of a column within the grid. The
/// following example sets a grid's alignment to
/// ``Alignment/leadingFirstTextBaseline``, and then sets the first column
/// to use ``HorizontalAlignment/trailing`` alignment:
///
///     Grid(alignment: .leadingFirstTextBaseline) {
///         GridRow {
///             Text("Regular font:")
///                 .gridColumnAlignment(.trailing) // Align the entire first column.
///             Text("Helvetica 12")
///             Button("Select...") { }
///         }
///         GridRow {
///             Text("Fixed-width font:")
///             Text("Menlo Regular 11")
///             Button("Select...") { }
///         }
///         GridRow {
///             Color.clear
///                 .gridCellUnsizedAxes([.vertical, .horizontal])
///             Toggle("Use fixed-width font for new documents", isOn: $isOn)
///                 .gridCellColumns(2)
///         }
///     }
///
/// This creates the layout of a typical macOS configuration
/// view, with the trailing edge of the first column flush with the
/// leading edge of the second column:
///
/// ![A screenshot of a configuration view, arranged in a grid. The grid
/// has three colums and three rows. Scanning from top to bottom, the
/// left-most column contains a cell with the text Regular font, a cell with
/// the text Fixed-width font, and a blank cell. The middle row contains
/// a cell with the text Helvetica 12, a cell with the text Menlo Regular
/// 11, and a cell with a labeled checkbox. The label says Use fixed-width
/// font for new documents. The label spans its own cell and the cell to
/// its right. The right-most column contains two cells with buttons
/// labeled Select. The last column's bottom cell is merged with the cell
/// from the middle columnn that holds the labeled
/// checkbox.](View-gridColumnAlignment-1-macOS)
///
/// Add the modifier to only one cell in a column. The grid
/// automatically aligns all cells in that column the same way.
/// You get undefined behavior if you apply different alignments to
/// different cells in the same column.
///
/// To override row alignment, see ``GridRow/init(alignment:content:)``. To
/// override alignment for a single cell, see ``View/gridCellAnchor(_:)``.
///
/// - Parameters:
///   - guide: The ``HorizontalAlignment`` guide to use for the grid
///     column that the view appears in.
///
/// - Returns: A view that uses the specified horizontal alignment, and
///   that causes all cells in the same column of a grid to use the
///   same alignment.
@inlinable public func gridColumnAlignment(_ guide: HorizontalAlignment) -> some View
/// Asks grid layouts not to offer the view extra size in the specified
/// axes.
///
/// Use this modifier to prevent a flexible view from taking more space
/// on the specified axes than the other cells in a row or column require.
/// For example, consider the following ``Grid`` that places a ``Divider``
/// between two rows of content:
///
///     Grid {
///         GridRow {
///             Text("Hello")
///             Image(systemName: "globe")
///         }
///         Divider()
///         GridRow {
///             Image(systemName: "hand.wave")
///             Text("World")
///         }
///     }
///
/// The text and images all have ideal widths for their content. However,
/// because a divider takes as much space as its parent offers, the grid
/// fills the width of the display, expanding all the other cells to match:
///
/// ![A screenshot of items arranged in a grid. The upper-left
/// cell in the grid contains the word hello. The upper-right contains
/// an image of a globe. The lower-left contains an image of a waving hand.
/// The lower-right contains the word world. A dividing line that spans
/// the width of the grid separates the upper and lower elements. The grid's
/// rows have minimal vertical spacing, but it's columns have a lot of
/// horizontal spacing, with column content centered
/// horizontally.](View-gridCellUnsizedAxes-1-iOS)
///
/// You can prevent the grid from giving the divider more width than
/// the other cells require by adding the modifier with the
/// ``Axis/horizontal`` parameter:
///
///     Divider()
///         .gridCellUnsizedAxes(.horizontal)
///
/// This restores the grid to the width that it would have without the
/// divider:
///
/// ![A screenshot of items arranged in a grid. The upper-left
/// position in the grid contains the word hello. The upper-right contains
/// an image of a globe. The lower-left contains an image of a waving hand.
/// The lower-right contains the word world. A dividing line that spans
/// the width of the grid separates the upper and lower elements. The grid's
/// rows and columns have minimal vertical or horizontal
/// spacing.](View-gridCellUnsizedAxes-2-iOS)
///
/// - Parameters:
///   - axes: The dimensions in which the grid shouldn't offer the view a
///     share of any available space. This prevents a flexible view like a
///     ``Spacer``, ``Divider``, or ``Color`` from defining the size of
///     a row or column.
///
/// - Returns: A view that doesn't ask an enclosing grid for extra size
///   in one or more axes.
@inlinable public func gridCellUnsizedAxes(_ axes: Axis.Set) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Applies effects to this view, while providing access to layout information
/// via `GeometryProxy`.
///
/// You return new effects by calling functions on the first argument
/// provided to the `effect` closure. In this example, `ContentView` is
/// offset by its own size, causing its top left corner to appear where the
/// bottom right corner was originally located:
/// ```swift
/// ContentView()
///     .visualEffect { content, geometryProxy in
///         content.offset(geometryProxy.size)
///     }
/// ```
///
/// - Parameters:
///   - effect: A closure that returns the effect to be applied. The first
///     argument provided to the closure is a placeholder representing
///     this view. The second argument is a `GeometryProxy`.
/// - Returns: A view with the effect applied.
public func visualEffect(_ effect: @escaping @Sendable (EmptyVisualEffect, GeometryProxy) -> some VisualEffect) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 16.0, watchOS 6.0, *)
extension View {
/// Adds an action to perform when this view recognizes a tap gesture.
///
/// Use this method to perform the specified `action` when the user clicks
/// or taps on the view or container `count` times.
///
/// > Note: If you create a control that's functionally equivalent
/// to a ``Button``, use ``ButtonStyle`` to create a customized button
/// instead.
///
/// In the example below, the color of the heart images changes to a random
/// color from the `colors` array whenever the user clicks or taps on the
/// view twice:
///
///     struct TapGestureExample: View {
///         let colors: [Color] = [.gray, .red, .orange, .yellow,
///                                .green, .blue, .purple, .pink]
///         @State private var fgColor: Color = .gray
///
///         var body: some View {
///             Image(systemName: "heart.fill")
///                 .resizable()
///                 .frame(width: 200, height: 200)
///                 .foregroundColor(fgColor)
///                 .onTapGesture(count: 2) {
///                     fgColor = colors.randomElement()!
///                 }
///         }
///     }
///
/// ![A screenshot of a view of a heart.](SwiftUI-View-TapGesture.png)
///
/// - Parameters:
///    - count: The number of taps or clicks required to trigger the action
///      closure provided in `action`. Defaults to `1`.
///    - action: The action to perform.
public func onTapGesture(count: Int = 1, perform action: @escaping () -> Void) -> some View
}
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets the preferred color scheme for this presentation.
///
/// Use one of the values in ``ColorScheme`` with this modifier to set a
/// preferred color scheme for the nearest enclosing presentation, like a
/// popover, a sheet, or a window. The value that you set overrides the
/// user's Dark Mode selection for that presentation. In the example below,
/// the ``Toggle`` controls an `isDarkMode` state variable, which in turn
/// controls the color scheme of the sheet that contains the toggle:
///
///     @State private var isPresented = false
///     @State private var isDarkMode = true
///
///     var body: some View {
///         Button("Show Sheet") {
///             isPresented = true
///         }
///         .sheet(isPresented: $isPresented) {
///             List {
///                 Toggle("Dark Mode", isOn: $isDarkMode)
///             }
///             .preferredColorScheme(isDarkMode ? .dark : .light)
///         }
///     }
///
/// If you apply the modifier to any of the views in the sheet --- which in
/// this case are a ``List`` and a ``Toggle`` --- the value that you set
/// propagates up through the view hierarchy to the enclosing
/// presentation, or until another color scheme modifier higher in the
/// hierarchy overrides it. The value you set also flows down to all child
/// views of the enclosing presentation.
///
/// A common use for this modifier is to create side-by-side previews of the
/// same view with light and dark appearances:
///
///     struct MyView_Previews: PreviewProvider {
///         static var previews: some View {
///             MyView().preferredColorScheme(.light)
///             MyView().preferredColorScheme(.dark)
///         }
///     }
///
/// If you need to detect the color scheme that currently applies to a view,
/// read the ``EnvironmentValues/colorScheme`` environment value:
///
///     @Environment(\.colorScheme) private var colorScheme
///
///     var body: some View {
///         Text(colorScheme == .dark ? "Dark" : "Light")
///     }
///
/// - Parameter colorScheme: The preferred color scheme for this view.
///
/// - Returns: A view that sets the color scheme.
@inlinable public func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Populates the toolbar or navigation bar with the views you provide.
///
/// Use this modifier to add content to the toolbar. The toolbar modifier
/// expects a collection of toolbar items that you can provide either by
/// supplying a collection of views with each view wrapped in a
/// ``ToolbarItem``, or by providing a collection of views as a
/// ``ToolbarItemGroup``. The example below adds views to using a toolbar
/// item group to support text editing features:
///
///     struct StructToolbarItemGroupView: View {
///         @State private var text = ""
///         @State private var bold = false
///         @State private var italic = false
///         @State private var fontSize = 12.0
///
///         var displayFont: Font {
///             let font = Font.system(size: CGFloat(fontSize),
///                                    weight: bold == true ? .bold : .regular)
///             return italic == true ? font.italic() : font
///         }
///
///         var body: some View {
///             TextEditor(text: $text)
///                 .font(displayFont)
///                 .toolbar {
///                     ToolbarItemGroup {
///                         Slider(
///                             value: $fontSize,
///                             in: 8...120,
///                             minimumValueLabel:
///                                 Text("A").font(.system(size: 8)),
///                             maximumValueLabel:
///                                 Text("A").font(.system(size: 16))
///                         ) {
///                             Text("Font Size (\(Int(fontSize)))")
///                         }
///                         .frame(width: 150)
///                         Toggle(isOn: $bold) {
///                             Image(systemName: "bold")
///                         }
///                         Toggle(isOn: $italic) {
///                             Image(systemName: "italic")
///                         }
///                     }
///                 }
///                 .navigationTitle("My Note")
///         }
///     }
///
/// ![A window showing a font size selector, and toggles for bold, italic.
///   and underlined text styling installed in the toolbar to
///   support text editing in
///   macOS.](SwiftUI-View-Styling-ToolbarContent.png)
///
/// - Parameter content: The views representing the content of the toolbar.
public func toolbar<Content>(@ViewBuilder content: () -> Content) -> some View where Content : View
/// Populates the toolbar or navigation bar with the specified items.
///
/// Use this method to populate a toolbar with a collection of views that
/// you provide to a toolbar view builder.
///
/// The toolbar modifier expects a collection of toolbar items which you can
/// provide either by supplying a collection of views with each view
/// wrapped in a ``ToolbarItem``, or by providing a collection of views as
/// a ``ToolbarItemGroup``. The example below uses a collection of
/// ``ToolbarItem`` views to create a macOS toolbar that supports text
/// editing features:
///
///     struct StructToolbarItemGroupView: View {
///         @State private var text = ""
///         @State private var bold = false
///         @State private var italic = false
///         @State private var fontSize = 12.0
///
///         var displayFont: Font {
///             let font = Font.system(size: CGFloat(fontSize),
///                                    weight: bold == true ? .bold : .regular)
///             return italic == true ? font.italic() : font
///         }
///
///         var body: some View {
///             TextEditor(text: $text)
///                 .font(displayFont)
///                 .toolbar {
///                     ToolbarItemGroup {
///                         Slider(
///                             value: $fontSize,
///                             in: 8...120,
///                             minimumValueLabel:
///                                 Text("A").font(.system(size: 8)),
///                             maximumValueLabel:
///                                 Text("A").font(.system(size: 16))
///                         ) {
///                             Text("Font Size (\(Int(fontSize)))")
///                         }
///                         .frame(width: 150)
///                         Toggle(isOn: $bold) {
///                             Image(systemName: "bold")
///                         }
///                         Toggle(isOn: $italic) {
///                             Image(systemName: "italic")
///                         }
///                     }
///                 }
///                 .navigationTitle("My Note")
///         }
///     }
///
/// ![A window showing a font size selector, and toggles for bold, italic.
///   and underlined text styling installed in the toolbar to
///   support text editing in
///   macOS.](SwiftUI-View-Styling-ToolbarContent.png)
///
/// Although it's not mandatory, wrapping a related group of toolbar
/// items together in a ``ToolbarItemGroup`` provides a one-to-one mapping
/// between controls and toolbar items which results in the correct layout
/// and spacing on each platform.
/// For design guidance on toolbars for macOS apps, see macOS Human
/// Interface Guidelines >
/// [Toolbars](https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/toolbars/).
/// For design guidance on toolbars for iOS apps, see iOS Human Interface Guidelines >
/// [Toolbars](https://developer.apple.com/design/human-interface-guidelines/ios/bars/toolbars/).
///
/// - Parameter content: The items representing the content of the toolbar.
public func toolbar<Content>(@ToolbarContentBuilder content: () -> Content) -> some View where Content : ToolbarContent
/// Populates the toolbar or navigation bar with the specified items,
/// allowing for user customization.
///
/// Use this modifier when you want to allow the user to customize the
/// components and layout of elements in the toolbar. The toolbar modifier
/// expects a collection of toolbar items which you can provide either by
/// supplying a collection of views with each view wrapped in a
/// ``ToolbarItem``.
///
/// > Note: Customizable toolbars will be displayed on both macOS and iOS,
///   but only apps running on iPadOS 16.0 and later will support
///   user customization.
///
/// The example below creates a view that represents each
/// ``ToolbarItem`` along with an ID that uniquely identifies the toolbar
/// item to the customization editor:
///
///     struct ToolsEditorView: View {
///         @State private var text = ""
///         @State private var bold = false
///         @State private var italic = false
///         @State private var fontSize = 12.0
///
///         var displayFont: Font {
///             let font = Font.system(
///                size: CGFloat(fontSize),
///                  weight: bold == true ? .bold : .regular)
///             return italic == true ? font.italic() : font
///         }
///
///         var body: some View {
///             TextEditor(text: $text)
///                 .font(displayFont)
///                 .toolbar(id: "editingtools") {
///                     ToolbarItem(
///                         id: "sizeSelector", placement: .secondaryAction
///                     ) {
///                         Slider(
///                             value: $fontSize,
///                             in: 8...120,
///                             minimumValueLabel:
///                                 Text("A").font(.system(size: 8)),
///                             maximumValueLabel:
///                                 Text("A").font(.system(size: 16))
///                         ) {
///                             Text("Font Size (\(Int(fontSize)))")
///                         }
///                         .frame(width: 150)
///                     }
///                     ToolbarItem(
///                         id: "bold", placement: .secondaryAction
///                     ) {
///                         Toggle(isOn: $bold) {
///                             Image(systemName: "bold")
///                         }
///                     }
///                     ToolbarItem(
///                         id: "italic", placement: .secondaryAction
///                     ) {
///                         Toggle(isOn: $italic) {
///                             Image(systemName: "italic")
///                         }
///                     }
///                 }
///                 .navigationTitle("My Note")
///         }
///     }
///
/// ![A window showing the macOS toolbar customization
///   editor.](SwiftUI-View-Styling-ToolbarCustomization.png)
///
/// > Note: Only ``ToolbarItemPlacement/secondaryAction`` items support
///   customization in iPadOS. Other items follow the normal
///   placement rules and can't be customized by the user.
///
/// In macOS you can enable menu support for toolbar customization by
/// adding a ``ToolbarCommands`` instance to a scene using the
/// ``Scene/commands(content:)`` scene modifier:
///
///     @main
///     struct ToolbarContent_macOSApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ToolsEditorView()
///                     .frame(maxWidth: .infinity, maxHeight: .infinity)
///             }
///             .commands {
///                 ToolbarCommands()
///             }
///         }
///     }
///
/// When you add the toolbar commands, the system adds a menu item to
/// your app's main menu to provide toolbar customization support.
/// This is in addition to the ability to Control-click on the
/// toolbar to open the toolbar customization editor.
///
/// ![A screenshot of the toolbar editor support for the macOS view
/// menu.](SwiftUI-View-Styling-ToolbarCustomizationMenu.png)
///
/// - Parameters:
///   - id: A unique identifier for this toolbar.
///   - content: The content representing the content of the toolbar.
public func toolbar<Content>(id: String, @ToolbarContentBuilder content: () -> Content) -> some View where Content : CustomizableToolbarContent
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Configures the view's title for purposes of navigation.
///
/// A view's navigation title is used to visually display
/// the current navigation state of an interface.
/// On iOS and watchOS, when a view is navigated to inside
/// of a navigation view, that view's title is displayed
/// in the navigation bar. On iPadOS, the primary destination's
/// navigation title is reflected as the window's title in the
/// App Switcher. Similarly on macOS, the primary destination's title
/// is used as the window title in the titlebar, Windows menu
/// and Mission Control.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation title modifiers.
///
/// - Parameter title: The title to display.
public func navigationTitle(_ title: Text) -> some View
/// Configures the view's title for purposes of navigation,
/// using a localized string.
///
/// A view's navigation title is used to visually display
/// the current navigation state of an interface.
/// On iOS and watchOS, when a view is navigated to inside
/// of a navigation view, that view's title is displayed
/// in the navigation bar. On iPadOS, the primary destination's
/// navigation title is reflected as the window's title in the
/// App Switcher. Similarly on macOS, the primary destination's title
/// is used as the window title in the titlebar, Windows menu
/// and Mission Control.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation title modifiers.
///
/// - Parameter titleKey: The key to a localized string to display.
public func navigationTitle(_ titleKey: LocalizedStringKey) -> some View
/// Configures the view's title for purposes of navigation, using a string.
///
/// A view's navigation title is used to visually display
/// the current navigation state of an interface.
/// On iOS and watchOS, when a view is navigated to inside
/// of a navigation view, that view's title is displayed
/// in the navigation bar. On iPadOS, the primary destination's
/// navigation title is reflected as the window's title in the
/// App Switcher. Similarly on macOS, the primary destination's title
/// is used as the window title in the titlebar, Windows menu
/// and Mission Control.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation title modifiers.
///
/// - Parameter title: The string to display.
public func navigationTitle<S>(_ title: S) -> some View where S : StringProtocol
}
extension View {
/// Configures the view's title for purposes of navigation, using a string
/// binding.
///
/// In iOS, iPadOS, and macOS, this allows editing the navigation title
/// when the title is displayed in the toolbar.
///
/// Refer to the <doc:Configure-Your-Apps-Navigation-Titles> article
/// for more information on navigation title modifiers.
///
/// - Parameter title: The text of the title.
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
public func navigationTitle(_ title: Binding<String>) -> some View
}
@available(iOS 14.0, watchOS 8.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
extension View {
/// Configures the title display mode for this view.
///
/// - Parameter displayMode: The style to use for displaying the title.
public func navigationBarTitleDisplayMode(_ displayMode: NavigationBarItem.TitleDisplayMode) -> some View
}
extension View {
/// Sets the screen edge from which you want your gesture to take
/// precedence over the system gesture.
///
/// The following code defers the vertical screen edges system gestures
/// of a given canvas.
///
///     struct DeferredView: View {
///         var body: some View {
///             Canvas()
///                 .defersSystemGestures(on: .vertical)
///         }
///     }
///
/// - Parameter edges: A value that indicates the screen edge from which
///   you want your gesture to take precedence over the system gesture.
@available(iOS 16.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, unavailable)
public func defersSystemGestures(on edges: Edge.Set) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets a value for the specified preference key, the value is a
/// function of the key's current value and a geometry value tied
/// to the current coordinate space, allowing readers of the value
/// to convert the geometry to their local coordinates.
///
/// - Parameters:
///   - key: the preference key type.
///   - value: the geometry value in the current coordinate space.
///   - transform: the function to produce the preference value.
///
/// - Returns: a new version of the view that writes the preference.
@inlinable public func transformAnchorPreference<A, K>(key _: K.Type = K.self, value: Anchor<A>.Source, transform: @escaping (inout K.Value, Anchor<A>) -> Void) -> some View where K : PreferenceKey
}
extension View {
/// Sets the text content type for this view, which the system uses to
/// offer suggestions while the user enters text on an iOS or tvOS device.
///
/// Use this method to set the content type for input text.
/// For example, you can configure a ``TextField`` for the entry of email
/// addresses:
///
///     TextField("Enter your email", text: $emailAddress)
///         .textContentType(.emailAddress)
///
/// - Parameter textContentType: One of the content types available in the
///   <doc://com.apple.documentation/documentation/UIKit/UITextContentType>
///   structure that identify the semantic meaning expected for a text-entry
///   area. These include support for email addresses, location names, URLs,
///   and telephone numbers, to name just a few.
@available(iOS 13.0, tvOS 13.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@inlinable public func textContentType(_ textContentType: UITextContentType?) -> some View
}
extension View {
/// Configure the title menu of a toolbar.
///
/// A title menu represent common functionality that can be done on the
/// content represented by your app's toolbar or navigation title. This
/// menu may be populated from your app's commands like
/// ``CommandGroupPlacement/saveItem`` or
/// ``CommandGroupPlacement/printItem``.
///
///     ContentView()
///         .toolbar {
///             ToolbarTitleMenu()
///         }
///
/// You can provide your own set of actions to override this behavior.
///
///     ContentView()
///         .toolbarTitleMenu {
///             DuplicateButton()
///             PrintButton()
///         }
///
/// In iOS and iPadOS, this will construct a menu that can be presented by
/// tapping the navigation title in the app's navigation bar.
///
/// - Parameter content: The content associated to the toolbar title menu.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbarTitleMenu<C>(@ViewBuilder content: () -> C) -> some View where C : View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Replaces one or more accessibility elements for this view with new
/// accessibility elements.
///
/// You can make controls accessible by using a custom style. For example, a custom
/// ``ToggleStyle`` that you create inherits the accessibility features of ``Toggle``
/// automatically. When you can't use the parent view's accessibility elements, use the
/// `accessibilityRepresentation(representation:)`
/// modifier instead. This modifier replaces default accessibility elements with different accessibility
/// elements that you provide. You use synthetic, non-visual accessibility elements to represent
/// what the view displays.
///
/// The example below makes a custom adjustable control accessible by explicitly
/// defining the representation of its step increments using a ``Slider``:
///
///     var body: some View {
///         VStack {
///             SliderTrack(...) // Custom slider implementation.
///         }
///         .accessibilityRepresentation {
///             Slider(value: $value, in: 0...100) {
///                 Text("Label")
///             }
///         }
///     }
///
/// SwiftUI hides the view that you provide in the `representation` closure
/// and makes it non-interactive. The framework uses it only to
/// generate accessibility elements.
///
/// - Parameter representation: A hidden view that the accessibility
///   system uses to generate accessibility elements.
///
public func accessibilityRepresentation<V>(@ViewBuilder representation: () -> V) -> some View where V : View
/// Replaces the existing accessibility element's children with one or
/// more new synthetic accessibility elements.
///
/// Use this modifier to replace an existing element's children with one
/// or more new synthetic accessibility elements you provide. This allows
/// for synthetic, non-visual accessibility elements to be set as children
/// of a visual accessibility element.
///
/// SwiftUI creates an accessibility container implicitly when needed.
/// If an accessibility element already exists, the framework converts it
/// into an accessibility container.
///
/// In the  example below, a ``Canvas`` displays a graph of vertical bars that don't have any
/// inherent accessibility elements. You make the view accessible by adding
/// the ``accessibilityChildren(children:)`` modifier with views whose accessibility
/// elements represent the values of each bar drawn in the canvas:
///
///     var body: some View {
///         Canvas { context, size in
///             // Draw Graph
///             for data in dataSet {
///                 let path = Path(
///                     roundedRect: CGRect(
///                         x: (size.width / CGFloat(dataSet.count))
///                         * CGFloat(data.week),
///                         y: 0,
///                         width: size.width / CGFloat(dataSet.count),
///                         height: CGFloat(data.lines),
///                     cornerRadius: 5)
///                 context.fill(path, with: .color(.blue))
///             }
///             // Draw Axis and Labels
///             ...
///         }
///         .accessibilityLabel("Lines of Code per Week")
///         .accessibilityChildren {
///             HStack {
///                 ForEach(dataSet) { data in
///                     RoundedRectangle(cornerRadius: 5)
///                         .accessibilityLabel("Week \(data.week)")
///                         .accessibilityValue("\(data.lines) lines")
///                 }
///             }
///         }
///     }
///
/// SwiftUI hides any views that you provide with the `children` parameter,
/// then the framework uses the views to generate the accessibility elements.
///
/// - Parameter children: A ``ViewBuilder`` that represents the replacement
///   child views the framework uses to generate accessibility elements.
public func accessibilityChildren<V>(@ViewBuilder children: () -> V) -> some View where V : View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Performs an action when a specified value changes.
///
/// Use this modifier to run a closure when a value like
/// an ``Environment`` value or a ``Binding`` changes.
/// For example, you can clear a cache when you notice
/// that the view's scene moves to the background:
///
///     struct ContentView: View {
///         @Environment(\.scenePhase) private var scenePhase
///         @StateObject private var cache = DataCache()
///
///         var body: some View {
///             MyView()
///                 .onChange(of: scenePhase) { newScenePhase in
///                     if newScenePhase == .background {
///                         cache.empty()
///                     }
///                 }
///         }
///     }
///
/// SwiftUI passes the new value into the closure. You can also capture the
/// previous value to compare it to the new value. For example, in
/// the following code example, `PlayerView` passes both the old and new
/// values to the model.
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var playState: PlayState = .paused
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                 Text(episode.showTitle)
///                 PlayButton(playState: $playState)
///             }
///             .onChange(of: playState) { [playState] newState in
///                 model.playStateDidChange(from: playState, to: newState)
///             }
///         }
///     }
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task.
///
/// Important: This modifier is deprecated and has been replaced with new
/// versions that include either zero or two parameters within the closure,
/// unlike this version that includes one parameter. This deprecated version
/// and the new versions behave differently with respect to how they execute
/// the action closure, specifically when the closure captures other values.
/// Using the deprecated API, the closure is run with captured values that
/// represent the "old" state. With the replacement API, the closure is run
/// with captured values that represent the "new" state, which makes it
/// easier to correctly perform updates that rely on supplementary values
/// (that may or may not have changed) in addition to the changed value that
/// triggered the action.
///
/// - Important: This modifier is deprecated and has been replaced with new
///   versions that include either zero or two parameters within the
///   closure, unlike this version that includes one parameter. This
///   deprecated version and the new versions behave differently with
///   respect to how they execute the action closure, specifically when the
///   closure captures other values. Using the deprecated API, the closure
///   is run with captured values that represent the "old" state. With the
///   replacement API, the closure is run with captured values that
///   represent the "new" state, which makes it easier to correctly perform
///   updates that rely on supplementary values (that may or may not have
///   changed) in addition to the changed value that triggered the action.
///
/// - Parameters:
///   - value: The value to check when determining whether to run the
///     closure. The value must conform to the
///     <doc://com.apple.documentation/documentation/Swift/Equatable>
///     protocol.
///   - action: A closure to run when the value changes. The closure
///     takes a `newValue` parameter that indicates the updated
///     value.
///
/// - Returns: A view that runs an action when the specified value changes.
@available(iOS, deprecated: 17.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(macOS, deprecated: 14.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(tvOS, deprecated: 17.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(watchOS, deprecated: 10.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@available(visionOS, deprecated: 1.0, message: "Use `onChange` with a two or zero parameter action closure instead.")
@inlinable public func onChange<V>(of value: V, perform action: @escaping (_ newValue: V) -> Void) -> some View where V : Equatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Adds a modifier for this view that fires an action when a specific
/// value changes.
///
/// You can use `onChange` to trigger a side effect as the result of a
/// value changing, such as an `Environment` key or a `Binding`.
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task.
///
/// When the value changes, the new version of the closure will be called,
/// so any captured values will have their values from the time that the
/// observed value has its new value. The old and new observed values are
/// passed into the closure. In the following code example, `PlayerView`
/// passes both the old and new values to the model.
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var playState: PlayState = .paused
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                 Text(episode.showTitle)
///                 PlayButton(playState: $playState)
///             }
///             .onChange(of: playState) { oldState, newState in
///                 model.playStateDidChange(from: oldState, to: newState)
///             }
///         }
///     }
///
/// - Parameters:
///   - value: The value to check against when determining whether
///     to run the closure.
///   - initial: Whether the action should be run when this view initially
///     appears.
///   - action: A closure to run when the value changes.
///   - oldValue: The old value that failed the comparison check (or the
///     initial value when requested).
///   - newValue: The new value that failed the comparison check.
///
/// - Returns: A view that fires an action when the specified value changes.
public func onChange<V>(of value: V, initial: Bool = false, _ action: @escaping (_ oldValue: V, _ newValue: V) -> Void) -> some View where V : Equatable
/// Adds a modifier for this view that fires an action when a specific
/// value changes.
///
/// You can use `onChange` to trigger a side effect as the result of a
/// value changing, such as an `Environment` key or a `Binding`.
///
/// The system may call the action closure on the main actor, so avoid
/// long-running tasks in the closure. If you need to perform such tasks,
/// detach an asynchronous background task.
///
/// When the value changes, the new version of the closure will be called,
/// so any captured values will have their values from the time that the
/// observed value has its new value. In the following code example,
/// `PlayerView` calls into its model when `playState` changes model.
///
///     struct PlayerView: View {
///         var episode: Episode
///         @State private var playState: PlayState = .paused
///
///         var body: some View {
///             VStack {
///                 Text(episode.title)
///                 Text(episode.showTitle)
///                 PlayButton(playState: $playState)
///             }
///             .onChange(of: playState) {
///                 model.playStateDidChange(state: playState)
///             }
///         }
///     }
///
/// - Parameters:
///   - value: The value to check against when determining whether
///     to run the closure.
///   - initial: Whether the action should be run when this view initially
///     appears.
///   - action: A closure to run when the value changes.
///
/// - Returns: A view that fires an action when the specified value changes.
public func onChange<V>(of value: V, initial: Bool = false, _ action: @escaping () -> Void) -> some View where V : Equatable
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Performs an action if the user presses a key on a hardware keyboard
/// while the view has focus.
///
/// SwiftUI performs the action for key-down and key-repeat events.
///
/// - Parameters:
///   - key: The key to match against incoming hardware keyboard events.
///   - action: The action to perform. Return `.handled` to consume the
///     event and prevent further dispatch, or `.ignored` to allow dispatch
///     to continue.
/// - Returns: A modified view that binds hardware keyboard input
///   when focused.
public func onKeyPress(_ key: KeyEquivalent, action: @escaping () -> KeyPress.Result) -> some View
/// Performs an action if the user presses a key on a hardware keyboard
/// while the view has focus.
///
/// SwiftUI performs the action for the specified event phases.
///
/// - Parameters:
///   - key: The key to match against incoming hardware keyboard events.
///   - phases: The key-press phases to match (`.down`, `.up`,
///     and `.repeat`).
///   - action: The action to perform. The action receives a value
///     describing the matched key event. Return `.handled` to consume the
///     event and prevent further dispatch, or `.ignored` to allow dispatch
///     to continue.
/// - Returns: A modified view that binds hardware keyboard input
///   when focused.
public func onKeyPress(_ key: KeyEquivalent, phases: KeyPress.Phases, action: @escaping (KeyPress) -> KeyPress.Result) -> some View
/// Performs an action if the user presses one or more keys on a hardware
/// keyboard while the view has focus.
///
/// - Parameters:
///   - keys: A set of keys to match against incoming hardware
///     keyboard events.
///   - phases: The key-press phases to match (`.down`, `.repeat`, and
///     `.up`). The default value is `[.down, .repeat]`.
///   - action: The action to perform. The action receives a value
///     describing the matched key event. Return `.handled` to consume the
///     event and prevent further dispatch, or `.ignored` to allow dispatch
///     to continue.
/// - Returns: A modified view that binds keyboard input when focused.
public func onKeyPress(keys: Set<KeyEquivalent>, phases: KeyPress.Phases = [.down, .repeat], action: @escaping (KeyPress) -> KeyPress.Result) -> some View
/// Performs an action if the user presses one or more keys on a hardware
/// keyboard while the view has focus.
///
/// - Parameters:
///   - characters: The set of characters to match against incoming
///     hardware keyboard events.
///   - phases: The key-press phases to match (`.down`, `.repeat`, and
///     `.up`). The default value is `[.down, .repeat]`.
///   - action: The action to perform. The action receives a value
///     describing the matched key event. Return `.handled` to consume the
///     event and prevent further dispatch, or `.ignored` to allow dispatch
///     to continue.
/// - Returns: A modified view that binds hardware keyboard input
///   when focused.
public func onKeyPress(characters: CharacterSet, phases: KeyPress.Phases = [.down, .repeat], action: @escaping (KeyPress) -> KeyPress.Result) -> some View
/// Performs an action if the user presses any key on a hardware keyboard
/// while the view has focus.
///
/// - Parameters:
///   - phases: The key-press phases to match (`.down`, `.repeat`, and
///     `.up`). The default value is `[.down, .repeat]`.
///   - action: The action to perform. The action receives a value
///     describing the matched key event. Return `.handled` to consume the
///     event and prevent further dispatch, or `.ignored` to allow dispatch
///     to continue.
/// - Returns: A modified view that binds hardware keyboard input
///   when focused.
public func onKeyPress(phases: KeyPress.Phases = [.down, .repeat], action: @escaping (KeyPress) -> KeyPress.Result) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Hides this view unconditionally.
///
/// Hidden views are invisible and can't receive or respond to interactions.
/// However, they do remain in the view hierarchy and affect layout. Use
/// this modifier if you want to include a view for layout purposes, but
/// don't want it to display.
///
///     HStack {
///         Image(systemName: "a.circle.fill")
///         Image(systemName: "b.circle.fill")
///         Image(systemName: "c.circle.fill")
///             .hidden()
///         Image(systemName: "d.circle.fill")
///     }
///
/// The third circle takes up space, because it's still present, but
/// SwiftUI doesn't draw it onscreen.
///
/// ![A row of circles with the letters A, B, and D, with a gap where
///   the circle with the letter C should be.](SwiftUI-View-hidden-1.png)
///
/// If you want to conditionally include a view in the view hierarchy, use
/// an `if` statement instead:
///
///     VStack {
///         HStack {
///             Image(systemName: "a.circle.fill")
///             Image(systemName: "b.circle.fill")
///             if !isHidden {
///                 Image(systemName: "c.circle.fill")
///             }
///             Image(systemName: "d.circle.fill")
///         }
///         Toggle("Hide", isOn: $isHidden)
///     }
///
/// Depending on the current value of the `isHidden` state variable in the
/// example above, controlled by the ``Toggle`` instance, SwiftUI draws
/// the circle or completely omits it from the layout.
///
/// ![Two side by side groups of items, each composed of a toggle beneath
///   a row of circles with letters in them. The toggle on the left
///   is off and has four equally spaced circles above it: A, B, C, and D.
///   The toggle on the right is on and has three equally spaced circles
///   above it: A, B, and D.](SwiftUI-View-hidden-2.png)
///
/// - Returns: A hidden view.
@inlinable public func hidden() -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Adds a descriptor to a View that represents a chart to make
/// the chart's contents accessible to all users.
///
/// Use this method to provide information about your chart view
/// to allow VoiceOver and other assistive technology users to
/// perceive and interact with your chart and its data.
///
/// This may be applied to any View that represents a chart,
/// including Image and custom-rendered chart views.
///
/// The `accessibilityChartDescriptor` modifier can be applied to -any-
/// view representing a chart, the simplest case being just an image of
/// a chart. The implementation details of the view aren't important,
/// only the fact that it represents a chart, and that the provided
/// chart descriptor accurately describes the content of the chart.
///
/// - Parameter chartDescriptor: The ``AXChartDescriptorRepresentable``
///  used to describe your chart and its data.
///
/// Example usage:
///
/// First define your `AXChartDescriptorRepresentable` type.
///
///     struct MyChartDescriptorRepresentable:
///     AXChartDescriptorRepresentable {
///         func makeChartDescriptor() -> AXChartDescriptor {
///             // Build and return your `AXChartDescriptor` here.
///         }
///
///         func updateChartDescriptor(_ descriptor: AXChartDescriptor) {
///             // Update your chart descriptor with any new values, or
///             // don't override if your chart doesn't have changing
///             // values.
///         }
///     }
///
/// Then use the `accessibilityChartDescriptor` modifier to provide an
/// instance of your `AXChartDescriptorRepresentable` type to the view
/// representing your chart:
///
///     SomeChartView()
///         .accessibilityChartDescriptor(MyChartDescriptorRepresentable())
public func accessibilityChartDescriptor<R>(_ representable: R) -> some View where R : AXChartDescriptorRepresentable
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Sets the menu indicator visibility for controls within this view.
///
/// Use this modifier to override the default menu indicator
/// visibility for controls in this view. For example, the code below
/// creates a menu without an indicator:
///
///     Menu {
///         ForEach(history , id: \.self) { historyItem in
///             Button(historyItem.title) {
///                 self.openURL(historyItem.url)
///             }
///         }
///     } label: {
///         Label("Back", systemImage: "chevron.backward")
///             .labelStyle(.iconOnly)
///     } primaryAction: {
///         if let last = history.last {
///             self.openURL(last.url)
///         }
///     }
///     .menuIndicator(.hidden)
///
/// - Note: On tvOS, the standard button styles do not include a menu
///         indicator, so this modifier will have no effect when using a
///         built-in button style. You can implement an indicator in your
///         own ``ButtonStyle`` implementation by checking the value of the
///         `menuIndicatorVisibility` environment value.
///
/// - Parameter visibility: The menu indicator visibility to apply.
@inlinable public func menuIndicator(_ visibility: Visibility) -> some View
}
extension View {
/// Modifies this view by injecting a value that you provide for use by
/// other views whose state depends on the focused view hierarchy.
///
/// - Parameters:
///   - keyPath: The key path to associate `value` with when adding
///     it to the existing table of exported focus values.
///   - value: The focus value to export.
/// - Returns: A modified representation of this view.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public func focusedValue<Value>(_ keyPath: WritableKeyPath<FocusedValues, Value?>, _ value: Value) -> some View
/// Creates a new view that exposes the provided value to other views whose
/// state depends on the focused view hierarchy.
///
/// Use this method instead of ``View/focusedSceneValue(_:_:)`` when your
/// scene includes multiple focusable views with their own associated
/// values, and you need an app- or scene-scoped element like a command or
/// toolbar item that operates on the value associated with whichever view
/// currently has focus. Each focusable view can supply its own value:
///
///
///
/// - Parameters:
///   - keyPath: The key path to associate `value` with when adding
///     it to the existing table of exported focus values.
///   - value: The focus value to export, or `nil` if no value is
///     currently available.
/// - Returns: A modified representation of this view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func focusedValue<Value>(_ keyPath: WritableKeyPath<FocusedValues, Value?>, _ value: Value?) -> some View
/// Modifies this view by injecting a value that you provide for use by
/// other views whose state depends on the focused scene.
///
/// Use this method instead of ``View/focusedValue(_:_:)`` for values that
/// must be visible regardless of where focus is located in the active
/// scene. For example, if an app needs a command for moving focus to a
/// particular text field in the sidebar, it could use this modifier to
/// publish a button action that's visible to command views as long as the
/// scene is active, and regardless of where focus happens to be in it.
///
///     struct Sidebar: View {
///         @FocusState var isFiltering: Bool
///
///         var body: some View {
///             VStack {
///                 TextField(...)
///                     .focused(when: $isFiltering)
///                     .focusedSceneValue(\.filterAction) {
///                         isFiltering = true
///                     }
///             }
///         }
///     }
///
///     struct NavigationCommands: Commands {
///         @FocusedValue(\.filterAction) var filterAction
///
///         var body: some Commands {
///             CommandMenu("Navigate") {
///                 Button("Filter in Sidebar") {
///                     filterAction?()
///                 }
///             }
///             .disabled(filterAction == nil)
///         }
///     }
///
///     struct FilterActionKey: FocusedValuesKey {
///         typealias Value = () -> Void
///     }
///
///     extension FocusedValues {
///         var filterAction: (() -> Void)? {
///             get { self[FilterActionKey.self] }
///             set { self[FilterActionKey.self] = newValue }
///         }
///     }
///
/// - Parameters:
///   - keyPath: The key path to associate `value` with when adding
///     it to the existing table of published focus values.
///   - value: The focus value to publish.
/// - Returns: A modified representation of this view.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func focusedSceneValue<T>(_ keyPath: WritableKeyPath<FocusedValues, T?>, _ value: T) -> some View
/// Creates a new view that exposes the provided value to other views whose
/// state depends on the active scene.
///
/// Use this method instead of ``View/focusedValue(_:_:)`` for values that
/// must be visible regardless of where focus is located in the active
/// scene. For example, if an app needs a command for moving focus to a
/// particular text field in the sidebar, it could use this modifier to
/// publish a button action that's visible to command views as long as the
/// scene is active, and regardless of where focus happens to be in it.
///
///     struct Sidebar: View {
///         @FocusState var isFiltering: Bool
///
///         var body: some View {
///             VStack {
///                 TextField(...)
///                     .focused(when: $isFiltering)
///                     .focusedSceneValue(\.filterAction) {
///                         isFiltering = true
///                     }
///             }
///         }
///     }
///
///     struct NavigationCommands: Commands {
///         @FocusedValue(\.filterAction) var filterAction
///
///         var body: some Commands {
///             CommandMenu("Navigate") {
///                 Button("Filter in Sidebar") {
///                     filterAction?()
///                 }
///             }
///             .disabled(filterAction == nil)
///         }
///     }
///
///     struct FilterActionKey: FocusedValuesKey {
///         typealias Value = () -> Void
///     }
///
///     extension FocusedValues {
///         var filterAction: (() -> Void)? {
///             get { self[FilterActionKey.self] }
///             set { self[FilterActionKey.self] = newValue }
///         }
///     }
///
/// - Parameters:
///   - keyPath: The key path to associate `value` with when adding
///     it to the existing table of published focus values.
///   - value: The focus value to publish, or `nil` if no value is
///     currently available.
/// - Returns: A modified representation of this view.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func focusedSceneValue<T>(_ keyPath: WritableKeyPath<FocusedValues, T?>, _ value: T?) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Modifies the view to use a given transition as its method of animating
/// changes to the contents of its views.
///
/// This modifier allows you to perform a transition that animates a change
/// within a single view. The provided ``ContentTransition`` can present an
/// opacity animation for content changes, an interpolated animation of
/// the content's paths as they change, or perform no animation at all.
///
/// > Tip: The `contentTransition(_:)` modifier only has an effect within
/// the context of an ``Animation``.
///
/// In the following example, a ``Button`` changes the color and font size
/// of a ``Text`` view. Since both of these properties apply to the paths of
/// the text, the ``ContentTransition/interpolate`` transition can animate a
/// gradual change to these properties through the entire transition. By
/// contrast, the ``ContentTransition/opacity`` transition would simply fade
/// between the start and end states.
///
///     private static let font1 = Font.system(size: 20)
///     private static let font2 = Font.system(size: 45)
///
///     @State private var color = Color.red
///     @State private var currentFont = font1
///
///     var body: some View {
///         VStack {
///             Text("Content transition")
///                 .foregroundColor(color)
///                 .font(currentFont)
///                 .contentTransition(.interpolate)
///             Spacer()
///             Button("Change") {
///                 withAnimation(Animation.easeInOut(duration: 5.0)) {
///                     color = (color == .red) ? .green : .red
///                     currentFont = (currentFont == font1) ? font2 : font1
///                 }
///             }
///         }
///     }
///
/// This example uses an ease-in–ease-out animation with a five-second
/// duration to make it easier to see the effect of the interpolation. The
/// figure below shows the `Text` at the beginning of the animation,
/// halfway through, and at the end.
///
/// | Time    | Display |
/// | ------- | ------- |
/// | Start   | ![The text Content transition in a small red font.](ContentTransition-1) |
/// | Middle  | ![The text Content transition in a medium brown font.](ContentTransition-2) |
/// | End     | ![The text Content transition in a large green font.](ContentTransition-3) |
///
/// To control whether content transitions use GPU-accelerated rendering,
/// set the value of the
/// ``EnvironmentValues/contentTransitionAddsDrawingGroup`` environment
/// variable.
///
/// - parameter transition: The transition to apply when animating the
///   content change.
public func contentTransition(_ transition: ContentTransition) -> some View
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the style for tables within this view.
public func tableStyle<S>(_ style: S) -> some View where S : TableStyle
}
@available(iOS 15.0, macOS 10.15, watchOS 9.0, *)
@available(tvOS, unavailable)
extension View {
/// Sets the size for controls within this view.
///
/// Use `controlSize(_:)` to override the system default size for controls
/// in this view. In this example, a view displays several typical controls
/// at `.mini`, `.small` and `.regular` sizes.
///
///     struct ControlSize: View {
///         var body: some View {
///             VStack {
///                 MyControls(label: "Mini")
///                     .controlSize(.mini)
///                 MyControls(label: "Small")
///                     .controlSize(.small)
///                 MyControls(label: "Regular")
///                     .controlSize(.regular)
///             }
///             .padding()
///             .frame(width: 450)
///             .border(Color.gray)
///         }
///     }
///
///     struct MyControls: View {
///         var label: String
///         @State private var value = 3.0
///         @State private var selected = 1
///         var body: some View {
///             HStack {
///                 Text(label + ":")
///                 Picker("Selection", selection: $selected) {
///                     Text("option 1").tag(1)
///                     Text("option 2").tag(2)
///                     Text("option 3").tag(3)
///                 }
///                 Slider(value: $value, in: 1...10)
///                 Button("OK") { }
///             }
///         }
///     }
///
/// ![A screenshot showing several controls of various
/// sizes.](SwiftUI-View-controlSize.png)
///
/// - Parameter controlSize: One of the control sizes specified in the
///   ``ControlSize`` enumeration.
@available(tvOS, unavailable)
@inlinable public func controlSize(_ controlSize: ControlSize) -> some View
}
@available(iOS 16.0, macOS 13.0, watchOS 7.0, *)
@available(tvOS, unavailable)
extension View {
/// Sets the style for gauges within this view.
public func gaugeStyle<S>(_ style: S) -> some View where S : GaugeStyle
}
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
extension View {
/// Controls the visibility of a `Table`'s column header views.
///
/// By default, `Table` will display a global header view with the labels
/// of each table column. This area is also where users can sort, resize,
/// and rearrange the columns. For simple cases that don't require those
/// features, this header can be hidden.
///
/// This will not affect the header of any `Section`s in a table.
///
///     Table(article.authors) {
///         TableColumn("Name", value: \.name)
///         TableColumn("Title", value: \.title)
///     }
///     .tableColumnHeaders(.hidden)
///
/// - Parameter visibility: A value of `visible` will show table columns,
///   `hidden` will remove them, and `automatic` will defer to default
///   behavior.
public func tableColumnHeaders(_ visibility: Visibility) -> some View
}
extension View {
/// Configures the toolbar title display mode for this view.
///
/// Use this modifier to override the default toolbar title display
/// mode.
///
///     NavigationStack {
///         ContentView()
///             .toolbarTitleDisplayMode(.inlineLarge)
///     }
///
/// See ``ToolbarTitleDisplayMode`` for more information on the
/// different kinds of display modes. This modifier has no effect
/// on macOS.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func toolbarTitleDisplayMode(_ mode: ToolbarTitleDisplayMode) -> some View
}
@available(iOS 15.0, macOS 12.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
extension View {
/// Generates a badge for the view from an integer value.
///
/// Use a badge to convey optional, supplementary information about a
/// view. Keep the contents of the badge as short as possible. Badges
/// appear only in list rows, tab bars, and menus.
///
/// The following example shows a ``List`` with the value of `recentItems.count`
/// represented by a badge on one of the rows:
///
///     List {
///         Text("Recents")
///             .badge(recentItems.count)
///         Text("Favorites")
///     }
///
/// ![A table with two rows, titled Recents and Favorites. The first row
/// shows the number 10 at the trailing side of the row
///  cell.](View-badge-1)
///
/// - Parameter count: An integer value to display in the badge.
///   Set the value to zero to hide the badge.
public func badge(_ count: Int) -> some View
/// Generates a badge for the view from a text view.
///
/// Use a badge to convey optional, supplementary information about a
/// view. Keep the contents of the badge as short as possible. Badges
/// appear only in list rows, tab bars, and menus.
///
/// Use this initializer when you want to style a ``Text`` view for use as a
/// badge. The following example customizes the badge with the
/// ``Text/monospacedDigit()``, ``Text/foregroundColor(_:)``, and
/// ``Text/bold()`` modifiers.
///
///     var body: some View {
///         let badgeView = Text("\(recentItems.count)")
///             .monospacedDigit()
///             .foregroundColor(.red)
///             .bold()
///
///         List {
///             Text("Recents")
///                 .badge(badgeView)
///             Text("Favorites")
///         }
///     }
///
/// ![A table with two rows, titled Recents and Favorites. The first row
/// shows the number 21 at the side of the row cell. The number badge
/// appears in bold red text with monospaced digits.](View-badge-2)
///
/// Styling the text view has no effect when the badge appears in
/// a ``TabView``.
///
/// - Parameter label: An optional ``Text`` view to display as a badge.
///   Set the value to `nil` to hide the badge.
public func badge(_ label: Text?) -> some View
/// Generates a badge for the view from a localized string key.
///
/// Use a badge to convey optional, supplementary information about a
/// view. Keep the contents of the badge as short as possible. Badges
/// appear only in list rows, tab bars, and menus.
///
/// This modifier creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. For
/// more information about localizing strings, see ``Text``. The following
/// example shows a list with a "Default" badge on one of its rows.
///
///     NavigationView {
///         List(servers) { server in
///             Text(server.name)
///                 .badge(server.isDefault ? "Default" : nil)
///         }
///         .navigationTitle("Servers")
///     }
///
/// ![A table with the navigation title Servers and four rows: North 1,
/// North 2, East 1, and South 1. The North 2 row shows a badge with the
/// text Default on its trailing side.](View-badge-3)
///
/// - Parameter key: An optional string key to display as a badge.
///   Set the value to `nil` to hide the badge.
public func badge(_ key: LocalizedStringKey?) -> some View
/// Generates a badge for the view from a string.
///
/// Use a badge to convey optional, supplementary information about a
/// view. Keep the contents of the badge as short as possible. Badges
/// appear only in list rows, tab bars, and menus.
///
/// This modifier creates a ``Text`` view on your behalf, and treats the
/// localized key similar to ``Text/init(_:)-9d1g4``. The following
/// example shows a list with a "Default" badge on one of its rows.
///
///     NavigationView {
///         List(servers) { server in
///             Text(server.name)
///                 .badge(server.defaultString())
///         }
///         .navigationTitle("Servers")
///     }
///
/// ![A table with the navigation title Servers and four rows: North 1,
/// North 2, East 1, and South 1. The North 2 row shows a badge with the
/// text Default on its trailing side.](View-badge-3)
///
/// - Parameter label: An optional string to display as a badge.
///   Set the value to `nil` to hide the badge.
public func badge<S>(_ label: S?) -> some View where S : StringProtocol
}
@available(iOS 15.0, macOS 12.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension View {
/// Sets the style for control groups within this view.
///
/// - Parameter style: The style to apply to controls within this view.
public func controlGroupStyle<S>(_ style: S) -> some View where S : ControlGroupStyle
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Defines a keyboard shortcut and assigns it to the modified control.
///
/// Pressing the control's shortcut while the control is anywhere in the
/// frontmost window or scene, or anywhere in the macOS main menu, is
/// equivalent to direct interaction with the control to perform its primary
/// action.
///
/// The target of a keyboard shortcut is resolved in a leading-to-trailing,
/// depth-first traversal of one or more view hierarchies. On macOS, the
/// system looks in the key window first, then the main window, and then the
/// command groups; on other platforms, the system looks in the active
/// scene, and then the command groups.
///
/// If multiple controls are associated with the same shortcut, the first
/// one found is used.
///
/// The default localization configuration is set to ``KeyboardShortcut/Localization-swift.struct/automatic``.
public func keyboardShortcut(_ key: KeyEquivalent, modifiers: EventModifiers = .command) -> some View
/// Assigns a keyboard shortcut to the modified control.
///
/// Pressing the control's shortcut while the control is anywhere in the
/// frontmost window or scene, or anywhere in the macOS main menu, is
/// equivalent to direct interaction with the control to perform its primary
/// action.
///
/// The target of a keyboard shortcut is resolved in a leading-to-trailing
/// traversal of one or more view hierarchies. On macOS, the system looks in
/// the key window first, then the main window, and then the command groups;
/// on other platforms, the system looks in the active scene, and then the
/// command groups.
///
/// If multiple controls are associated with the same shortcut, the first
/// one found is used.
public func keyboardShortcut(_ shortcut: KeyboardShortcut) -> some View
/// Assigns an optional keyboard shortcut to the modified control.
///
/// Pressing the control's shortcut while the control is anywhere in the
/// frontmost window or scene, or anywhere in the macOS main menu, is
/// equivalent to direct interaction with the control to perform its primary
/// action.
///
/// The target of a keyboard shortcut is resolved in a leading-to-trailing
/// traversal of one or more view hierarchies. On macOS, the system looks in
/// the key window first, then the main window, and then the command groups;
/// on other platforms, the system looks in the active scene, and then the
/// command groups.
///
/// If multiple controls are associated with the same shortcut, the first
/// one found is used. If the provided shortcut is `nil`, the modifier will
/// have no effect.
@available(iOS 15.4, macOS 12.3, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func keyboardShortcut(_ shortcut: KeyboardShortcut?) -> some View
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Defines a keyboard shortcut and assigns it to the modified control.
///
/// Pressing the control's shortcut while the control is anywhere in the
/// frontmost window or scene, or anywhere in the macOS main menu, is
/// equivalent to direct interaction with the control to perform its primary
/// action.
///
/// The target of a keyboard shortcut is resolved in a leading-to-trailing,
/// depth-first traversal of one or more view hierarchies. On macOS, the
/// system looks in the key window first, then the main window, and then the
/// command groups; on other platforms, the system looks in the active
/// scene, and then the command groups.
///
/// If multiple controls are associated with the same shortcut, the first
/// one found is used.
///
/// ### Localization
///
/// Provide a `localization` value to specify how this shortcut
/// should be localized.
/// Given that `key` is always defined in relation to the US-English
/// keyboard layout, it might be hard to reach on different international
/// layouts. For example the shortcut `⌘[` works well for the
/// US layout but is hard to reach for German users, where
/// `[` is available by pressing `⌥5`, making users type `⌥⌘5`.
/// The automatic keyboard shortcut remapping re-assigns the shortcut to
/// an appropriate replacement, `⌘Ö` in this case.
///
/// Certain shortcuts carry information about directionality. For instance,
/// `⌘[` can reveal a previous view. Following the layout direction of
/// the UI, this shortcut will be automatically mirrored to `⌘]`.
/// However, this does not apply to items such as "Align Left `⌘{`",
/// which will be "left" independently of the layout direction.
/// When the shortcut shouldn't follow the directionality of the UI, but rather
/// be the same in both right-to-left and left-to-right directions, using
/// ``KeyboardShortcut/Localization-swift.struct/withoutMirroring``
/// will prevent the system from flipping it.
///
///     var body: some Commands {
///         CommandMenu("Card") {
///             Button("Align Left") { ... }
///                 .keyboardShortcut("{",
///                      modifiers: .option,
///                      localization: .withoutMirroring)
///             Button("Align Right") { ... }
///                 .keyboardShortcut("}",
///                      modifiers: .option,
///                      localization: .withoutMirroring)
///         }
///     }
///
/// Lastly, providing the option
/// ``KeyboardShortcut/Localization-swift.struct/custom``
/// disables
/// the automatic localization for this shortcut to tell the system that
/// internationalization is taken care of in a different way.
public func keyboardShortcut(_ key: KeyEquivalent, modifiers: EventModifiers = .command, localization: KeyboardShortcut.Localization) -> some View
}
extension View {
/// Sets whether to disable autocorrection for this view.
///
/// Use this method when the effect of autocorrection would
/// make it more difficult for the user to input information. The entry of
/// proper names and street addresses are examples where autocorrection can
/// negatively affect the user's ability complete a data entry task.
///
/// The example below configures a ``TextField`` with the default
/// keyboard. Disabling autocorrection allows the user to enter arbitrary
/// text without the autocorrection system offering suggestions or
/// attempting to override their input.
///
///     TextField("1234 Main St.", text: $address)
///         .keyboardType(.default)
///         .autocorrectionDisabled(true)
///
/// - Parameter disable: A Boolean value that indicates whether
///   autocorrection is disabled for this view. The default value is `true`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 8.0, *)
public func autocorrectionDisabled(_ disable: Bool = true) -> some View
}
extension View {
/// Sets whether to disable autocorrection for this view.
///
/// Use `disableAutocorrection(_:)` when the effect of autocorrection would
/// make it more difficult for the user to input information. The entry of
/// proper names and street addresses are examples where autocorrection can
/// negatively affect the user's ability complete a data entry task.
///
/// In the example below configures a ``TextField`` with the `.default`
/// keyboard. Disabling autocorrection allows the user to enter arbitrary
/// text without the autocorrection system offering suggestions or
/// attempting to override their input.
///
///     TextField("1234 Main St.", text: $address)
///         .keyboardType(.default)
///         .disableAutocorrection(true)
///
/// - Parameter enabled: A Boolean value that indicates whether
///   autocorrection is disabled for this view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "autocorrectionDisabled(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "autocorrectionDisabled(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "autocorrectionDisabled(_:)")
@available(watchOS, introduced: 8.0, deprecated: 100000.0, renamed: "autocorrectionDisabled(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "autocorrectionDisabled(_:)")
public func disableAutocorrection(_ disable: Bool?) -> some View
}
extension View {
@available(iOS 17.0, visionOS 1.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public func searchDictationBehavior(_ dictationBehavior: TextInputDictationBehavior) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Positions this view within an invisible frame with the specified size.
///
/// Use this method to specify a fixed size for a view's width, height, or
/// both. If you only specify one of the dimensions, the resulting view
/// assumes this view's sizing behavior in the other dimension.
///
/// For example, the following code lays out an ellipse in a fixed 200 by
/// 100 frame. Because a shape always occupies the space offered to it by
/// the layout system, the first ellipse is 200x100 points. The second
/// ellipse is laid out in a frame with only a fixed height, so it occupies
/// that height, and whatever width the layout system offers to its parent.
///
///     VStack {
///         Ellipse()
///             .fill(Color.purple)
///             .frame(width: 200, height: 100)
///         Ellipse()
///             .fill(Color.blue)
///             .frame(height: 100)
///     }
///
/// ![A screenshot showing the effect of frame size options: a purple
/// ellipse shows the effect of a fixed frame size, while a blue ellipse
/// shows the effect of constraining a view in one
/// dimension.](SwiftUI-View-frame-1.png)
///
/// `The alignment` parameter specifies this view's alignment within the
/// frame.
///
///     Text("Hello world!")
///         .frame(width: 200, height: 30, alignment: .topLeading)
///         .border(Color.gray)
///
/// In the example above, the text is positioned at the top, leading corner
/// of the frame. If the text is taller than the frame, its bounds may
/// extend beyond the bottom of the frame's bounds.
///
/// ![A screenshot showing the effect of frame size options on a text view
/// showing a fixed frame size with a specified
/// alignment.](SwiftUI-View-frame-2.png)
///
/// - Parameters:
///   - width: A fixed width for the resulting view. If `width` is `nil`,
///     the resulting view assumes this view's sizing behavior.
///   - height: A fixed height for the resulting view. If `height` is `nil`,
///     the resulting view assumes this view's sizing behavior.
///   - alignment: The alignment of this view inside the resulting frame.
///     Note that most alignment values have no apparent effect when the
///     size of the frame happens to match that of this view.
///
/// - Returns: A view with fixed dimensions of `width` and `height`, for the
///   parameters that are non-`nil`.
@inlinable public func frame(width: CGFloat? = nil, height: CGFloat? = nil, alignment: Alignment = .center) -> some View
/// Positions this view within an invisible frame.
///
/// Use ``SwiftUI/View/frame(width:height:alignment:)`` or
/// ``SwiftUI/View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)``
/// instead.
@available(*, deprecated, message: "Please pass one or more parameters.")
@inlinable public func frame() -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Positions this view within an invisible frame having the specified size
/// constraints.
///
/// Always specify at least one size characteristic when calling this
/// method. Pass `nil` or leave out a characteristic to indicate that the
/// frame should adopt this view's sizing behavior, constrained by the other
/// non-`nil` arguments.
///
/// The size proposed to this view is the size proposed to the frame,
/// limited by any constraints specified, and with any ideal dimensions
/// specified replacing any corresponding unspecified dimensions in the
/// proposal.
///
/// If no minimum or maximum constraint is specified in a given dimension,
/// the frame adopts the sizing behavior of its child in that dimension. If
/// both constraints are specified in a dimension, the frame unconditionally
/// adopts the size proposed for it, clamped to the constraints. Otherwise,
/// the size of the frame in either dimension is:
///
/// - If a minimum constraint is specified and the size proposed for the
///   frame by the parent is less than the size of this view, the proposed
///   size, clamped to that minimum.
/// - If a maximum constraint is specified and the size proposed for the
///   frame by the parent is greater than the size of this view, the
///   proposed size, clamped to that maximum.
/// - Otherwise, the size of this view.
///
/// - Parameters:
///   - minWidth: The minimum width of the resulting frame.
///   - idealWidth: The ideal width of the resulting frame.
///   - maxWidth: The maximum width of the resulting frame.
///   - minHeight: The minimum height of the resulting frame.
///   - idealHeight: The ideal height of the resulting frame.
///   - maxHeight: The maximum height of the resulting frame.
///   - alignment: The alignment of this view inside the resulting frame.
///     Note that most alignment values have no apparent effect when the
///     size of the frame happens to match that of this view.
///
/// - Returns: A view with flexible dimensions given by the call's non-`nil`
///   parameters.
@inlinable public func frame(minWidth: CGFloat? = nil, idealWidth: CGFloat? = nil, maxWidth: CGFloat? = nil, minHeight: CGFloat? = nil, idealHeight: CGFloat? = nil, maxHeight: CGFloat? = nil, alignment: Alignment = .center) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Modifies this view by binding its accessibility element's focus state to
/// the given state value.
///
/// - Parameters:
///   - binding: The state binding to register. When accessibility focus moves to the
///     accessibility element of the modified view, SwiftUI sets the bound value to the corresponding
///     match value. If you set the state value programmatically to the matching value, then
///     accessibility focus moves to the accessibility element of the modified view. SwiftUI sets
///     the value to `nil` if accessibility focus leaves the accessibility element associated with the
///     modified view, and programmatically setting the value to `nil` dismisses focus automatically.
///   - value: The value to match against when determining whether the
///     binding should change.
/// - Returns: The modified view.
public func accessibilityFocused<Value>(_ binding: AccessibilityFocusState<Value>.Binding, equals value: Value) -> some View where Value : Hashable
/// Modifies this view by binding its accessibility element's focus state
/// to the given boolean state value.
///
/// - Parameter condition: The accessibility focus state to bind. When
///     accessibility focus moves to the accessibility element of the
///     modified view, the focus value is set to `true`.
///     If the value is set to `true` programmatically, then accessibility
///     focus will move to accessibility element of the modified view.
///     The value will be set to `false` if accessibility focus leaves
///     the accessibility element of the modified view,
///     and accessibility focus will be dismissed automatically if the
///     value is set to `false` programmatically.
///
/// - Returns: The modified view.
public func accessibilityFocused(_ condition: AccessibilityFocusState<Bool>.Binding) -> some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Sets the style for group boxes within this view.
///
/// - Parameter style: The style to apply to boxes within this view.
public func groupBoxStyle<S>(_ style: S) -> some View where S : GroupBoxStyle
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Marks the view as containing sensitive, private user data.
///
/// SwiftUI redacts views marked with this modifier when you apply the
/// ``RedactionReasons/privacy`` redaction reason.
///
///     struct BankAccountView: View {
///         var body: some View {
///             VStack {
///                 Text("Account #")
///
///                 Text(accountNumber)
///                     .font(.headline)
///                     .privacySensitive() // Hide only the account number.
///             }
///         }
///     }
public func privacySensitive(_ sensitive: Bool = true) -> some View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets the available detents for the enclosing sheet.
///
/// By default, sheets support the ``PresentationDetent/large`` detent.
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents([.medium, .large])
///             }
///         }
///     }
///
/// - Parameter detents: A set of supported detents for the sheet.
///   If you provide more that one detent, people can drag the sheet
///   to resize it.
public func presentationDetents(_ detents: Set<PresentationDetent>) -> some View
/// Sets the available detents for the enclosing sheet, giving you
/// programmatic control of the currently selected detent.
///
/// By default, sheets support the ``PresentationDetent/large`` detent.
///
///     struct ContentView: View {
///         @State private var showSettings = false
///         @State private var settingsDetent = PresentationDetent.medium
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents(
///                         [.medium, .large],
///                         selection: $settingsDetent
///                      )
///             }
///         }
///     }
///
/// - Parameters:
///   - detents: A set of supported detents for the sheet.
///     If you provide more that one detent, people can drag the sheet
///     to resize it.
///   - selection: A ``Binding`` to the currently selected detent.
///     Ensure that the value matches one of the detents that you
///     provide for the `detents` parameter.
public func presentationDetents(_ detents: Set<PresentationDetent>, selection: Binding<PresentationDetent>) -> some View
/// Sets the visibility of the drag indicator on top of a sheet.
///
/// You can show a drag indicator when it isn't apparent that a
/// sheet can resize or when the sheet can't dismiss interactively.
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents([.medium, .large])
///                     .presentationDragIndicator(.visible)
///             }
///         }
///     }
///
/// - Parameter visibility: The preferred visibility of the drag indicator.
public func presentationDragIndicator(_ visibility: Visibility) -> some View
}
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
extension View {
/// Controls whether people can interact with the view behind a
/// presentation.
///
/// On many platforms, SwiftUI automatically disables the view behind a
/// sheet that you present, so that people can't interact with the backing
/// view until they dismiss the sheet. Use this modifier if you want to
/// enable interaction.
///
/// The following example enables people to interact with the view behind
/// the sheet when the sheet is at the smallest detent, but not at the other
/// detents:
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents(
///                         [.height(120), .medium, .large])
///                     .presentationBackgroundInteraction(
///                         .enabled(upThrough: .height(120)))
///             }
///         }
///     }
///
/// - Parameters:
///   - interaction: A specification of how people can interact with the
///     view behind a presentation.
public func presentationBackgroundInteraction(_ interaction: PresentationBackgroundInteraction) -> some View
/// Specifies how to adapt a presentation to compact size classes.
///
/// Some presentations adapt their appearance depending on the context. For
/// example, a sheet presentation over a vertically-compact view uses a
/// full-screen-cover appearance by default. Use this modifier to indicate
/// a custom adaptation preference. For example, the following code
/// uses a presentation adaptation value of ``PresentationAdaptation/none``
/// to request that the system not adapt the sheet in compact size classes:
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents([.medium, .large])
///                     .presentationCompactAdaptation(.none)
///             }
///         }
///     }
///
/// If you want to specify different adaptations for each dimension,
/// use the ``View/presentationCompactAdaptation(horizontal:vertical:)``
/// method instead.
///
/// - Parameter adaptation: The adaptation to use in either a horizontally
///   or vertically compact size class.
public func presentationCompactAdaptation(_ adaptation: PresentationAdaptation) -> some View
/// Specifies how to adapt a presentation to horizontally and vertically
/// compact size classes.
///
/// Some presentations adapt their appearance depending on the context. For
/// example, a popover presentation over a horizontally-compact view uses a
/// sheet appearance by default. Use this modifier to indicate a custom
/// adaptation preference.
///
///     struct ContentView: View {
///         @State private var showInfo = false
///
///         var body: some View {
///             Button("View Info") {
///                 showInfo = true
///             }
///             .popover(isPresented: $showInfo) {
///                 InfoView()
///                     .presentationCompactAdaptation(
///                         horizontal: .popover,
///                         vertical: .sheet)
///             }
///         }
///     }
///
/// If you want to specify the same adaptation for both dimensions,
/// use the ``View/presentationCompactAdaptation(_:)`` method instead.
///
/// - Parameters:
///   - horizontalAdaptation: The adaptation to use in a horizontally
///     compact size class.
///   - verticalAdaptation: The adaptation to use in a vertically compact
///     size class. In a size class that is both horizontally and vertically
///     compact, SwiftUI uses the `verticalAdaptation` value.
public func presentationCompactAdaptation(horizontal horizontalAdaptation: PresentationAdaptation, vertical verticalAdaptation: PresentationAdaptation) -> some View
/// Requests that the presentation have a specific corner radius.
///
/// Use this modifier to change the corner radius of a presentation.
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents([.medium, .large])
///                     .presentationCornerRadius(21)
///             }
///         }
///     }
///
/// - Parameter cornerRadius: The corner radius, or `nil` to use the system
///   default.
public func presentationCornerRadius(_ cornerRadius: CGFloat?) -> some View
/// Configures the behavior of swipe gestures on a presentation.
///
/// By default, when a person swipes up on a scroll view in a resizable
/// presentation, the presentation grows to the next detent. A scroll view
/// embedded in the presentation only scrolls after the presentation
/// reaches its largest size. Use this modifier to control which action
/// takes precedence.
///
/// For example, you can request that swipe gestures scroll content first,
/// resizing the sheet only after hitting the end of the scroll view, by
/// passing the ``PresentationContentInteraction/scrolls`` value to this
/// modifier:
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationDetents([.medium, .large])
///                     .presentationContentInteraction(.scrolls)
///             }
///         }
///     }
///
/// People can always resize your presentation using the drag indicator.
///
/// - Parameter behavior: The requested behavior.
public func presentationContentInteraction(_ behavior: PresentationContentInteraction) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Sets whether buttons in this view should repeatedly trigger their
/// actions on prolonged interactions.
///
/// Apply this to buttons that increment or decrement a value or perform
/// some other inherently iterative operation. Interactions such as
/// pressing-and-holding on the button, holding the button's keyboard
/// shortcut, or holding down the space key while the button is focused will
/// trigger this repeat behavior.
///
///     Button {
///         playbackSpeed.advance(by: 1)
///     } label: {
///         Label("Speed up", systemImage: "hare")
///     }
///     .buttonRepeatBehavior(.enabled)
///
/// This affects all system button styles, as well as automatically
/// affects custom `ButtonStyle` conforming types. This does not
/// automatically apply to custom `PrimitiveButtonStyle` conforming types,
/// and the ``EnvironmentValues.buttonRepeatBehavior`` value should be used
/// to adjust their custom gestures as appropriate.
///
/// - Parameter behavior: A value of `enabled` means that buttons should
///   enable repeating behavior and a value of `disabled` means that buttons
///   should disallow repeating behavior.
public func buttonRepeatBehavior(_ behavior: ButtonRepeatBehavior) -> some View
}
extension View {
/// Applies a text scale to text in the view.
///
/// - Parameters:
///   - scale: The text scale to apply.
///   - isEnabled: If true the text scale is applied; otherwise text scale
///     is unchanged.
/// - Returns: A view with the specified text scale applied.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func textScale(_ scale: Text.Scale, isEnabled: Bool = true) -> some View
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Adds an item-based context menu to a view.
///
/// You can add an item-based context menu to a container that supports
/// selection, like a ``List`` or a ``Table``. In the closure that you
/// use to define the menu, you receive a collection of items that
/// depends on the selection state of the container and the location where
/// the person clicks or taps to activate the menu. The collection contains:
///
/// * The selected item or items, when people initiate the context menu
///   from any selected item.
/// * Nothing, if people tap or click to activate the context menu from
///   an empty part of the container. This is true even when one or more
///   items is currently selected.
///
/// You can vary the menu contents according to the number of selected
/// items. For example, the following code has a list that defines an
/// empty area menu, a single item menu, and a multi-item menu:
///
///     struct ContextMenuItemExample: View {
///         var items: [Item]
///         @State private var selection = Set<Item.ID>()
///
///         var body: some View {
///             List(selection: $selection) {
///                 ForEach(items) { item in
///                     Text(item.name)
///                 }
///             }
///             .contextMenu(forSelectionType: Item.ID.self) { items in
///                 if items.isEmpty { // Empty area menu.
///                     Button("New Item") { }
///
///                 } else if items.count == 1 { // Single item menu.
///                     Button("Copy") { }
///                     Button("Delete", role: .destructive) { }
///
///                 } else { // Multi-item menu.
///                     Button("Copy") { }
///                     Button("New Folder With Selection") { }
///                     Button("Delete Selected", role: .destructive) { }
///                 }
///             }
///         }
///     }
///
/// The above example assumes that the `Item` type conforms to the
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>
/// protocol, and relies on the associated `ID` type for both selection
/// and context menu presentation.
///
/// If you add the modifier to a view hierarchy that doesn't have a
/// container that supports selection, the context menu never activates.
/// To add a context menu that doesn't depend on selection behavior, use
/// ``View/contextMenu(menuItems:)``. To add a context menu to a specific
/// row in a table, use ``TableRowContent/contextMenu(menuItems:)``.
///
/// ### Add a primary action
///
/// Optionally, you can add a custom primary action to the context menu. In
/// macOS, a single click on a row in a selectable container selects that
/// row, and a double click performs the primary action. In iOS and iPadOS,
/// tapping on the row activates the primary action. To select a row
/// without performing an action, either enter edit mode or hold
/// shift or command on a keyboard while tapping the row.
///
/// For example, you can modify the context menu from the previous example
/// so that double clicking the row on macOS opens a new window for
/// selected items. Get the ``OpenWindowAction`` from the environment:
///
///     @Environment(\.openWindow) private var openWindow
///
/// Then call ``EnvironmentValues/openWindow`` from inside the
/// `primaryAction` closure for each item:
///
///     .contextMenu(forSelectionType: Item.ID.self) { items in
///         // ...
///     } primaryAction: { items in
///         for item in items {
///             openWindow(value: item)
///         }
///     }
///
/// The open window action depends on the declaration of a ``WindowGroup``
/// scene in your ``App`` that responds to the `Item` type:
///
///     WindowGroup("Item Detail", for: Item.self) { $item in
///         // ...
///     }
///
/// - Parameters:
///   - itemType: The identifier type of the items. Ensure that this
///     matches the container's selection type.
///   - menu: A closure that produces the menu. A single parameter to the
///     closure contains the set of items to act on. An empty set indicates
///     menu activation over the empty area of the selectable container,
///     while a non-empty set indicates menu activation over selected items.
///     Use controls like ``Button``, ``Picker``, and ``Toggle`` to define
///     the menu items. You can also create submenus using ``Menu``, or
///     group items with ``Section``. You can deactivate the context menu
///     by returning nothing from the closure.
///   - primaryAction: A closure that defines the action to perform in
///     response to the primary interaction. A single parameter to the
///     closure contains the set of items to act on.
///
/// - Returns: A view that can display an item-based context menu.
public func contextMenu<I, M>(forSelectionType itemType: I.Type = I.self, @ViewBuilder menu: @escaping (Set<I>) -> M, primaryAction: ((Set<I>) -> Void)? = nil) -> some View where I : Hashable, M : View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system interface for allowing the user to move an existing
/// file to a new location.
///
/// - Note: This interface provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `file` must not be `nil`. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - file: The `URL` of the file to be moved.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed. To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileMover(isPresented: Binding<Bool>, file: URL?, onCompletion: @escaping (_ result: Result<URL, Error>) -> Void) -> some View
/// Presents a system interface for allowing the user to move a collection
/// of existing files to a new location.
///
/// - Note: This interface provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `files` must not be empty. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - files: A collection of `URL`s for the files to be moved.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed. To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileMover<C>(isPresented: Binding<Bool>, files: C, onCompletion: @escaping (_ result: Result<[URL], Error>) -> Void) -> some View where C : Collection, C.Element == URL
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system dialog for allowing the user to move
/// an existing file to a new location.
///
/// - Note: This dialog provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// For example, a button that allows the user to move a file might look like this:
///
///       struct MoveFileButton: View {
///           @State private var showFileMover = false
///           var file: URL
///           var onCompletion: (URL) -> Void
///           var onCancellation: (() -> Void)?
///
///           var body: some View {
///               Button {
///                   showFileMover = true
///               } label: {
///                   Label("Choose destination", systemImage: "folder.circle")
///               }
///               .fileMover(isPresented: $showFileMover, file: file) { result in
///                   switch result {
///                   case .success(let url):
///                       guard url.startAccessingSecurityScopedResource() else {
///                           return
///                       }
///                       onCompletion(url)
///                       url.stopAccessingSecurityScopedResource()
///                   case .failure(let error):
///                       print(error)
///                       // handle error
///                   }
///               } onCancellation: {
///                   onCancellation?()
///               }
///           }
///       }
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - file: The URL of the file to be moved.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed. To access the received URLs, call
///     `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileMover(isPresented: Binding<Bool>, file: URL?, onCompletion: @escaping (Result<URL, Error>) -> Void, onCancellation: @escaping () -> Void) -> some View
/// Presents a system dialog for allowing the user to move
/// a collection of existing files to a new location.
///
/// - Note: This dialog provides security-scoped URLs.
///   Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
///   the URLs, and the ``stopAccessingSecurityScopedResource`` method
///   to release the access.
///
/// For example, a button that allows the user to move files might look like this:
///
///       struct MoveFilesButton: View {
///           @Binding var files: [URL]
///           @State private var showFileMover = false
///           var onCompletion: (URL) -> Void
///           var onCancellation: (() -> Void)?
///
///           var body: some View {
///               Button {
///                   showFileMover = true
///               } label: {
///                   Label("Choose destination", systemImage: "folder.circle")
///               }
///               .fileMover(isPresented: $showFileMover, files: files) { result in
///                   switch result {
///                   case .success(let urls):
///                       urls.forEach { url in
///                           guard url.startAccessingSecurityScopedResource() else {
///                               return
///                           }
///                           onCompletion(url)
///                           url.stopAccessingSecurityScopedResource()
///                       }
///                   case .failure(let error):
///                       print(error)
///                       // handle error
///                   }
///               } onCancellation: {
///                   onCancellation?()
///               }
///           }
///       }
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - files: A collection of URLs for the files to be moved.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed.
///     To access the received URLs, call `startAccessingSecurityScopedResource`.
///     When the access is no longer required, call `stopAccessingSecurityScopedResource`.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileMover<C>(isPresented: Binding<Bool>, files: C, onCompletion: @escaping (Result<[URL], Error>) -> Void, onCancellation: @escaping () -> Void) -> some View where C : Collection, C.Element == URL
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Controls whether people can select text within this view.
///
/// People sometimes need to copy useful information from ``Text`` views ---
/// including error messages, serial numbers, or IP addresses --- so they
/// can then paste the text into another context. Enable text selection
/// to let people select text in a platform-appropriate way.
///
/// You can apply this method to an individual text view, or to a
/// container to make each contained text view selectable. In the following
/// example, the person using the app can select text that shows the date of
/// an event or the name or email of any of the event participants:
///
///     var body: some View {
///         VStack {
///             Text("Event Invite")
///                 .font(.title)
///             Text(invite.date.formatted(date: .long, time: .shortened))
///                 .textSelection(.enabled)
///
///             List(invite.recipients) { recipient in
///                 VStack (alignment: .leading) {
///                     Text(recipient.name)
///                     Text(recipient.email)
///                         .foregroundStyle(.secondary)
///                 }
///             }
///             .textSelection(.enabled)
///         }
///         .navigationTitle("New Invitation")
///     }
///
/// On macOS, people use the mouse or trackpad to select a range of text,
/// which they can quickly copy by choosing Edit > Copy, or with the
/// standard keyboard shortcut.
///
/// ![A macOS window titled New Invitation, with header Event Invite and
/// the date and time of the event below it. The date --- July 31, 2022 ---
/// is selected. Below this, a list of invitees by name and
/// email.](View-textSelection-1)
///
/// On iOS, the person using the app touches and holds on a selectable
/// `Text` view, which brings up a system menu with menu items appropriate
/// for the current context. These menu items operate on the entire contents
/// of the `Text` view; the person can't select a range of text like they
/// can on macOS.
///
/// ![A portion of an iOS view, with header Event Invite and
/// the date and time of the event below it. Below the date and time, a
/// menu shows two items: Copy and Share. Below this, a list of invitees by
/// name and email.](View-textSelection-2)
///
/// - Note: ``Button`` views don't support text selection.
public func textSelection<S>(_ selectability: S) -> some View where S : TextSelectability
}
extension View {
/// Specifies if the view is focusable.
///
/// - Parameters isFocusable: A Boolean value that indicates whether this
///   view is focusable.
///
/// - Returns: A view that sets whether a view is focusable.
@available(iOS 17.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func focusable(_ isFocusable: Bool = true) -> some View
/// Specifies if the view is focusable, and if so, what focus-driven
/// interactions it supports.
///
/// By default, SwiftUI enables all possible focus interactions. However, on
/// macOS and iOS it is conventional for button-like views to only accept
/// focus when the user has enabled keyboard navigation system-wide in the
/// Settings app. Clients can reproduce this behavior with custom views by
/// only supporting `.activate` interactions.
///
///     MyTapGestureView(...)
///         .focusable(interactions: .activate)
///
/// - Note: The focus interactions allowed for custom views changed in
///   macOS 14—previously, custom views could only become focused with
///   keyboard navigation enabled system-wide. Clients built using older
///   SDKs will continue to see the older focus behavior, while custom views
///   in clients built using macOS 14 or later will always be focusable
///   unless the client requests otherwise by specifying a restricted set of
///   focus interactions.
///
/// - Parameters:
///   - isFocusable: `true` if the view should participate in focus;
///     `false` otherwise. The default value is `true`.
///   - interactions: The types of focus interactions supported by the view.
///     The default value is `.automatic`.
/// - Returns: A view that sets whether its child is focusable.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func focusable(_ isFocusable: Bool = true, interactions: FocusInteractions) -> some View
/// Adds a condition that controls whether this view can display focus
/// effects, such as a default focus ring or hover effect.
///
/// The higher views in a view hierarchy can override the value you set on
/// this view. In the following example, the button does not display a focus
/// effect because the outer `focusEffectDisabled(_:)` modifier overrides
/// the inner one:
///
///     HStack {
///         Button("Press") {}
///             .focusEffectDisabled(false)
///     }
///     .focusEffectDisabled(true)
///
/// - Parameter disabled: A Boolean value that determines whether this view
///   can display focus effects.
/// - Returns: A view that controls whether focus effects can be displayed
///   in this view.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func focusEffectDisabled(_ disabled: Bool = true) -> some View
}
extension View {
/// Configures the semantic role for the content populating the toolbar.
///
/// Use this modifier to configure the semantic role for content
/// populating your app's toolbar. SwiftUI uses this role when
/// rendering the content of your app's toolbar.
///
///     ContentView()
///         .navigationTitle("Browser")
///         .toolbarRole(.browser)
///         .toolbar {
///             ToolbarItem(placement: .primaryAction) {
///                 AddButton()
///             }
///          }
///
/// - Parameter role: The role of the toolbar.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func toolbarRole(_ role: ToolbarRole) -> some View
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system interface for exporting a document that's stored in
/// a value type, like a structure, to a file on disk.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `document` must not be `nil`. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// The `contentType` provided must be included within the document type's
/// `writableContentTypes`, otherwise the first valid writable content type
/// will be used instead.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - document: The in-memory document to export.
///   - contentType: The content type to use for the exported file.
///   - defaultFilename: If provided, the default name to use for the
///     exported file, which will the user will have an opportunity to edit
///     prior to the export.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileExporter<D>(isPresented: Binding<Bool>, document: D?, contentType: UTType, defaultFilename: String? = nil, onCompletion: @escaping (_ result: Result<URL, Error>) -> Void) -> some View where D : FileDocument
/// Presents a system interface for exporting a collection of value type
/// documents to files on disk.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `documents` must not be empty. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// The `contentType` provided must be included within the document type's
/// `writableContentTypes`, otherwise the first valid writable content type
/// will be used instead.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - documents: The collection of in-memory documents to export.
///   - contentType: The content type to use for the exported file.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentType: UTType, onCompletion: @escaping (_ result: Result<[URL], Error>) -> Void) -> some View where C : Collection, C.Element : FileDocument
/// Presents a system interface for exporting a document that's stored in
/// a reference type, like a class, to a file on disk.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `document` must not be `nil`. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// The `contentType` provided must be included within the document type's
/// `writableContentTypes`, otherwise the first valid writable content type
/// will be used instead.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - document: The in-memory document to export.
///   - contentType: The content type to use for the exported file.
///   - defaultFilename: If provided, the default name to use for the
///     exported file, which will the user will have an opportunity to edit
///     prior to the export.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileExporter<D>(isPresented: Binding<Bool>, document: D?, contentType: UTType, defaultFilename: String? = nil, onCompletion: @escaping (_ result: Result<URL, Error>) -> Void) -> some View where D : ReferenceFileDocument
/// Presents a system interface for exporting a collection of reference type
/// documents to files on disk.
///
/// In order for the interface to appear, both `isPresented` must be `true`
/// and `documents` must not be empty. When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// The `contentType` provided must be included within the document type's
/// `writableContentTypes`, otherwise the first valid writable content type
/// will be used instead.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - documents: The collection of in-memory documents to export.
///   - contentType: The content type to use for the exported file.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed.
///   - result: A `Result` indicating whether the operation succeeded or
///     failed.
public func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentType: UTType, onCompletion: @escaping (_ result: Result<[URL], Error>) -> Void) -> some View where C : Collection, C.Element : ReferenceFileDocument
}
@available(iOS 17.0, macOS 14.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Presents a system interface allowing the user to export
/// a `Transferable` item to file on disk.
///
/// In order for the interface to appear `isPresented` must be set to `true`.
/// When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - item: The item to be saved on disk.
///   - contentTypes: The optional content types to use for the exported file.
///     If empty, SwiftUI uses the content types from the `transferRepresentation`
///     property provided for `Transferable` conformance.
///   - onCompletion: A callback that will be invoked when the operation
///     has succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the operation was cancelled.
public func fileExporter<T>(isPresented: Binding<Bool>, item: T?, contentTypes: [UTType] = [], defaultFilename: String? = nil, onCompletion: @escaping (Result<URL, Error>) -> Void, onCancellation: @escaping () -> Void = { }) -> some View where T : Transferable
/// Presents a system interface allowing the user to export
/// a collection of items to files on disk.
///
/// In order for the interface to appear `isPresented` must be set to `true`.
/// When the operation is finished,
/// `isPresented` will be set to `false` before `onCompletion` is called. If
/// the user cancels the operation, `isPresented` will be set to `false` and
/// `onCompletion` will not be called.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - items: Collection of values to be saved on disk.
///   - contentTypes: The content types to use for the exported file.
///     If empty, SwiftUI uses the content types from the `transferRepresentation`
///     property provided for `Transferable` conformance.
///   - allowsOtherContentTypes: A Boolean value that indicates if the users
///     are allowed to save the files with a different file extension than
///     specified by the `contentType` property.
///   - onCompletion: A callback that will be invoked when the operation has
///     has succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the operation was cancelled.
public func fileExporter<C, T>(isPresented: Binding<Bool>, items: C, contentTypes: [UTType] = [], onCompletion: @escaping (Result<[URL], Error>) -> Void, onCancellation: @escaping () -> Void = { }) -> some View where C : Collection, T : Transferable, T == C.Element
/// Presents a system interface for allowing the user to export a
/// `FileDocument` to a file on disk.
///
/// In order for the interface to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCancellation` will be
/// called.
///
/// - Parameters:
///   - isPresented: A binding to whether the interface should be shown.
///   - document: The in-memory document to export.
///   - contentTypes: The list of supported content types which can
///     be exported. If not provided, `FileDocument.writableContentTypes`
///     are used.
///   - defaultFilename: If provided, the default name to use
///     for the exported file, which will the user will have
///     an opportunity to edit prior to the export.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileExporter<D>(isPresented: Binding<Bool>, document: D?, contentTypes: [UTType] = [], defaultFilename: String? = nil, onCompletion: @escaping (Result<URL, Error>) -> Void, onCancellation: @escaping () -> Void = {}) -> some View where D : FileDocument
/// Presents a system dialog for allowing the user to export a
/// `ReferenceFileDocument` to a file on disk.
///
/// In order for the dialog to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCancellation` will be
/// called.
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - document: The in-memory document to export.
///   - contentTypes: The list of supported content types which can
///     be exported. If not provided, `ReferenceFileDocument.writableContentTypes`
///     are used.
///   - defaultFilename: If provided, the default name to use
///     for the exported file, which will the user will have
///     an opportunity to edit prior to the export.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileExporter<D>(isPresented: Binding<Bool>, document: D?, contentTypes: [UTType] = [], defaultFilename: String? = nil, onCompletion: @escaping (Result<URL, Error>) -> Void, onCancellation: @escaping () -> Void = {}) -> some View where D : ReferenceFileDocument
/// Presents a system dialog for allowing the user to export a
/// collection of documents that conform to `FileDocument`
/// to files on disk.
///
/// In order for the dialog to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCancellation` will be
/// called.
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - documents: The in-memory documents to export.
///   - contentTypes: The list of supported content types which can
///     be exported. If not provided, `FileDocument.writableContentTypes`
///     are used.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentTypes: [UTType] = [], onCompletion: @escaping (Result<[URL], Error>) -> Void, onCancellation: @escaping () -> Void = {}) -> some View where C : Collection, C.Element : FileDocument
/// Presents a system dialog for allowing the user to export a
/// collection of documents that conform to `ReferenceFileDocument`
/// to files on disk.
///
/// In order for the dialog to appear, `isPresented` must be `true`. When
/// the operation is finished, `isPresented` will be set to `false` before
/// `onCompletion` is called. If the user cancels the operation,
/// `isPresented` will be set to `false` and `onCancellation` will be
/// called.
///
/// - Parameters:
///   - isPresented: A binding to whether the dialog should be shown.
///   - documents: The in-memory documents to export.
///   - contentTypes: The list of supported content types which can
///     be exported. If not provided, `ReferenceFileDocument.writableContentTypes`
///     are used.
///   - onCompletion: A callback that will be invoked when the operation has
///     succeeded or failed. The `result` indicates whether
///     the operation succeeded or failed.
///   - onCancellation: A callback that will be invoked
///     if the user cancels the operation.
public func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentTypes: [UTType] = [], onCompletion: @escaping (Result<[URL], Error>) -> Void, onCancellation: @escaping () -> Void = {}) -> some View where C : Collection, C.Element : ReferenceFileDocument
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Sets the rendering mode for symbol images within this view.
///
/// - Parameter mode: The symbol rendering mode to use.
///
/// - Returns: A view that uses the rendering mode you supply.
@inlinable public func symbolRenderingMode(_ mode: SymbolRenderingMode?) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Conditionally prevents interactive dismissal of presentations like
/// popovers, sheets, and inspectors.
///
/// Users can dismiss certain kinds of presentations using built-in
/// gestures. In particular, a user can dismiss a sheet by dragging it down,
/// or a popover by clicking or tapping outside of the presented view. Use
/// the `interactiveDismissDisabled(_:)` modifier to conditionally prevent
/// this kind of dismissal. You typically do this to prevent the user from
/// dismissing a presentation before providing needed data or completing
/// a required action.
///
/// For instance, suppose you have a view that displays a licensing
/// agreement that the user must acknowledge before continuing:
///
///     struct TermsOfService: View {
///         @Binding var areTermsAccepted: Bool
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             Form {
///                 Text("License Agreement")
///                     .font(.title)
///                 Text("Terms and conditions go here.")
///                 Button("Accept") {
///                     areTermsAccepted = true
///                     dismiss()
///                 }
///             }
///         }
///     }
///
/// If you present this view in a sheet, the user can dismiss it by either
/// tapping the button --- which calls ``EnvironmentValues/dismiss``
/// from its `action` closure --- or by dragging the sheet down. To
/// ensure that the user accepts the terms by tapping the button,
/// disable interactive dismissal, conditioned on the `areTermsAccepted`
/// property:
///
///     struct ContentView: View {
///         @State private var isSheetPresented = false
///         @State private var areTermsAccepted = false
///
///         var body: some View {
///             Button("Use Service") {
///                 isSheetPresented = true
///             }
///             .sheet(isPresented: $isSheetPresented) {
///                 TermsOfService()
///                     .interactiveDismissDisabled(!areTermsAccepted)
///             }
///         }
///     }
///
/// You can apply the modifier to any view in the sheet's view hierarchy,
/// including to the sheet's top level view, as the example demonstrates,
/// or to any child view, like the ``Form`` or the Accept ``Button``.
///
/// The modifier has no effect on programmatic dismissal, which you can
/// invoke by updating the ``Binding`` that controls the presentation, or
/// by calling the environment's ``EnvironmentValues/dismiss`` action.
/// On macOS, disabling interactive dismissal in a popover makes the popover
/// nontransient.
///
/// - Parameter isDisabled: A Boolean value that indicates whether to
///   prevent nonprogrammatic dismissal of the containing view hierarchy
///   when presented in a sheet or popover.
public func interactiveDismissDisabled(_ isDisabled: Bool = true) -> some View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Creates a new accessibility element, or modifies the
/// ``AccessibilityChildBehavior`` of the existing accessibility element.
///
/// See also:
/// - ``AccessibilityChildBehavior/ignore``
/// - ``AccessibilityChildBehavior/combine``
/// - ``AccessibilityChildBehavior/contain``
///
/// - Parameters:
///     -   children: The behavior to use when creating or
///     transforming an accessibility element.
///     The default is ``AccessibilityChildBehavior/ignore``
public func accessibilityElement(children: AccessibilityChildBehavior = .ignore) -> some View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds the given traits to the view.
public func accessibilityAddTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Removes the given traits from this view.
public func accessibilityRemoveTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
extension View {
/// Adds the given traits to the view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)")
public func accessibility(addTraits traits: AccessibilityTraits) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Removes the given traits from this view.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
@available(visionOS, introduced: 1.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)")
public func accessibility(removeTraits traits: AccessibilityTraits) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Sets a style for labeled content.
public func labeledContentStyle<S>(_ style: S) -> some View where S : LabeledContentStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets a value for the given preference.
@inlinable public func preference<K>(key: K.Type = K.self, value: K.Value) -> some View where K : PreferenceKey
}
extension View {
/// Adds an action to perform when this view recognizes a tap gesture,
/// and provides the action with the location of the interaction.
///
/// Use this method to perform the specified `action` when the user clicks
/// or taps on the modified view `count` times. The action closure receives
/// the location of the interaction.
///
/// > Note: If you create a control that's functionally equivalent
/// to a ``Button``, use ``ButtonStyle`` to create a customized button
/// instead.
///
/// The following code adds a tap gesture to a ``Circle`` that toggles the color
/// of the circle based on the tap location.
///
///     struct TapGestureExample: View {
///         @State private var location: CGPoint = .zero
///
///         var body: some View {
///             Circle()
///                 .fill(self.location.y > 50 ? Color.blue : Color.red)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .onTapGesture { location in
///                     self.location = location
///                 }
///         }
///     }
///
/// - Parameters:
///    - count: The number of taps or clicks required to trigger the action
///      closure provided in `action`. Defaults to `1`.
///    - coordinateSpace: The coordinate space in which to receive
///      location values. Defaults to ``CoordinateSpace/local``.
///    - action: The action to perform. This closure receives an input
///      that indicates where the interaction occurred.
@available(iOS, introduced: 16.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(macOS, introduced: 13.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(watchOS, introduced: 9.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
@available(tvOS, unavailable)
@available(visionOS, introduced: 1.0, deprecated: 100000.0, message: "use overload that accepts a CoordinateSpaceProtocol instead")
public func onTapGesture(count: Int = 1, coordinateSpace: CoordinateSpace = .local, perform action: @escaping (CGPoint) -> Void) -> some View
}
extension View {
/// Adds an action to perform when this view recognizes a tap gesture,
/// and provides the action with the location of the interaction.
///
/// Use this method to perform the specified `action` when the user clicks
/// or taps on the modified view `count` times. The action closure receives
/// the location of the interaction.
///
/// > Note: If you create a control that's functionally equivalent
/// to a ``Button``, use ``ButtonStyle`` to create a customized button
/// instead.
///
/// The following code adds a tap gesture to a ``Circle`` that toggles the color
/// of the circle based on the tap location.
///
///     struct TapGestureExample: View {
///         @State private var location: CGPoint = .zero
///
///         var body: some View {
///             Circle()
///                 .fill(self.location.y > 50 ? Color.blue : Color.red)
///                 .frame(width: 100, height: 100, alignment: .center)
///                 .onTapGesture { location in
///                     self.location = location
///                 }
///         }
///     }
///
/// - Parameters:
///    - count: The number of taps or clicks required to trigger the action
///      closure provided in `action`. Defaults to `1`.
///    - coordinateSpace: The coordinate space in which to receive
///      location values. Defaults to ``CoordinateSpace/local``.
///    - action: The action to perform. This closure receives an input
///      that indicates where the interaction occurred.
@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
@available(tvOS, unavailable)
public func onTapGesture(count: Int = 1, coordinateSpace: some CoordinateSpaceProtocol = .local, perform action: @escaping (CGPoint) -> Void) -> some View
}
extension View {
/// Sets a tag that you use for tracking interactivity.
///
/// The following example tracks the scrolling activity of a ``List``:
///
///     List {
///         Section("Today") {
///             ForEach(messageStore.today) { message in
///                 Text(message.title)
///             }
///         }
///     }
///     .interactionActivityTrackingTag("MessagesList")
///
/// The resolved activity tracking tag is additive, so using the
/// modifier across the view hierarchy builds the tag from top to
/// bottom. The example below shows a hierarchical usage of this
/// modifier with the resulting tag `Home-Feed`:
///
///     var body: some View {
///         Home()
///             .interactionActivityTrackingTag("Home")
///     }
///
///     struct Home: View {
///         var body: some View {
///             List {
///                 Text("A List Item")
///                 Text("A Second List Item")
///                 Text("A Third List Item")
///             }
///             .interactionActivityTrackingTag("Feed")
///         }
///     }
///
/// - Parameter tag: The tag used to track user interactions
///   hosted by this view as activities.
///
/// - Returns: A view that uses a tracking tag.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func interactionActivityTrackingTag(_ tag: String) -> some View
}
@available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
extension View {
/// Sets the presentation background of the enclosing sheet using a shape
/// style.
///
/// The following example uses the ``Material/thick`` material as the sheet
/// background:
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationBackground(.thickMaterial)
///             }
///         }
///     }
///
/// The `presentationBackground(_:)` modifier differs from the
/// ``View/background(_:ignoresSafeAreaEdges:)`` modifier in several key
/// ways. A presentation background:
///
/// * Automatically fills the entire presentation.
/// * Allows views behind the presentation to show through translucent
///   styles.
///
/// - Parameter style: The shape style to use as the presentation
///   background.
public func presentationBackground<S>(_ style: S) -> some View where S : ShapeStyle
/// Sets the presentation background of the enclosing sheet to a custom
/// view.
///
/// The following example uses a yellow view as the sheet background:
///
///     struct ContentView: View {
///         @State private var showSettings = false
///
///         var body: some View {
///             Button("View Settings") {
///                 showSettings = true
///             }
///             .sheet(isPresented: $showSettings) {
///                 SettingsView()
///                     .presentationBackground {
///                         Color.yellow
///                     }
///             }
///         }
///     }
///
/// The `presentationBackground(alignment:content:)` modifier differs from
/// the ``View/background(alignment:content:)`` modifier in several key
/// ways. A presentation background:
///
/// * Automatically fills the entire presentation.
/// * Allows views behind the presentation to show through translucent
///   areas of the `content`.
///
/// - Parameters:
///   - alignment: The alignment that the modifier uses to position the
///     implicit ``ZStack`` that groups the background views. The default is
///     ``Alignment/center``.
///   - content: The view to use as the background of the presentation.
public func presentationBackground<V>(alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View where V : View
}
extension View {
/// Sets the rename action in the environment to update focus state.
///
/// Use this modifier in conjunction with the ``RenameButton`` to implement
/// standard rename interactions. A rename button receives its action
/// from the environment. Use this modifier to customize the action
/// provided to the rename button.
///
///     struct RowView: View {
///         @State private var text = ""
///         @FocusState private var isFocused: Bool
///
///         var body: some View {
///             TextField(text: $item.name) {
///                 Text("Prompt")
///             }
///             .focused($isFocused)
///             .contextMenu {
///                 RenameButton()
///                 // ... your own custom actions
///             }
///             .renameAction($isFocused)
///     }
///
/// When someone taps the rename button in the context menu, the rename
/// action focuses the text field by setting the `isFocused`
/// property to true.
///
/// - Parameter isFocused: The focus binding to update when
///   activating the rename action.
///
/// - Returns: A view that has the specified rename action.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func renameAction(_ isFocused: FocusState<Bool>.Binding) -> some View
/// Sets a closure to run for the rename action.
///
/// Use this modifier in conjunction with the ``RenameButton`` to implement
/// standard rename interactions. A rename button receives its action
/// from the environment. Use this modifier to customize the action
/// provided to the rename button.
///
///     struct RowView: View {
///         @State private var text = ""
///         @FocusState private var isFocused: Bool
///
///         var body: some View {
///             TextField(text: $item.name) {
///                 Text("Prompt")
///             }
///             .focused($isFocused)
///             .contextMenu {
///                 RenameButton()
///                 // ... your own custom actions
///             }
///             .renameAction { isFocused = true }
///     }
///
/// When the user taps the rename button in the context menu, the rename
/// action focuses the text field by setting the `isFocused`
/// property to true.
///
/// - Parameter action: A closure to run when renaming.
///
/// - Returns: A view that has the specified rename action.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public func renameAction(_ action: @escaping () -> Void) -> some View
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ value: Text?, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter valueKey: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter key: Key used to specify the identifier and label of the
///   of the additional accessibility information entry.
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape." A value of `nil` will remove
///   any entry of additional information added earlier for any `key` with
///   the same identifier.
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s
///   having different identifiers will create new entries of
///   additional information.
///   Calling `accessibilityAdditionalContent` repeatedly with `key`s
///   having matching identifiers will replace the previous entry.
public func accessibilityCustomContent<V>(_ key: AccessibilityCustomContentKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where V : StringProtocol
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example: `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter label: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ label: Text, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example: `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter label: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Add additional accessibility information to the view.
///
/// Use this method to add information you want accessibility users to be
/// able to access about this element, beyond the basics of label, value,
/// and hint. For example, `accessibilityCustomContent` can be used to add
/// information about the orientation of a photograph, or the number of
/// people found in the picture.
///
/// - Parameter labelKey: Localized text describing to the user what
///   is contained in this additional information entry. For example:
///   "orientation".
/// - Parameter value: Text value for the additional accessibility
///   information. For example: "landscape."
/// - Parameter importance: Importance of the accessibility information.
///   High-importance information gets read out immediately, while
///   default-importance information must be explicitly asked for by the
///   user.
/// - Note: Repeated calls of `accessibilityCustomContent` with different
///   labels will create new entries of additional information. Calling
///   `accessibilityAdditionalContent` repeatedly with the same label will
///   instead replace the previous value and importance.
public func accessibilityCustomContent<V>(_ labelKey: LocalizedStringKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where V : StringProtocol
}
@available(iOS 17.0, macOS 14.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
extension View {
/// Specifies the prominence of badges created by this view.
///
/// Badges can be used for different kinds of information, from the
/// passive number of items in a container to the number of required
/// actions. The prominence of badges in Lists can be adjusted to reflect
/// this and be made to draw more or less attention to themselves.
///
/// Badges will default to `standard` prominence unless specified.
///
/// The following example shows a ``List`` displaying a list of folders
/// with an informational badge with lower prominence, showing the number
/// of items in the folder.
///
///     List(folders) { folder in
///         Text(folder.name)
///             .badge(folder.numberOfItems)
///     }
///     .badgeProminence(.decreased)
///
/// - Parameter prominence: The prominence to apply to badges.
@inlinable public func badgeProminence(_ prominence: BadgeProminence) -> some View
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Adds an accessibility zoom action to the view. Actions allow
/// assistive technologies, such as VoiceOver, to interact with the
/// view by invoking the action.
///
/// For example, this is how a zoom action is used to transform the scale
/// of a shape which has a `MagnificationGesture`.
///
///     var body: some View {
///         Circle()
///             .scaleEffect(magnifyBy)
///             .gesture(magnification)
///             .accessibilityLabel("Circle Magnifier")
///             .accessibilityZoomAction { action in
///                 switch action.direction {
///                 case .zoomIn:
///                     magnifyBy += 0.5
///                 case .zoomOut:
///                      magnifyBy -= 0.5
///                 }
///             }
///     }
///
public func accessibilityZoomAction(_ handler: @escaping (AccessibilityZoomGestureAction) -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Applies the given transaction mutation function to all animations used
/// within the view.
///
/// Use this modifier to change or replace the animation used in a view.
/// Consider three identical animations controlled by a
/// button that executes all three animations simultaneously:
///
///  * The first animation rotates the "Rotation" ``Text`` view by 360
///    degrees.
///  * The second uses the `transaction(_:)` modifier to change the
///    animation by adding a delay to the start of the animation
///    by two seconds and then increases the rotational speed of the
///    "Rotation\nModified" ``Text`` view animation by a factor of 2.
///  * The third animation uses the `transaction(_:)` modifier to
///    replace the rotation animation affecting the "Animation\nReplaced"
///    ``Text`` view with a spring animation.
///
/// The following code implements these animations:
///
///     struct TransactionExample: View {
///         @State private var flag = false
///
///         var body: some View {
///             VStack(spacing: 50) {
///                 HStack(spacing: 30) {
///                     Text("Rotation")
///                         .rotationEffect(Angle(degrees:
///                                                 self.flag ? 360 : 0))
///
///                     Text("Rotation\nModified")
///                         .rotationEffect(Angle(degrees:
///                                                 self.flag ? 360 : 0))
///                         .transaction { view in
///                             view.animation =
///                                 view.animation?.delay(2.0).speed(2)
///                         }
///
///                     Text("Animation\nReplaced")
///                         .rotationEffect(Angle(degrees:
///                                                 self.flag ? 360 : 0))
///                         .transaction { view in
///                             view.animation = .interactiveSpring(
///                                 response: 0.60,
///                                 dampingFraction: 0.20,
///                                 blendDuration: 0.25)
///                         }
///                 }
///
///                 Button("Animate") {
///                     withAnimation(.easeIn(duration: 2.0)) {
///                         self.flag.toggle()
///                     }
///                 }
///             }
///         }
///     }
///
/// Use this modifier on leaf views such as ``Image`` or ``Button`` rather
/// than container views such as ``VStack`` or ``HStack``. The
/// transformation applies to all child views within this view; calling
/// `transaction(_:)` on a container view can lead to unbounded scope of
/// execution depending on the depth of the view hierarchy.
///
/// - Parameter transform: The transformation to apply to transactions
///   within this view.
///
/// - Returns: A view that wraps this view and applies a transformation to
///   all transactions used within the view.
@inlinable public func transaction(_ transform: @escaping (inout Transaction) -> Void) -> some View
/// Applies the given transaction mutation function to all animations used
/// within the view.
///
/// Use this modifier to change or replace the animation used in a view.
/// Consider three identical views controlled by a
/// button that changes all three simultaneously:
///
///  * The first view animates rotating the "Rotation" ``Text`` view by 360
///    degrees.
///  * The second uses the `transaction(_:)` modifier to change the
///    animation by adding a delay to the start of the animation
///    by two seconds and then increases the rotational speed of the
///    "Rotation\nModified" ``Text`` view animation by a factor of 2.
///  * The third uses the `transaction(_:)` modifier to disable animations
///    affecting the "Animation\nReplaced" ``Text`` view.
///
/// The following code implements these animations:
///
///     struct TransactionExample: View {
///         @State var flag = false
///
///         var body: some View {
///             VStack(spacing: 50) {
///                 HStack(spacing: 30) {
///                     Text("Rotation")
///                         .rotationEffect(Angle(degrees: flag ? 360 : 0))
///
///                     Text("Rotation\nModified")
///                         .rotationEffect(Angle(degrees: flag ? 360 : 0))
///                         .transaction(value: flag) { t in
///                             t.animation =
///                                 t.animation?.delay(2.0).speed(2)
///                         }
///
///                     Text("Animation\nReplaced")
///                         .rotationEffect(Angle(degrees: flag ? 360 : 0))
///                         .transaction(value: flag) { t in
///                             t.disableAnimations = true
///                         }
///                 }
///
///                 Button("Animate") {
///                     withAnimation(.easeIn(duration: 2.0)) {
///                         flag.toggle()
///                     }
///                 }
///             }
///         }
///     }
///
/// - Parameters:
///   - value: A value to monitor for changes.
///   - transform: The transformation to apply to transactions
///     within this view.
///
/// - Returns: A view that wraps this view and applies a transformation to
///   all transactions used within the view whenever `value` changes.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func transaction(value: some Equatable, _ transform: @escaping (inout Transaction) -> Void) -> some View
/// Applies the given animation to all animatable values within this view.
///
/// Use this modifier on leaf views rather than container views. The
/// animation applies to all child views within this view; calling
/// `animation(_:)` on a container view can lead to unbounded scope.
///
/// - Parameter animation: The animation to apply to animatable values
///   within this view.
///
/// - Returns: A view that wraps this view and applies `animation` to all
///   animatable values used within the view.
@available(iOS, introduced: 13.0, deprecated: 15.0, message: "Use withAnimation or animation(_:value:) instead.")
@available(macOS, introduced: 10.15, deprecated: 12.0, message: "Use withAnimation or animation(_:value:) instead.")
@available(tvOS, introduced: 13.0, deprecated: 15.0, message: "Use withAnimation or animation(_:value:) instead.")
@available(watchOS, introduced: 6.0, deprecated: 8.0, message: "Use withAnimation or animation(_:value:) instead.")
@available(visionOS, introduced: 1.0, deprecated: 1.0, message: "Use withAnimation or animation(_:value:) instead.")
@inlinable public func animation(_ animation: Animation?) -> some View
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension View {
/// Applies the given transaction mutation function to all animations used
/// within the `body` closure.
///
/// Any modifiers applied to the content of `body` will be applied to this
/// view, and the changes to the transaction performed in the `transform`
/// will only affect the modifiers defined in the `body`.
///
/// The following code animates the opacity changing with a faster
/// animation, while the contents of MyView are animated with the implicit
/// transaction:
///
///     MyView(isActive: isActive)
///         .transaction { transaction in
///             transaction.animation = transaction.animation?.speed(2)
///         } body: { content in
///             content.opacity(isActive ? 1.0 : 0.0)
///         }
///
/// - See Also: `Transaction.disablesAnimations`
public func transaction<V>(_ transform: @escaping (inout Transaction) -> Void, @ViewBuilder body: (PlaceholderContentView<Self>) -> V) -> some View where V : View
/// Applies the given animation to all animatable values within the `body`
/// closure.
///
/// Any modifiers applied to the content of `body` will be applied to this
/// view, and the `animation` will only be used on the modifiers defined in
/// the `body`.
///
/// The following code animates the opacity changing with an easeInOut
/// animation, while the contents of MyView are animated with the implicit
/// transaction's animation:
///
///     MyView(isActive: isActive)
///         .animation(.easeInOut) { content in
///             content.opacity(isActive ? 1.0 : 0.0)
///         }
public func animation<V>(_ animation: Animation?, @ViewBuilder body: (PlaceholderContentView<Self>) -> V) -> some View where V : View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// The activation point for an element is the location
/// assistive technologies use to initiate gestures.
///
/// Use this modifier to ensure that the activation point for a
/// small element remains accurate even if you present a larger
/// version of the element to VoiceOver.
///
/// If an activation point is not provided, an activation point
/// will be derrived from one of the accessibility elements
/// decendents or from the center of the accessibility frame.
public func accessibilityActivationPoint(_ activationPoint: CGPoint) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// The activation point for an element is the location
/// assistive technologies use to initiate gestures.
///
/// Use this modifier to ensure that the activation point for a
/// small element remains accurate even if you present a larger
/// version of the element to VoiceOver.
///
/// If an activation point is not provided, an activation point
/// will be derrived from one of the accessibility elements
/// decendents or from the center of the accessibility frame.
public func accessibilityActivationPoint(_ activationPoint: UnitPoint) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Creates a new view that exposes the provided object to other views whose
/// whose state depends on the focused view hierarchy.
///
/// Use this method instead of ``View/focusedSceneObject(_:)`` when your
/// scene includes multiple focusable views with their own associated data,
/// and you need an app- or scene-scoped element like a command or toolbar
/// item that operates on the data associated with whichever view currently
/// has focus. Each focusable view can supply its own object:
///
///     struct MessageView: View {
///         @StateObject private var message = Message(...)
///
///         var body: some View {
///             TextField(...)
///                 .focusedObject(message)
///         }
///     }
///
/// Interested views can then use the ``FocusedObject`` property wrapper to
/// observe and update the focused view's object. In this example, an app
/// command updates the focused view's data, and is automatically disabled
/// when focus is in an unrelated part of the scene:
///
///     struct MessageCommands: Commands {
///         @FocusedObject private var message: Message?
///
///         var body: some Commands {
///             CommandGroup(after: .pasteboard) {
///                 Button("Add Duck to Message") {
///                     message?.text.append(" 🦆")
///                 }
///                 .keyboardShortcut("d")
///                 .disabled(message == nil)
///             }
///         }
///     }
///
/// - Parameters:
///   - object: The observable object to associate with focus.
/// - Returns: A view that supplies an observable object when in focus.
@inlinable public func focusedObject<T>(_ object: T) -> some View where T : ObservableObject
/// Creates a new view that exposes the provided object to other views whose
/// state depends on the focused view hierarchy.
///
/// Use this method instead of ``View/focusedSceneObject(_:)`` when your
/// scene includes multiple focusable views with their own associated data,
/// and you need an app- or scene-scoped element like a command or toolbar
/// item that operates on the data associated with whichever view currently
/// has focus. Each focusable view can supply its own object:
///
///     struct MessageView: View {
///         @StateObject private var message = Message(...)
///
///         var body: some View {
///             TextField(...)
///                 .focusedObject(message)
///         }
///     }
///
/// Interested views can then use the ``FocusedObject`` property wrapper to
/// observe and update the focused view's object. In this example, an app
/// command updates the focused view's data, and is automatically disabled
/// when focus is in an unrelated part of the scene:
///
///     struct MessageCommands: Commands {
///         @FocusedObject private var message: Message?
///
///         var body: some Commands {
///             CommandGroup(after: .pasteboard) {
///                 Button("Add Duck to Message") {
///                     message?.text.append(" 🦆")
///                 }
///                 .keyboardShortcut("d")
///                 .disabled(message == nil)
///             }
///         }
///     }
///
/// - Parameters:
///   - object: The observable object to associate with focus, or `nil` if
///     no object is currently available.
/// - Returns: A view that supplies an observable object when in focus.
@inlinable public func focusedObject<T>(_ object: T?) -> some View where T : ObservableObject
/// Creates a new view that exposes the provided object to other views whose
/// whose state depends on the active scene.
///
/// Use this method instead of ``View/focusedObject(_:)`` for observable
/// objects that must be visible regardless of where focus is located in the
/// active scene. This is sometimes needed for things like main menu and
/// discoverability HUD commands that observe and update data from the
/// active scene but aren't concerned with what the user is actually focused
/// on. The scene's root view can supply the scene's state object:
///
///     struct RootView: View {
///         @StateObject private var sceneData = SceneData()
///
///         var body: some View {
///             NavigationSplitView {
///                 ...
///             }
///             .focusedSceneObject(sceneData)
///         }
///     }
///
/// Interested views can then use the ``FocusedObject`` property wrapper to
/// observe and update the active scene's state object. In this example, an
/// app command updates the active scene's data, and is enabled as long as
/// any scene is active.
///
///     struct MessageCommands: Commands {
///         @FocusedObject private var sceneData: SceneData?
///
///         var body: some Commands {
///             CommandGroup(after: .newItem) {
///                 Button("New Message") {
///                     sceneData?.addMessage()
///                 }
///                 .keyboardShortcut("n", modifiers: [.option, .command])
///                 .disabled(sceneData == nil)
///             }
///         }
///     }
///
/// - Parameters:
///   - object: The observable object to associate with the scene.
/// - Returns: A view that supplies an observable object while the scene
///   is active.
@inlinable public func focusedSceneObject<T>(_ object: T) -> some View where T : ObservableObject
/// Creates a new view that exposes the provided object to other views whose
/// whose state depends on the active scene.
///
/// Use this method instead of ``View/focusedObject(_:)`` for observable
/// objects that must be visible regardless of where focus is located in the
/// active scene. This is sometimes needed for things like main menu and
/// discoverability HUD commands that observe and update data from the
/// active scene but aren't concerned with what the user is actually focused
/// on. The scene's root view can supply the scene's state object:
///
///     struct RootView: View {
///         @StateObject private var sceneData = SceneData()
///
///         var body: some View {
///             NavigationSplitView {
///                 ...
///             }
///             .focusedSceneObject(sceneData)
///         }
///     }
///
/// Interested views can then use the ``FocusedObject`` property wrapper to
/// observe and update the active scene's state object. In this example, an
/// app command updates the active scene's data, and is enabled as long as
/// any scene is active.
///
///     struct MessageCommands: Commands {
///         @FocusedObject private var sceneData: SceneData?
///
///         var body: some Commands {
///             CommandGroup(after: .newItem) {
///                 Button("New Message") {
///                     sceneData?.addMessage()
///                 }
///                 .keyboardShortcut("n", modifiers: [.option, .command])
///                 .disabled(sceneData == nil)
///             }
///         }
///     }
///
/// - Parameters:
///   - object: The observable object to associate with the scene, or `nil`
///     if no object is currently available.
/// - Returns: A view that supplies an observable object while the scene
///   is active.
@inlinable public func focusedSceneObject<T>(_ object: T?) -> some View where T : ObservableObject
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a `.default` action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(_ actionKind: AccessibilityActionKind = .default, _ handler: @escaping () -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: Text("New Message")) {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(named name: Text, _ handler: @escaping () -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension View {
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction {
///                 // Handle action
///             } label: {
///                 Label("New Message", systemImage: "plus")
///             }
///     }
///
public func accessibilityAction<Label>(action: @escaping () -> Void, @ViewBuilder label: () -> Label) -> some View where Label : View
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension View {
/// Adds multiple accessibility actions to the view.
///
/// Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
/// For example, this is how a dynamic number of custom action could
/// be added to a view.
///
///     var isDraft: Bool
///
///     var body: some View {
///         ContentView()
///             .accessibilityActions {
///                 ForEach(actions) { action in
///                     Button {
///                         action()
///                     } label: {
///                         Text(action.title)
///                     }
///                 }
///
///                 if isDraft {
///                     Button {
///                         // Handle Delete
///                     } label: {
///                         Text("Delete")
///                     }
///                 }
///             }
///
public func accessibilityActions<Content>(@ViewBuilder _ content: () -> Content) -> some View where Content : View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: "New Message") {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction(named nameKey: LocalizedStringKey, _ handler: @escaping () -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
/// Adds an accessibility action to the view. Actions allow assistive technologies,
/// such as the VoiceOver, to interact with the view by invoking the action.
///
/// For example, this is how a custom action to compose
/// a new email could be added to a view.
///
///     var body: some View {
///         ContentView()
///             .accessibilityAction(named: "New Message") {
///                 // Handle action
///             }
///     }
///
public func accessibilityAction<S>(named name: S, _ handler: @escaping () -> Void) -> ModifiedContent<Self, AccessibilityAttachmentModifier> where S : StringProtocol
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Adds help text to a view using a localized string that you provide.
///
/// Adding help to a view configures the view's accessibility hint and
/// its tooltip ("help tag") on macOS.
/// For more information on using help tags, see
/// [Help](https://developer.apple.com/design/human-interface-guidelines/macos/user-interaction/help/)
/// in the macOS Human Interface Guidelines.
///
///     Button(action: composeMessage) {
///         Image(systemName: "square.and.pencil")
///     }
///     .help("Compose a new message")
///
/// - Parameter textKey: The key for the localized text to use as help.
public func help(_ textKey: LocalizedStringKey) -> some View
/// Adds help text to a view using a text view that you provide.
///
/// Adding help to a view configures the view's accessibility hint and
/// its tooltip ("help tag") on macOS.
/// For more information on using help tags, see
/// [Help](https://developer.apple.com/design/human-interface-guidelines/macos/user-interaction/help/)
/// in the macOS Human Interface Guidelines.
///
///     Slider("Opacity", value: $selectedShape.opacity)
///         .help(Text("Adjust the opacity of the selected \(selectedShape.name)"))
///
/// - Parameter text: The Text view to use as help.
public func help(_ text: Text) -> some View
/// Adds help text to a view using a string that you provide.
///
/// Adding help to a view configures the view's accessibility hint and
/// its tooltip ("help tag") on macOS.
/// For more information on using help tags, see
/// [Help](https://developer.apple.com/design/human-interface-guidelines/macos/user-interaction/help/)
/// in the macOS Human Interface Guidelines.
///
///     Image(systemName: "pin.circle")
///         .foregroundColor(pointOfInterest.tintColor)
///         .help(pointOfInterest.name)
///
/// - Parameter text: The text to use as help.
public func help<S>(_ text: S) -> some View where S : StringProtocol
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Places a custom background view behind a list row item.
///
/// Use `listRowBackground(_:)` to place a custom background view behind a
/// list row item.
///
/// In the example below, the `Flavor` enumeration provides content for list
/// items. The SwiftUI ``ForEach`` structure computes views for each element
/// of the `Flavor` enumeration and extracts the raw value of each of its
/// elements using the resulting text to create each list row item. The
/// `listRowBackground(_:)` modifier then places the view you supply behind
/// each of the list row items:
///
///     struct ContentView: View {
///         enum Flavor: String, CaseIterable, Identifiable {
///             var id: String { self.rawValue }
///             case vanilla, chocolate, strawberry
///         }
///
///         var body: some View {
///             List {
///                 ForEach(Flavor.allCases) {
///                     Text($0.rawValue)
///                         .listRowBackground(Ellipse()
///                                             .background(Color.clear)
///                                             .foregroundColor(.purple)
///                                             .opacity(0.3)
///                         )
///                 }
///             }
///         }
///     }
///
/// ![A screenshot showing the placement of an image as the background to
///   each row in a list.](SwiftUI-View-listRowBackground.png)
///
/// - Parameter view: The ``View`` to use as the background behind the list
///   row view.
///
/// - Returns: A list row view with `view` as its background view.
@inlinable public func listRowBackground<V>(_ view: V?) -> some View where V : View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
/// Sets the style for labels within this view.
///
/// Use this modifier to set a specific style for all labels within a view:
///
///     VStack {
///         Label("Fire", systemImage: "flame.fill")
///         Label("Lightning", systemImage: "bolt.fill")
///     }
///     .labelStyle(MyCustomLabelStyle())
///
public func labelStyle<S>(_ style: S) -> some View where S : LabelStyle
}
@available(iOS 13.4, macOS 10.15, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Activates this view as the source of a drag and drop operation.
///
/// Applying the `onDrag(_:)` modifier adds the appropriate gestures for
/// drag and drop to this view. When a drag operation begins, a rendering of
/// this view is generated and used as the preview image.
///
/// - Parameter data: A closure that returns a single
/// <doc://com.apple.documentation/documentation/Foundation/NSItemProvider> that
/// represents the draggable data from this view.
///
/// - Returns: A view that activates this view as the source of a drag and
///   drop operation, beginning with user gesture input.
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func onDrag(_ data: @escaping () -> NSItemProvider) -> some View
}
@available(iOS 15.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Activates this view as the source of a drag and drop operation.
///
/// Applying the `onDrag(_:preview:)` modifier adds the appropriate gestures
/// for drag and drop to this view. When a drag operation begins,
/// a rendering of `preview` is generated and used as the preview image.
///
/// - Parameter data: A closure that returns a single
/// <doc://com.apple.documentation/documentation/Foundation/NSItemProvider>
/// that represents the draggable data from this view.
/// - Parameter preview: A ``View`` to use as the source for the dragging
///   preview, once the drag operation has begun. The preview is centered over
///   the source view.
///
/// - Returns: A view that activates this view as the source of a drag-and-
///   drop operation, beginning with user gesture input.
public func onDrag<V>(_ data: @escaping () -> NSItemProvider, @ViewBuilder preview: () -> V) -> some View where V : View
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {
/// Activates this view as the source of a drag and drop operation.
///
/// Applying the `draggable(_:)` modifier adds the appropriate gestures for
/// drag and drop to this view. When a drag operation begins, a rendering of
/// this view is generated and used as the preview image.
///
/// - Parameter payload: A closure that returns a single
/// instance or a value conforming to <doc://com.apple.documentation/documentation/coretransferable/transferable> that
/// represents the draggable data from this view.
///
/// - Returns: A view that activates this view as the source of a drag and
///   drop operation, beginning with user gesture input.
public func draggable<T>(_ payload: @autoclosure @escaping () -> T) -> some View where T : Transferable
/// Activates this view as the source of a drag and drop operation.
///
/// Applying the `draggable(_:preview:)` modifier adds the appropriate gestures
/// for drag and drop to this view. When a drag operation begins,
/// a rendering of `preview` is generated and used as the preview image.
///
///     var title: String
///     var body: some View {
///         Color.pink
///             .frame(width: 400, height: 400)
///             .draggable(title) {
///                  Text("Drop me")
///              }
///     }
///
/// - Parameter payload: A closure that returns a single
/// class instance or a value conforming to `Transferable` that
/// represents the draggable data from this view.
/// - Parameter preview: A ``View`` to use as the source for the dragging
/// preview, once the drag operation has begun. The preview is centered over
/// the source view.
///
/// - Returns: A view that activates this view as the source of a drag and
///   drop operation, beginning with user gesture input.
public func draggable<V, T>(_ payload: @autoclosure @escaping () -> T, @ViewBuilder preview: () -> V) -> some View where V : View, T : Transferable
}
@available(iOS 13.0, macOS 10.15, watchOS 10.0, *)
@available(tvOS, unavailable)
extension View {
/// Sets the style for date pickers within this view.
@available(watchOS 10.0, *)
@available(tvOS, unavailable)
public func datePickerStyle<S>(_ style: S) -> some View where S : DatePickerStyle
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Adds a condition that controls whether users can interact with this
/// view.
///
/// The higher views in a view hierarchy can override the value you set on
/// this view. In the following example, the button isn't interactive
/// because the outer `disabled(_:)` modifier overrides the inner one:
///
///     HStack {
///         Button(Text("Press")) {}
///         .disabled(false)
///     }
///     .disabled(true)
///
/// - Parameter disabled: A Boolean value that determines whether users can
///   interact with this view.
///
/// - Returns: A view that controls whether users can interact with this
///   view.
@inlinable public func disabled(_ disabled: Bool) -> some View
}
/// The scroll behavior that aligns scroll targets to view-based geometry.
///
/// You use this behavior when a scroll view should always align its
/// scroll targets to a rectangle that's aligned to the geometry of a view. In
/// the following example, the scroll view always picks an item view
/// to settle on.
///
///     ScrollView(.horizontal) {
///         LazyHStack(spacing: 10.0) {
///             ForEach(items) { item in
///               ItemView(item)
///             }
///         }
///         .scrollTargetLayout()
///     }
///     .scrollTargetBehavior(.viewAligned)
///     .padding(.horizontal, 20.0)
///
/// You configure which views should be used for settling using the
/// ``View/scrollTargetLayout(isEnabled:)`` modifier. Apply this modifier to a
/// layout container like ``LazyVStack`` or ``HStack`` and each individual
/// view in that layout will be considered for alignment.
///
/// You can customize whether the view aligned behavior limits the
/// number of views that can be scrolled at a time by using the
/// ``ViewAlignedScrollTargetBehavior/LimitBehavior`` type. Provide a value of
/// ``ViewAlignedScrollTargetBehavior/LimitBehavior/always`` to always have
/// the behavior only allow a few views to be scrolled at a time.
///
/// By default, the view aligned behavior will limit the number of views
/// it scrolls when in a compact horizontal size class when scrollable
/// in the horizontal axis, when in a compact vertical size class when
/// scrollable in the vertical axis, and otherwise does not impose any
/// limit on the number of views that can be scrolled.
///
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public struct ViewAlignedScrollTargetBehavior : ScrollTargetBehavior {
/// A type that defines the amount of views that can be scrolled at a time.
public struct LimitBehavior {
/// The automatic limit behavior.
///
/// By default, the behavior will be limited in compact horizontal
/// size classes and will not be limited otherwise.
public static var automatic: ViewAlignedScrollTargetBehavior.LimitBehavior { get }
/// The always limit behavior.
///
/// Always limit the amount of views that can be scrolled.
public static var always: ViewAlignedScrollTargetBehavior.LimitBehavior { get }
/// The never limit behavior.
///
/// Never limit the amount of views that can be scrolled.
public static var never: ViewAlignedScrollTargetBehavior.LimitBehavior { get }
}
/// Creates a view aligned scroll behavior.
public init(limitBehavior: ViewAlignedScrollTargetBehavior.LimitBehavior = .automatic)
/// Updates the proposed target that a scrollable view should scroll to.
///
/// The system calls this method in two main cases:
/// - When a scroll gesture ends, it calculates where it would naturally
///   scroll to using its deceleration rate. The system
///   provides this calculated value as the target of this method.
/// - When a scrollable view's size changes, it calculates where it should
///   be scrolled given the new size and provides this calculates value
///   as the target of this method.
///
/// You can implement this method to override the calculated target
/// which will have the scrollable view scroll to a different position
/// than it would otherwise.
public func updateTarget(_ target: inout ScrollTarget, context: ViewAlignedScrollTargetBehavior.TargetContext)
}
/// A custom parameter attribute that constructs views from closures.
///
/// You typically use ``ViewBuilder`` as a parameter attribute for child
/// view-producing closure parameters, allowing those closures to provide
/// multiple child views. For example, the following `contextMenu` function
/// accepts a closure that produces one or more views via the view builder.
///
///     func contextMenu<MenuItems: View>(
///         @ViewBuilder menuItems: () -> MenuItems
///     ) -> some View
///
/// Clients of this function can use multiple-statement closures to provide
/// several child views, as shown in the following example:
///
///     myView.contextMenu {
///         Text("Cut")
///         Text("Copy")
///         Text("Paste")
///         if isSymbol {
///             Text("Jump to Definition")
///         }
///     }
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@resultBuilder public struct ViewBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : View
/// Builds an empty view from a block containing no statements.
public static func buildBlock() -> EmptyView
/// Passes a single view written as a child view through unmodified.
///
/// An example of a single view written as a child view is
/// `{ Text("Hello") }`.
public static func buildBlock<Content>(_ content: Content) -> Content where Content : View
public static func buildBlock<each Content>(_ content: repeat each Content) -> TupleView<(repeat each Content)> where repeat each Content : View
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewBuilder {
/// Provides support for “if” statements in multi-statement closures,
/// producing an optional view that is visible only when the condition
/// evaluates to `true`.
public static func buildIf<Content>(_ content: Content?) -> Content? where Content : View
/// Provides support for "if" statements in multi-statement closures,
/// producing conditional content for the "then" branch.
public static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : View, FalseContent : View
/// Provides support for "if-else" statements in multi-statement closures,
/// producing conditional content for the "else" branch.
public static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : View, FalseContent : View
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ViewBuilder {
/// Provides support for "if" statements with `#available()` clauses in
/// multi-statement closures, producing conditional content for the "then"
/// branch, i.e. the conditionally-available branch.
public static func buildLimitedAvailability<Content>(_ content: Content) -> AnyView where Content : View
}
/// A view's size and alignment guides in its own coordinate space.
///
/// This structure contains the size and alignment guides of a view.
/// You receive an instance of this structure to use in a variety of
/// layout calculations, like when you:
///
/// * Define a default value for a custom alignment guide;
///   see ``AlignmentID/defaultValue(in:)``.
/// * Modify an alignment guide on a view;
///   see ``View/alignmentGuide(_:computeValue:)-9mdoh``.
/// * Ask for the dimensions of a subview of a custom view layout;
///   see ``LayoutSubview/dimensions(in:)``.
///
/// ### Custom alignment guides
///
/// You receive an instance of this structure as the `context` parameter to
/// the ``AlignmentID/defaultValue(in:)`` method that you implement to produce
/// the default offset for an alignment guide, or as the first argument to the
/// closure you provide to the ``View/alignmentGuide(_:computeValue:)-6y3u2``
/// view modifier to override the default calculation for an alignment guide.
/// In both cases you can use the instance, if helpful, to calculate the
/// offset for the guide. For example, you could compute a default offset
/// for a custom ``VerticalAlignment`` as a fraction of the view's ``height``:
///
///     private struct FirstThirdAlignment: AlignmentID {
///         static func defaultValue(in context: ViewDimensions) -> CGFloat {
///             context.height / 3
///         }
///     }
///
///     extension VerticalAlignment {
///         static let firstThird = VerticalAlignment(FirstThirdAlignment.self)
///     }
///
/// As another example, you could use the view dimensions instance to look
/// up the offset of an existing guide and modify it:
///
///     struct ViewDimensionsOffset: View {
///         var body: some View {
///             VStack(alignment: .leading) {
///                 Text("Default")
///                 Text("Indented")
///                     .alignmentGuide(.leading) { context in
///                         context[.leading] - 10
///                     }
///             }
///         }
///     }
///
/// The example above indents the second text view because the subtraction
/// moves the second text view's leading guide in the negative x direction,
/// which is to the left in the view's coordinate space. As a result,
/// SwiftUI moves the second text view to the right, relative to the first
/// text view, to keep their leading guides aligned:
///
/// ![A screenshot of two strings. The first says Default and the second,
/// which appears below the first, says Indented. The left side of the second
/// string appears horizontally offset to the right from the left side of the
/// first string by about the width of one character.](ViewDimensions-1-iOS)
///
/// ### Layout direction
///
/// The discussion above describes a left-to-right language environment,
/// but you don't change your guide calculation to operate in a right-to-left
/// environment. SwiftUI moves the view's origin from the left to the right side
/// of the view and inverts the positive x direction. As a result,
/// the existing calculation produces the same effect, but in the opposite
/// direction.
///
/// You can see this if you use the ``View/environment(_:_:)``
/// modifier to set the ``EnvironmentValues/layoutDirection`` property for the
/// view that you defined above:
///
///     ViewDimensionsOffset()
///         .environment(\.layoutDirection, .rightToLeft)
///
/// With no change in your guide, this produces the desired effect ---
/// it indents the second text view's right side, relative to the
/// first text view's right side. The leading edge is now on the right,
/// and the direction of the offset is reversed:
///
/// ![A screenshot of two strings. The first says Default and the second,
/// which appears below the first, says Indented. The right side of the second
/// string appears horizontally offset to the left from the right side of the
/// first string by about the width of one character.](ViewDimensions-2-iOS)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct ViewDimensions {
/// The view's width.
public var width: CGFloat { get }
/// The view's height.
public var height: CGFloat { get }
/// Gets the value of the given horizontal guide.
///
/// Find the offset of a particular guide in the corresponding view by
/// using that guide as an index to read from the context:
///
///     .alignmentGuide(.leading) { context in
///         context[.leading] - 10
///     }
///
/// For information about using subscripts in Swift to access member
/// elements of a collection, list, or, sequence, see
/// [Subscripts](https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html)
/// in _The Swift Programming Language_.
public subscript(guide: HorizontalAlignment) -> CGFloat { get }
/// Gets the value of the given vertical guide.
///
/// Find the offset of a particular guide in the corresponding view by
/// using that guide as an index to read from the context:
///
///     .alignmentGuide(.top) { context in
///         context[.top] - 10
///     }
///
/// For information about using subscripts in Swift to access member
/// elements of a collection, list, or, sequence, see
/// [Subscripts](https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html)
/// in _The Swift Programming Language_.
public subscript(guide: VerticalAlignment) -> CGFloat { get }
/// Gets the explicit value of the given horizontal alignment guide.
///
/// Find the horizontal offset of a particular guide in the corresponding
/// view by using that guide as an index to read from the context:
///
///     .alignmentGuide(.leading) { context in
///         context[.leading] - 10
///     }
///
/// This subscript returns `nil` if no value exists for the guide.
///
/// For information about using subscripts in Swift to access member
/// elements of a collection, list, or, sequence, see
/// [Subscripts](https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html)
/// in _The Swift Programming Language_.
public subscript(explicit guide: HorizontalAlignment) -> CGFloat? { get }
/// Gets the explicit value of the given vertical alignment guide
///
/// Find the vertical offset of a particular guide in the corresponding
/// view by using that guide as an index to read from the context:
///
///     .alignmentGuide(.top) { context in
///         context[.top] - 10
///     }
///
/// This subscript returns `nil` if no value exists for the guide.
///
/// For information about using subscripts in Swift to access member
/// elements of a collection, list, or, sequence, see
/// [Subscripts](https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html)
/// in _The Swift Programming Language_.
public subscript(explicit guide: VerticalAlignment) -> CGFloat? { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewDimensions : Equatable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (lhs: ViewDimensions, rhs: ViewDimensions) -> Bool
}
/// A modifier that you apply to a view or another view modifier, producing a
/// different version of the original value.
///
/// Adopt the ``ViewModifier`` protocol when you want to create a reusable
/// modifier that you can apply to any view. The example below combines several
/// modifiers to create a new modifier that you can use to create blue caption
/// text surrounded by a rounded rectangle:
///
///     struct BorderedCaption: ViewModifier {
///         func body(content: Content) -> some View {
///             content
///                 .font(.caption2)
///                 .padding(10)
///                 .overlay(
///                     RoundedRectangle(cornerRadius: 15)
///                         .stroke(lineWidth: 1)
///                 )
///                 .foregroundColor(Color.blue)
///         }
///     }
///
/// You can apply ``View/modifier(_:)`` directly to a view, but a more common
/// and idiomatic approach uses ``View/modifier(_:)`` to define an extension to
/// ``View`` itself that incorporates the view modifier:
///
///     extension View {
///         func borderedCaption() -> some View {
///             modifier(BorderedCaption())
///         }
///     }
///
/// You can then apply the bordered caption to any view, similar to this:
///
///     Image(systemName: "bus")
///         .resizable()
///         .frame(width:50, height:50)
///     Text("Downtown Bus")
///         .borderedCaption()
///
/// ![A screenshot showing the image of a bus with a caption reading
/// Downtown Bus. A view extension, using custom a modifier, renders the
///  caption in blue text surrounded by a rounded
///  rectangle.](SwiftUI-View-ViewModifier.png)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ViewModifier {
/// The type of view representing the body.
associatedtype Body : View
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
@ViewBuilder @MainActor func body(content: Self.Content) -> Self.Body
/// The content view type passed to `body()`.
typealias Content
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewModifier where Self.Body == Never {
/// Gets the current body of the caller.
///
/// `content` is a proxy for the view that will have the modifier
/// represented by `Self` applied to it.
public func body(content: Self.Content) -> Self.Body
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewModifier {
/// Returns a new modifier that is the result of concatenating
/// `self` with `modifier`.
@inlinable public func concat<T>(_ modifier: T) -> ModifiedContent<Self, T>
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewModifier {
/// Returns a new version of the modifier that will apply the
/// transaction mutation function `transform` to all transactions
/// within the modifier.
@inlinable public func transaction(_ transform: @escaping (inout Transaction) -> Void) -> some ViewModifier
/// Returns a new version of the modifier that will apply
/// `animation` to all animatable values within the modifier.
@inlinable public func animation(_ animation: Animation?) -> some ViewModifier
}
/// A collection of the geometric spacing preferences of a view.
///
/// This type represents how much space a view prefers to have between it and
/// the next view in a layout. The type stores independent values
/// for each of the top, bottom, leading, and trailing edges,
/// and can also record different values for different kinds of adjacent
/// views. For example, it might contain one value for the spacing to the next
/// text view along the top and bottom edges, other values for the spacing to
/// text views on other edges, and yet other values for other kinds of views.
/// Spacing preferences can also vary by platform.
///
/// Your ``Layout`` type doesn't have to take preferred spacing into
/// account, but if it does, you can use the ``LayoutSubview/spacing``
/// preferences of the subviews in your layout container to:
///
/// * Add space between subviews when you implement the
///   ``Layout/placeSubviews(in:proposal:subviews:cache:)`` method.
/// * Create a spacing preferences instance for the container view by
///   implementing the ``Layout/spacing(subviews:cache:)-86z2e`` method.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public struct ViewSpacing : Sendable {
/// A view spacing instance that contains zero on all edges.
///
/// You typically only use this value for an empty view.
public static let zero: ViewSpacing
/// Initializes an instance with default spacing values.
///
/// Use this initializer to create a spacing preferences instance with
/// default values. Then use ``formUnion(_:edges:)`` to combine
/// preferences from other views with the new instance. You typically
/// do this in a custom layout's implementation of the
/// ``Layout/spacing(subviews:cache:)-86z2e`` method.
public init()
/// Merges the spacing preferences of another spacing instance with this
/// instance for a specified set of edges.
///
/// When you merge another spacing preference instance with this one,
/// this instance ends up with the greater of its original value or the
/// other instance's value for each of the specified edges.
/// You can call the method repeatedly with each value in a collection to
/// merge a collection of preferences. The result has the smallest
/// preferences on each edge that meets the largest requirements of all
/// the inputs for that edge.
///
/// If you want to merge preferences without modifying the original
/// instance, use ``union(_:edges:)`` instead.
///
/// - Parameters:
///   - other: Another spacing preferences instances to merge with this one.
///   - edges: The edges to merge. Edges that you don't specify are
///     unchanged after the method completes.
public mutating func formUnion(_ other: ViewSpacing, edges: Edge.Set = .all)
/// Gets a new value that merges the spacing preferences of another spacing
/// instance with this instance for a specified set of edges.
///
/// This method behaves like ``formUnion(_:edges:)``, except that it creates
/// a copy of the original spacing preferences instance before merging,
/// leaving the original instance unmodified.
///
/// - Parameters:
///   - other: Another spacing preferences instance to merge with this one.
///   - edges: The edges to merge. Edges that you don't specify are
///     unchanged after the method completes.
///
/// - Returns: A new view spacing preferences instance with the merged
///   values.
public func union(_ other: ViewSpacing, edges: Edge.Set = .all) -> ViewSpacing
/// Gets the preferred spacing distance along the specified axis to the view
/// that returns a specified spacing preference.
///
/// Call this method from your implementation of ``Layout`` protocol
/// methods if you need to measure the default spacing between two
/// views in a custom layout. Call the method on the first view's
/// preferences instance, and provide the second view's preferences
/// instance as input.
///
/// For example, consider two views that appear in a custom horizontal
/// stack. The following distance call gets the preferred spacing between
/// these views, where `spacing1` contains the preferences of a first
/// view, and `spacing2` contains the preferences of a second view:
///
///     let distance = spacing1.distance(to: spacing2, axis: .horizontal)
///
/// The method first determines, based on the axis and the ordering, that
/// the views abut on the trailing edge of the first view and the leading
/// edge of the second. It then gets the spacing preferences for the
/// corresponding edges of each view, and returns the greater of the two
/// values. This results in the smallest value that provides enough space
/// to satisfy the preferences of both views.
///
/// > Note: This method returns the default spacing between views, but a
/// layout can choose to ignore the value and use custom spacing instead.
///
/// - Parameters:
///   - next: The spacing preferences instance of the adjacent view.
///   - axis: The axis that the two views align on.
///
/// - Returns: A floating point value that represents the smallest distance
///   in points between two views that satisfies the spacing preferences
///   of both this view and the adjacent views on their shared edge.
public func distance(to next: ViewSpacing, along axis: Axis) -> CGFloat
}
/// A view that adapts to the available space by providing the first
/// child view that fits.
///
/// `ViewThatFits` evaluates its child views in the order you provide them
/// to the initializer. It selects the first child whose ideal size on the
/// constrained axes fits within the proposed size. This means that you
/// provide views in order of preference. Usually this order is largest to
/// smallest, but since a view might fit along one constrained axis but not the
/// other, this isn't always the case. By default, `ViewThatFits` constrains
/// in both the horizontal and vertical axes.
///
/// The following example shows an `UploadProgressView` that uses `ViewThatFits`
/// to display the upload progress in one of three ways. In order, it attempts
/// to display:
///
/// * An ``HStack`` that contains a ``Text`` view and a ``ProgressView``.
/// * Only the `ProgressView`.
/// * Only the `Text` view.
///
/// The progress views are fixed to a 100-point width.
///
///     struct UploadProgressView: View {
///         var uploadProgress: Double
///
///         var body: some View {
///             ViewThatFits(in: .horizontal) {
///                 HStack {
///                     Text("\(uploadProgress.formatted(.percent))")
///                     ProgressView(value: uploadProgress)
///                         .frame(width: 100)
///                 }
///                 ProgressView(value: uploadProgress)
///                     .frame(width: 100)
///                 Text("\(uploadProgress.formatted(.percent))")
///             }
///         }
///     }
///
/// This use of `ViewThatFits` evaluates sizes only on the horizontal axis. The
/// following code fits the `UploadProgressView` to several fixed widths:
///
///     VStack {
///         UploadProgressView(uploadProgress: 0.75)
///             .frame(maxWidth: 200)
///         UploadProgressView(uploadProgress: 0.75)
///             .frame(maxWidth: 100)
///         UploadProgressView(uploadProgress: 0.75)
///             .frame(maxWidth: 50)
///     }
///
/// ![A vertical stack showing three expressions of progress, constrained by
/// the available horizontal space. The first line shows the text, 75%, and a
/// three-quarters-full progress bar. The second line shows only the progress
/// view. The third line shows only the text.](ViewThatFits-1)
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct ViewThatFits<Content> : View where Content : View {
/// Produces a view constrained in the given axes from one of several
/// alternatives provided by a view builder.
///
/// - Parameters:
///     - axes: A set of axes to constrain children to. The set may
///       contain ``Axis/horizontal``, ``Axis/vertical``, or both of these.
///       `ViewThatFits` chooses the first child whose size fits within the
///       proposed size on these axes. If `axes` is an empty set,
///       `ViewThatFits` uses the first child view. By default,
///       `ViewThatFits` uses both axes.
///     - content: A view builder that provides the child views for this
///       container, in order of preference. The builder chooses the first
///       child view that fits within the proposed width, height, or both,
///       as defined by `axes`.
@inlinable public init(in axes: Axis.Set = [.horizontal, .vertical], @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// The visibility of a UI element, chosen automatically based on
/// the platform, current context, and other factors.
///
/// For example, the preferred visibility of list row separators can be
/// configured using the ``View/listRowSeparator(_:edges:)``.
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
@frozen public enum Visibility : Hashable, CaseIterable {
/// The element may be visible or hidden depending on the policies of the
/// component accepting the visibility configuration.
///
/// For example, some components employ different automatic behavior
/// depending on factors including the platform, the surrounding container,
/// user settings, etc.
case automatic
/// The element may be visible.
///
/// Some APIs may use this value to represent a hint or preference, rather
/// than a mandatory assertion. For example, setting list row separator
/// visibility to `visible` using the
/// ``View/listRowSeparator(_:edges:)`` modifier may not always
/// result in any visible separators, especially for list styles that do not
/// include separators as part of their design.
case visible
/// The element may be hidden.
///
/// Some APIs may use this value to represent a hint or preference, rather
/// than a mandatory assertion. For example, setting confirmation dialog
/// title visibility to `hidden` using the
/// ``View/confirmationDialog(_:isPresented:titleVisibility:actions:)-87n66``
/// modifier may not always hide the dialog title, which is required on
/// some platforms.
case hidden
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: Visibility, b: Visibility) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// A type that can represent a collection of all values of this type.
public typealias AllCases = [Visibility]
/// A collection of all values of this type.
public static var allCases: [Visibility] { get }
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Visibility : Sendable {
}
/// Visual Effects change the visual appearance of a view without changing its
/// ancestors or descendents.
///
/// Because effects do not impact layout, they are safe to use in situations
/// where layout modification is not allowed. For example, effects may be
/// applied as a function of position, accessed through a geometry proxy:
///
/// ```swift
/// var body: some View {
///     ContentRow()
///         .visualEffect { content, geometryProxy in
///             content.offset(x: geometryProxy.frame(in: .global).origin.y)
///         }
/// }
/// ```
///
/// You don't conform to this protocol yourself. Instead, visual effects are
/// created by calling modifier functions (such as `.offset(x:y:)` on other
/// effects, as seen in the example above.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public protocol VisualEffect : Sendable, Animatable {
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, *)
@available(watchOS, unavailable)
extension VisualEffect {
/// Returns a new visual effect that applies `shader` to `self` as
/// a filter effect on the color of each pixel.
///
/// For a shader function to act as a color filter it must have a
/// function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position, half4 color, args...)
///
/// where `position` is the user-space coordinates of the pixel
/// applied to the shader and `color` its source color, as a
/// pre-multiplied color in the destination color space. `args...`
/// should be compatible with the uniform arguments bound to
/// `shader`. The function should return the modified color value.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply to `self` as a color filter.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a color filter.
public func colorEffect(_ shader: Shader, isEnabled: Bool = true) -> some VisualEffect
/// Returns a new visual effect that applies `shader` to `self` as
/// a geometric distortion effect on the location of each pixel.
///
/// For a shader function to act as a distortion effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] float2 name(float2 position, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader. `args...` should be
/// compatible with the uniform arguments bound to `shader`. The
/// function should return the user-space coordinates of the
/// corresponding source pixel.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply as a distortion effect.
///   - maxSampleOffset: The maximum distance in each axis between
///     the returned source pixel position and the destination pixel
///     position, for all source pixels.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a distortion effect.
public func distortionEffect(_ shader: Shader, maxSampleOffset: CGSize, isEnabled: Bool = true) -> some VisualEffect
/// Returns a new visual effect that applies `shader` to `self` as
/// a filter on the raster layer created from `self`.
///
/// For a shader function to act as a layer effect it must
/// have a function signature matching:
///
///     [[ stitchable ]] half4 name(float2 position,
///       SwiftUI::Layer layer, args...)
///
/// where `position` is the user-space coordinates of the
/// destination pixel applied to the shader, and `layer` is a
/// subregion of the rasterized contents of `self`. `args...`
/// should be compatible with the uniform arguments bound to
/// `shader`.
///
/// The `SwiftUI::Layer` type is defined in the
/// `<SwiftUI/SwiftUI.h>` header file. It exports a single
/// `sample()` function that returns a linearly-filtered pixel
/// value from a position in the source content, as a premultiplied
/// RGBA pixel value:
///
///     namespace SwiftUI {
///       struct Layer {
///         half4 sample(float2 position) const;
///       };
///     };
///
/// The function should return the color mapping to the destination
/// pixel, typically by sampling one or more pixels from `layer` at
/// location(s) derived from `position` and them applying some kind
/// of transformation to produce a new color.
///
/// > Important: Views backed by AppKit or UIKit views may not
///   render into the filtered layer. Instead, they log a warning
///   and display a placeholder image to highlight the error.
///
/// - Parameters:
///   - shader: The shader to apply as a layer effect.
///   - maxSampleOffset: If the shader function samples from the
///     layer at locations not equal to the destination position,
///     this value must specify the maximum sampling distance in
///     each axis, for all source pixels.
///   - isEnabled: Whether the effect is enabled or not.
///
/// - Returns: A new view that renders `self` with the shader
///   applied as a distortion effect.
public func layerEffect(_ shader: Shader, maxSampleOffset: CGSize, isEnabled: Bool = true) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Offsets the view by the horizontal and vertical amount specified in the
/// offset parameter.
///
/// - Parameter offset: The distance to offset the view.
///
/// - Returns: An effect that offsets the view by `offset`.
public func offset(_ offset: CGSize) -> some VisualEffect
/// Offsets the view by the specified horizontal and vertical distances.
///
/// - Parameters:
///   - x: The horizontal distance to offset the view.
///   - y: The vertical distance to offset the view.
///
/// - Returns: An effect that offsets the view by `x` and `y`.
public func offset(x: CGFloat = 0, y: CGFloat = 0) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Applies a projection transformation to the view's rendered output.
///
/// Use `transformEffect(_:)` to rotate, scale, translate, or skew the
/// output of the view according to the provided
/// <doc://com.apple.documentation/documentation/SwiftUI/ProjectionTransform>.
///
/// - Parameter transform: A
/// <doc://com.apple.documentation/documentation/SwiftUI/ProjectionTransform> to
/// apply to the view.
///
/// - Returns: An effect that applies a projection transformation to the
///   view's rendered output.
public func transformEffect(_ transform: ProjectionTransform) -> some VisualEffect
/// Applies an affine transformation to the view's rendered output.
///
/// Use `transformEffect(_:)` to rotate, scale, translate, or skew the
/// output of the view according to the provided
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGAffineTransform>.
///
/// - Parameter transform: A
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGAffineTransform> to
/// apply to the view.
///
/// - Returns: An effect that applies an affine transformation to the
///   view's rendered output.
///
public func transformEffect(_ transform: CGAffineTransform) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Rotates the view's rendered output around the specified point.
///
/// - Parameters:
///   - angle: The angle at which to rotate the view.
///   - anchor: The location with a default of ``UnitPoint/center`` that
///     defines a point at which the rotation is anchored.
/// - Returns: An effect that rotates the view's rendered output.
public func rotationEffect(_ angle: Angle, anchor: UnitPoint = .center) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Scales the view's rendered output by the given vertical and horizontal
/// size amounts, relative to an anchor point.
///
/// - Parameters:
///   - scale: A <doc://com.apple.documentation/documentation/CoreGraphics/CGSize> that
///     represents the horizontal and vertical amount to scale the view.
///   - anchor: The point with a default of ``UnitPoint/center`` that
///     defines the location within the view from which to apply the
///     transformation.
///
/// - Returns: An effect that scales the view's rendered output.
public func scaleEffect(_ scale: CGSize, anchor: UnitPoint = .center) -> some VisualEffect
/// Scales the view's rendered output by the given amount in both the
/// horizontal and vertical directions, relative to an anchor point.
///
/// - Parameters:
///   - s: The amount to scale the view in the view in both the horizontal
///     and vertical directions.
///   - anchor: The point with a default of ``UnitPoint/center`` that
///     defines the location within the view from which to apply the
///     transformation.
///
/// - Returns: An effect that scales the view's rendered output.
public func scaleEffect(_ scale: CGFloat, anchor: UnitPoint = .center) -> some VisualEffect
/// Scales the view's rendered output by the given horizontal and vertical
/// amounts, relative to an anchor point.
///
/// - Parameters:
///   - x: An amount that represents the horizontal amount to scale the
///     view. The default value is `1.0`.
///   - y: An amount that represents the vertical amount to scale the view.
///     The default value is `1.0`.
///   - anchor: The point with a default of ``UnitPoint/center`` that
///     defines the location within the view from which to apply the
///     transformation.
///
/// - Returns: An effect that scales the view's rendered output.
public func scaleEffect(x: CGFloat = 1.0, y: CGFloat = 1.0, anchor: UnitPoint = .center) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Applies a Gaussian blur to the view.
///
/// Use `blur(radius:opaque:)` to apply a gaussian blur effect to the
/// rendering of the view.
///
/// - Parameters:
///   - radius: The radial size of the blur. A blur is more diffuse when its
///     radius is large.
///   - opaque: A Boolean value that indicates whether the blur renderer
///     permits transparency in the blur output. Set to `true` to create an
///     opaque blur, or set to `false` to permit transparency.
///
/// - Returns: An effect that blurs the view.
public func blur(radius: CGFloat, opaque: Bool = false) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Brightens the view by the specified amount.
///
/// - Parameter amount: A value between 0 (no effect) and 1 (full white
///   brightening) that represents the intensity of the brightness effect.
///
/// - Returns: An effect that brightens the view by the specified amount.
public func brightness(_ amount: Double) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Sets the contrast and separation between similar colors in the view.
///
/// Apply contrast to a view to increase or decrease the separation between
/// similar colors in the view.
///
/// - Parameter amount: The intensity of color contrast to apply. negative
///   values invert colors in addition to applying contrast.
///
/// - Returns: An effect that applies color contrast to the view.
public func contrast(_ amount: Double) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Adds a grayscale effect to the view.
///
/// A grayscale effect reduces the intensity of colors in the view.
///
/// - Parameter amount: The intensity of grayscale to apply from 0.0 to less
///   than 1.0. Values closer to 0.0 are more colorful, and values closer to
///   1.0 are less colorful.
///
/// - Returns: An effect that reduces the intensity of colors in the view.
public func grayscale(_ amount: Double) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Applies a hue rotation effect to the view.
///
/// Use hue rotation effect to shift all of the colors in a view according
/// to the angle you specify.
///
/// - Parameter angle: The hue rotation angle to apply to the colors in the
///   view.
///
/// - Returns: An effect that shifts all of the colors in the view.
public func hueRotation(_ angle: Angle) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Adjusts the color saturation of the view.
///
/// Use color saturation to increase or decrease the intensity of colors in
/// a view.
///
/// - SeeAlso: `contrast(_:)`
/// - Parameter amount: The amount of saturation to apply to the view.
///
/// - Returns: An effect that adjusts the saturation of the view.
public func saturation(_ amount: Double) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Sets the transparency of the view.
///
/// When applying the `opacity(_:)` effect to a view that has already had
/// its opacity transformed, the effect of the underlying opacity
/// transformation is multiplied.
///
/// - Parameter opacity: A value between 0 (fully transparent) and 1 (fully
///   opaque).
///
/// - Returns: An effect that sets the transparency of the view.
public func opacity(_ opacity: Double) -> some VisualEffect
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension VisualEffect {
/// Rotates the view's rendered output in three dimensions around the given
/// axis of rotation.
///
/// Use `rotation3DEffect(_:axis:anchor:anchorZ:perspective:)` to rotate the
/// view in three dimensions around the given axis of rotation, and
/// optionally, position the view at a custom display order and perspective.
///
/// - Parameters:
///   - angle: The angle at which to rotate the view.
///   - axis: The `x`, `y` and `z` elements that specify the axis of
///     rotation.
///   - anchor: The location with a default of ``UnitPoint/center`` that
///     defines a point in 3D space about which the rotation is anchored.
///   - anchorZ: The location with a default of `0` that defines a point in
///     3D space about which the rotation is anchored.
///   - perspective: The relative vanishing point with a default of `1` for
///     this rotation.
///
/// - Returns: An effect that rotates the view's rendered output in three
///   dimensions.
public func rotation3DEffect(_ angle: Angle, axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint = .center, anchorZ: CGFloat = 0, perspective: CGFloat = 1) -> some VisualEffect
}
/// A date picker style that displays each component as columns in a scrollable
/// wheel.
///
/// You can also use ``DatePickerStyle/wheel`` to construct this style.
@available(iOS 13.0, watchOS 10.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public struct WheelDatePickerStyle : DatePickerStyle {
/// Creates an instance of the wheel date picker style.
public init()
/// Returns the appearance and interaction content for a `DatePicker`.
///
/// The system calls this method for each ``DatePicker`` instance in a view
/// hierarchy where this style is the current date picker style.
///
/// - Parameter configuration : The properties of the date picker.
@available(iOS 16.0, watchOS 10.0, *)
public func makeBody(configuration: WheelDatePickerStyle.Configuration) -> some View
/// A view representing the appearance and interaction of a `DatePicker`.
public typealias Body = some View
}
/// A picker style that presents the options in a scrollable wheel that shows
/// the selected option and a few neighboring options.
///
/// You can also use ``PickerStyle/wheel`` to construct this style.
@available(iOS 13.0, watchOS 6.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
public struct WheelPickerStyle : PickerStyle {
/// Sets the picker style to display an item wheel from which the user makes
/// a selection.
public init()
}
/// The configuration and content of a widget to display on the Home screen or
/// in Notification Center.
///
/// Widgets show glanceable and relevant content from your app right on the iOS
/// Home screen or in Notification Center on macOS. Users can add, configure, and
/// arrange widgets to suit their individual needs. You can provide multiple
/// types of widgets, each presenting a specific kind of information. When
/// users want more information, like to read the full article for a headline
/// or to see the details of a package delivery, the widget lets them get to
/// the information in your app quickly.
///
/// There are three key components to a widget:
///
/// * A configuration that determines whether the widget is configurable,
///   identifies the widget, and defines the SwiftUI views that show the
///   widget's content.
/// * A timeline provider that drives the process of updating the widget's view
///   over time.
/// * SwiftUI views used by WidgetKit to display the widget.
///
/// For information about adding a widget extension to your app, and keeping
/// your widget up to date, see
/// <doc://com.apple.documentation/documentation/WidgetKit/Creating-a-Widget-Extension>
/// and
/// <doc://com.apple.documentation/documentation/WidgetKit/Keeping-a-Widget-Up-To-Date>,
/// respectively.
///
/// By adding a custom SiriKit intent definition, you can let users customize
/// their widgets to show the information that's most relevant to them. If
/// you've already added support for Siri or Shortcuts, you're well on your way
/// to supporting customizable widgets. For more information, see
/// <doc://com.apple.documentation/documentation/WidgetKit/Making-a-Configurable-Widget>.
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public protocol Widget {
/// The type of configuration representing the content of the widget.
///
/// When you create a custom widget, Swift infers this type from your
/// implementation of the required ``Widget/body-swift.property`` property.
associatedtype Body : WidgetConfiguration
/// Creates a widget using `body` as its content.
init()
/// The content and behavior of the widget.
///
/// For any widgets that you create, provide a computed `body` property that
/// defines the widget as a composition of SwiftUI views.
///
/// Swift infers the widget's ``SwiftUI/Scene/Body-swift.associatedtype``
/// associated type based on the contents of the `body` property.
var body: Self.Body { get }
}
/// A container used to expose multiple widgets from a single widget extension.
///
/// To support multiple types of widgets, add the `@main` attribute to a
/// structure that conforms to `WidgetBundle`. For example, a game might have
/// one widget to display summary information about the game and a second
/// widget to display detailed information about individual characters.
///
///     @main
///     struct GameWidgets: WidgetBundle {
///        var body: some Widget {
///            GameStatusWidget()
///            CharacterDetailWidget()
///        }
///     }
///
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public protocol WidgetBundle {
/// The type of widget that represents the content of the bundle.
///
/// When you support more than one widget, Swift infers this type from your
/// implementation of the required ``WidgetBundle/body-swift.property``
/// property.
associatedtype Body : Widget
/// Creates a widget bundle using the bundle's body as its content.
init()
/// Declares the group of widgets that an app supports.
///
/// The order that the widgets appear in this property determines the order
/// they are shown to the user when adding a widget. The following example
/// shows how to use a widget bundle builder to define a body showing
/// a game status widget first and a character detail widget second:
///
///     @main
///     struct GameWidgets: WidgetBundle {
///        var body: some Widget {
///            GameStatusWidget()
///            CharacterDetailWidget()
///        }
///     }
///
@WidgetBundleBuilder var body: Self.Body { get }
}
/// A custom attribute that constructs a widget bundle's body.
///
/// Use the `@WidgetBundleBuilder` attribute to group multiple widgets listed
/// in the ``WidgetBundle/body-swift.property`` property of a widget bundle.
/// For example, the following code defines a widget bundle that consists of
/// two widgets.
///
///     @main
///     struct GameWidgets: WidgetBundle {
///        @WidgetBundleBuilder
///        var body: some Widget {
///            GameStatusWidget()
///            CharacterDetailWidget()
///        }
///     }
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
@resultBuilder public struct WidgetBundleBuilder {
/// Builds an expression within the builder.
public static func buildExpression<Content>(_ content: Content) -> Content where Content : Widget
/// Builds an empty Widget from a block containing no statements, `{ }`.
public static func buildBlock() -> some Widget
/// Builds a single Widget written as a child view (e..g, `{ MyWidget() }`)
/// through unmodified.
public static func buildBlock<Content>(_ content: Content) -> some Widget where Content : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
/// Provides support for "if" statements in multi-statement closures,
/// producing an optional widget that is visible only when the condition
/// evaluates to `true`.
///
/// "if" statement in a ``WidgetBundleBuilder`` are limited to only
/// `#available()` clauses.
public static func buildOptional(_ widget: (Widget & _LimitedAvailabilityWidgetMarker)?) -> some Widget
/// Provides support for "if" statements with `#available()` clauses in
/// multi-statement closures, producing conditional content for the "then"
/// branch, i.e. the conditionally-available branch.
public static func buildLimitedAvailability(_ widget: some Widget) -> Widget & _LimitedAvailabilityWidgetMarker
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Widget where C0 : Widget, C1 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget, C5 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget, C5 : Widget, C6 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget, C5 : Widget, C6 : Widget, C7 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget, C5 : Widget, C6 : Widget, C7 : Widget, C8 : Widget
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetBundleBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some Widget where C0 : Widget, C1 : Widget, C2 : Widget, C3 : Widget, C4 : Widget, C5 : Widget, C6 : Widget, C7 : Widget, C8 : Widget, C9 : Widget
}
/// A type that describes a widget's content.
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
public protocol WidgetConfiguration {
/// The type of widget configuration representing the body of
/// this configuration.
///
/// When you create a custom widget, Swift infers this type from your
/// implementation of the required `body` property.
associatedtype Body : WidgetConfiguration
/// The content and behavior of this widget.
var body: Self.Body { get }
}
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension WidgetConfiguration {
/// Runs the given action when the system provides a background task.
///
/// When the system wakes your app or extension for one or more background
/// tasks, it will call any actions associated with matching tasks. When your
/// async actions return, the system will put your app back into a suspended
/// state. In Widget Extensions, this modifier can be used to handle URL Session
/// background tasks with ``BackgroundTask/urlSession``.
///
/// - Parameters:
///    - task: The type of task the action responds to.
///    - action: The closure that is called when the system provides
///      a task matching the provided task.
public func backgroundTask<D, R>(_ task: BackgroundTask<D, R>, action: @escaping @Sendable (D) async -> R) -> some WidgetConfiguration where D : Sendable, R : Sendable
}
/// A style appropriate for elements that should match the background
/// of their containing window.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@available(visionOS, unavailable)
public struct WindowBackgroundShapeStyle : ShapeStyle {
/// Creates a new window background shape style instance.
public init()
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
/// A scene that presents a group of identically structured windows.
///
/// Use a `WindowGroup` as a container for a view hierarchy that your app
/// presents. The hierarchy that you declare as the group's content serves as a
/// template for each window that the app creates from that group:
///
///     @main
///     struct Mail: App {
///         var body: some Scene {
///             WindowGroup {
///                 MailViewer() // Define a view hierarchy for the window.
///             }
///         }
///     }
///
/// SwiftUI takes care of certain platform-specific behaviors. For example,
/// on platforms that support it, like macOS and iPadOS, people can open more
/// than one window from the group simultaneously. In macOS, people
/// can gather open windows together in a tabbed interface. Also in macOS,
/// window groups automatically provide commands for standard window
/// management.
///
/// > Important: To enable an iPadOS app to simultaneously display multiple
/// windows, be sure to include the
/// <doc://com.apple.documentation/documentation/bundleresources/information_property_list/uiapplicationscenemanifest/uiapplicationsupportsmultiplescenes>
/// key with a value of `true` in the
/// <doc://com.apple.documentation/documentation/bundleresources/information_property_list/uiapplicationscenemanifest>
/// dictionary of your app's Information Property List.
///
/// Every window in the group maintains independent state. For example, the
/// system allocates new storage for any ``State`` or ``StateObject`` variables
/// instantiated by the scene's view hierarchy for each window that it creates.
///
/// For document-based apps, use ``DocumentGroup`` to define windows instead.
///
/// ### Open windows programmatically
///
/// If you initialize a window group with an identifier, a presentation type,
/// or both, you can programmatically open a window from the group. For example,
/// you can give the mail viewer scene from the previous example an identifier:
///
///     WindowGroup(id: "mail-viewer") { // Identify the window group.
///         MailViewer()
///     }
///
/// Elsewhere in your code, you can use the ``EnvironmentValues/openWindow``
/// action from the environment to create a new window from the group:
///
///     struct NewViewerButton: View {
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             Button("Open new mail viewer") {
///                 openWindow(id: "mail-viewer") // Match the group's identifier.
///             }
///         }
///     }
///
/// Be sure to use unique strings for identifiers that you apply to window
/// groups in your app.
///
/// ### Present data in a window
///
/// If you initialize a window group with a presentation type, you can pass
/// data of that type to the window when you open it. For example, you can
/// define a second window group for the Mail app that displays a specified
/// message:
///
///     @main
///     struct Mail: App {
///         var body: some Scene {
///             WindowGroup {
///                 MailViewer(id: "mail-viewer")
///             }
///
///             // A window group that displays messages.
///             WindowGroup(for: Message.ID.self) { $messageID in
///                 MessageDetail(messageID: messageID)
///             }
///         }
///     }
///
/// When you call the ``EnvironmentValues/openWindow`` action with a
/// value, SwiftUI finds the window group with the matching type
/// and passes a binding to the value into the window group's content closure.
/// For example, you can define a button that opens a message by passing
/// the message's identifier:
///
///     struct NewMessageButton: View {
///         var message: Message
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             Button("Open message") {
///                 openWindow(value: message.id)
///             }
///         }
///     }
///
/// Be sure that the type you present conforms to both the
/// <doc://com.apple.documentation/documentation/Swift/Hashable>
/// and <doc://com.apple.documentation/documentation/Swift/Codable> protocols.
/// Also, prefer lightweight data for the presentation value.
/// For model values that conform to the
/// <doc://com.apple.documentation/documentation/Swift/Identifiable> protocol,
/// the value's identifier works well as a presentation type, as the above
/// example demonstrates.
///
/// If a window with a binding to the same value that you pass to the
/// `openWindow` action already appears in the user interface, the system
/// brings the existing window to the front rather than opening a new window.
/// If SwiftUI doesn't have a value to provide --- for example, when someone
/// opens a window by choosing File > New Window from the macOS menu bar ---
/// SwiftUI passes a binding to a `nil` value instead. To avoid receiving a
/// `nil` value, you can optionally specify a default value in your window
/// group initializer. For example, for the message viewer, you can present
/// a new empty message:
///
///     WindowGroup(for: Message.ID.self) { $messageID in
///         MessageDetail(messageID: messageID)
///     } defaultValue: {
///         model.makeNewMessage().id // A new message that your model stores.
///     }
///
/// SwiftUI persists the value of the binding for the purposes of state
/// restoration, and reapplies the same value when restoring the window. If the
/// restoration process results in an error, SwiftUI sets the binding to the
/// default value if you provide one, or `nil` otherwise.
///
/// ### Title your app's windows
///
/// To help people distinguish among windows from different groups,
/// include a title as the first parameter in the group's initializer:
///
///     WindowGroup("Message", for: Message.ID.self) { $messageID in
///         MessageDetail(messageID: messageID)
///     }
///
/// SwiftUI uses this title when referring to the window in:
///
/// * The list of new windows that someone can open using the File > New menu.
/// * The window's title bar.
/// * The list of open windows that the Window menu displays.
///
/// If you don't provide a title for a window, the system refers to the window
/// using the app's name instead.
///
/// > Note: You can override the title that SwiftUI uses for a window in the
///   window's title bar and the menu's list of open windows by adding one of
///   the ``View/navigationTitle(_:)-avgj`` modifiers to the window's content.
///   This enables you to customize and dynamically update the title for each
///   individual window instance.
///
/// ### Distinguish windows that present like data
///
/// To programmatically distinguish between windows that present the same type
/// of data, like when you use a
/// <doc://com.apple.documentation/documentation/Foundation/UUID>
/// as the identifier for more than one model type, add the `id` parameter
/// to the group's initializer to provide a unique string identifier:
///
///     WindowGroup("Message", id: "message", for: UUID.self) { $uuid in
///         MessageDetail(uuid: uuid)
///     }
///     WindowGroup("Account", id: "account-info", for: UUID.self) { $uuid in
///         AccountDetail(uuid: uuid)
///     }
///
/// Then use both the identifer and a value to open the window:
///
///     struct ActionButtons: View {
///         var messageID: UUID
///         var accountID: UUID
///
///         @Environment(\.openWindow) private var openWindow
///
///         var body: some View {
///             HStack {
///                 Button("Open message") {
///                     openWindow(id: "message", value: messageID)
///                 }
///                 Button("Edit account information") {
///                     openWindow(id: "account-info", value: accountID)
///                 }
///             }
///         }
///     }
///
/// ### Dismiss a window programmatically
///
/// The system provides people with platform-appropriate controls to dismiss a
/// window. You can also dismiss windows programmatically by calling the
/// ``EnvironmentValues/dismiss`` action from within the window's view
/// hierarchy. For example, you can include a button in the account detail
/// view from the previous example that dismisses the view:
///
///     struct AccountDetail: View {
///         var uuid: UUID?
///         @Environment(\.dismiss) private var dismiss
///
///         var body: some View {
///             VStack {
///                 // ...
///
///                 Button("Dismiss") {
///                     dismiss()
///                 }
///             }
///         }
///     }
///
/// The dismiss action doesn't close the window if you call it from a
/// modal --- like a sheet or a popover --- that you present
/// from the window. In that case, the action dismisses the modal presentation
/// instead.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct WindowGroup<Content> : Scene where Content : View {
/// Creates a window group with an identifier.
///
/// The window group uses the given view as a
/// template to form the content of each window in the group.
///
/// - Parameters:
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - content: A closure that creates the content for each instance
///     of the group.
public init(id: String, @ViewBuilder content: () -> Content)
/// Creates a window group with a text view title and an identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - content: A closure that creates the content for each instance
///     of the group.
public init(_ title: Text, id: String, @ViewBuilder content: () -> Content)
/// Creates a window group with a localized title string and an
/// identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// - Parameters:
///   - titleKey: The title key to use for the title of the group.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - content: A closure that creates the content for each instance
///     of the group.
public init(_ titleKey: LocalizedStringKey, id: String, @ViewBuilder content: () -> Content)
/// Creates a window group with a title string and an identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - content: A closure that creates the content for each instance
///     of the group.
public init<S>(_ title: S, id: String, @ViewBuilder content: () -> Content) where S : StringProtocol
/// Creates a window group.
///
/// The window group uses the given view as a template to form the
/// content of each window in the group.
///
/// - Parameter content: A closure that creates the content for each
///   instance of the group.
public init(@ViewBuilder content: () -> Content)
/// Creates a window group with a text view title.
///
/// The window group uses the given view as a
/// template to form the content of each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - content: A closure that creates the content for each instance
///     of the group.
public init(_ title: Text, @ViewBuilder content: () -> Content)
/// Creates a window group with a localized title string.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// - Parameters:
///   - titleKey: The title key to use for the group's title.
///   - content: A closure that creates the content for each instance
///     of the group.
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content)
/// Creates a window group with a title string.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - content: A closure that creates the content for each instance
///     of the group.
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol
/// The content and behavior of the scene.
///
/// For any scene that you create, provide a computed `body` property that
/// defines the scene as a composition of other scenes. You can assemble a
/// scene from built-in scenes that SwiftUI provides, as well as other
/// scenes that you've defined.
///
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype``
/// associated type based on the contents of the `body` property.
@MainActor public var body: some Scene { get }
/// The type of scene that represents the body of this scene.
///
/// When you create a custom scene, Swift infers this type from your
/// implementation of the required ``SwiftUI/Scene/body-swift.property``
/// property.
public typealias Body = some Scene
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension WindowGroup {
/// Creates a data-presenting window group with an identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(id: String, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a text view title and an
/// identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(_ title: Text, id: String, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a localized title
/// string and an identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - titleKey: The title key to use for the group's title.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(_ titleKey: LocalizedStringKey, id: String, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a title string and an
/// identifier.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<S, D, C>(_ title: S, id: String, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, S : StringProtocol, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group.
///
/// The window group uses the given view as a template to form the
/// content of each window in the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a text view title.
///
/// The window group uses the given view as a
/// template to form the content of each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(_ title: Text, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a localized title
/// string.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - titleKey: The title key to use for the group's title.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<D, C>(_ titleKey: LocalizedStringKey, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a title string.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
public init<S, D, C>(_ title: S, for type: D.Type, @ViewBuilder content: @escaping (Binding<D?>) -> C) where Content == PresentedWindowContent<D, C>, S : StringProtocol, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with an identifier and a default
/// value.
///
/// The window group uses the given view as a
/// template to form the content of each window in the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(id: String, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a text view title, an
/// identifier, and a default value.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(_ title: Text, id: String, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a localized title
/// string, an identifier, and a default value.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - titleKey: The title key to use for the group's title.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(_ titleKey: LocalizedStringKey, id: String, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a title string, an
/// identifier, and a default value.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - id: A string that uniquely identifies the window group. Identifiers
///     must be unique among the window groups in your app.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<S, D, C>(_ title: S, id: String, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, S : StringProtocol, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a default value.
///
/// The window group using the given view as a template to form the
/// content of each window in the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - type:The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a text view title and a
/// default value.
///
/// The window group uses the given view as a
/// template to form the content of each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// > Important: The system ignores any text styling that you apply to
///   the ``Text`` view title, like bold or italics. However, you can use
///   the formatting controls that the view offers, like for localization,
///   dates, and numerical representations.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The ``Text`` view to use for the group's title.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(_ title: Text, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a localized title
/// string and a default value.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - titleKey: The title key to use for the group's title.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<D, C>(_ titleKey: LocalizedStringKey, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, D : Decodable, D : Encodable, D : Hashable, C : View
/// Creates a data-presenting window group with a title string and a default
/// value.
///
/// The window group uses the specified content as a
/// template to create each window in the group.
///
/// The system uses the title to distinguish the window group in the user
/// interface, such as in the name of commands associated with the group.
///
/// SwiftUI creates a window from the group when you present a value
/// of the specified type using the ``EnvironmentValues/openWindow`` action.
///
/// - Parameters:
///   - title: The string to use for the title of the group.
///   - type: The type of presented data this window group accepts.
///   - content: A closure that creates the content for each instance
///     of the group. The closure receives a binding to the value that you
///     pass into the ``EnvironmentValues/openWindow`` action when you open
///     the window. SwiftUI automatically persists and restores the value
///     of this binding as part of the state restoration process.
///   - defaultValue: A closure that returns a default value to present.
///     SwiftUI calls this closure when it has no data to provide, like
///     when someone opens a new window from the File > New Window menu
///     item.
public init<S, D, C>(_ title: S, for type: D.Type = D.self, @ViewBuilder content: @escaping (Binding<D>) -> C, defaultValue: @escaping () -> D) where Content == PresentedWindowContent<D, C>, S : StringProtocol, D : Decodable, D : Encodable, D : Hashable, C : View
}
/// The resizability of a window.
///
/// Use the ``Scene/windowResizability(_:)`` scene modifier to apply a value
/// of this type to a ``Scene`` that you define in your ``App`` declaration.
/// The value that you specify indicates the strategy the system uses to
/// place minimum and maximum size restrictions on windows that it creates
/// from that scene.
///
/// For example, you can create a window group that people can resize to
/// between 100 and 400 points in both dimensions by applying both a frame
/// with those constraints to the scene's content, and the
/// ``WindowResizability/contentSize`` resizability to the scene:
///
///     @main
///     struct MyApp: App {
///         var body: some Scene {
///             WindowGroup {
///                 ContentView()
///                     .frame(
///                         minWidth: 100, maxWidth: 400,
///                         minHeight: 100, maxHeight: 400)
///             }
///             .windowResizability(.contentSize)
///         }
///     }
///
/// The default value for all scenes if you don't apply the modifier is
/// ``WindowResizability/automatic``. With that strategy, ``Settings``
/// windows use the ``WindowResizability/contentSize`` strategy, while
/// all others use ``WindowResizability/contentMinSize``.
@available(iOS 17.0, macOS 13.0, visionOS 1.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct WindowResizability : Sendable {
/// The automatic window resizability.
///
/// When you use automatic resizability, SwiftUI applies a resizing
/// strategy that's appropriate for the scene type:
/// * Windows from ``WindowGroup``, ``Window``, and ``DocumentGroup``
///   scene declarations use the ``contentMinSize`` strategy.
/// * A window from a ``Settings`` scene declaration uses the
///   ``contentSize`` strategy.
///
/// Automatic resizability is the default if you don't specify another
/// value using the ``Scene/windowResizability(_:)`` scene modifier.
public static var automatic: WindowResizability
/// A window resizability that's derived from the window's content.
///
/// Windows that use this resizability have:
/// * A minimum size that matches the minimum size of the window's content.
/// * A maximum size that matches the maximum size of the window's content.
public static var contentSize: WindowResizability
/// A window resizability that's partially derived from the window's
/// content.
///
/// Windows that use this resizability have:
/// * A minimum size that matches the minimum size of the window's content.
/// * No maximum size.
public static var contentMinSize: WindowResizability
}
/// A view that overlays its subviews, aligning them in both axes.
///
/// The `ZStack` assigns each successive subview a higher z-axis value than
/// the one before it, meaning later subviews appear "on top" of earlier ones.
///
/// The following example creates a `ZStack` of 100 x 100 point ``Rectangle``
/// views filled with one of six colors, offsetting each successive subview
/// by 10 points so they don't completely overlap:
///
///     let colors: [Color] =
///         [.red, .orange, .yellow, .green, .blue, .purple]
///
///     var body: some View {
///         ZStack {
///             ForEach(0..<colors.count) {
///                 Rectangle()
///                     .fill(colors[$0])
///                     .frame(width: 100, height: 100)
///                     .offset(x: CGFloat($0) * 10.0,
///                             y: CGFloat($0) * 10.0)
///             }
///         }
///     }
///
/// ![Six squares of different colors, stacked atop each other, with a 10-point
/// offset in both the x and y axes for each layer so they can be
/// seen.](SwiftUI-ZStack-offset-rectangles.png)
///
/// The `ZStack` uses an ``Alignment`` to set the x- and y-axis coordinates of
/// each subview, defaulting to a ``Alignment/center`` alignment. In the following
/// example, the `ZStack` uses a ``Alignment/bottomLeading`` alignment to lay
/// out two subviews, a red 100 x 50 point rectangle below, and a blue 50 x 100
/// point rectangle on top. Because of the alignment value, both rectangles
/// share a bottom-left corner with the `ZStack` (in locales where left is the
/// leading side).
///
///     var body: some View {
///         ZStack(alignment: .bottomLeading) {
///             Rectangle()
///                 .fill(Color.red)
///                 .frame(width: 100, height: 50)
///             Rectangle()
///                 .fill(Color.blue)
///                 .frame(width:50, height: 100)
///         }
///         .border(Color.green, width: 1)
///     }
///
/// ![A green 100 by 100 square containing two overlapping rectangles: on the
/// bottom, a red 100 by 50 rectangle, and atop it, a blue 50 by 100 rectangle.
/// The rectangles share their bottom left point with the containing green
/// square.](SwiftUI-ZStack-alignment.png)
///
/// > Note: If you need a version of this stack that conforms to the ``Layout``
/// protocol, like when you want to create a conditional layout using
/// ``AnyLayout``, use ``ZStackLayout`` instead.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct ZStack<Content> : View where Content : View {
/// Creates an instance with the given alignment.
///
/// - Parameters:
///   - alignment: The guide for aligning the subviews in this stack on both
///     the x- and y-axes.
///   - content: A view builder that creates the content of this stack.
@inlinable public init(alignment: Alignment = .center, @ViewBuilder content: () -> Content)
/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required ``View/body-swift.property`` property.
public typealias Body = Never
}
/// An overlaying container that you can use in conditional layouts.
///
/// This layout container behaves like a ``ZStack``, but conforms to the
/// ``Layout`` protocol so you can use it in the conditional layouts that you
/// construct with ``AnyLayout``. If you don't need a conditional layout, use
/// ``ZStack`` instead.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
@frozen public struct ZStackLayout : Layout {
/// The alignment of subviews.
public var alignment: Alignment
/// Creates a stack with the specified alignment.
///
/// - Parameters:
///   - alignment: The guide for aligning the subviews in this stack
///     on both the x- and y-axes.
@inlinable public init(alignment: Alignment = .center)
/// The type defining the data to animate.
public typealias AnimatableData = EmptyAnimatableData
/// Cached values associated with the layout instance.
///
/// If you create a cache for your custom layout, you can use
/// a type alias to define this type as your data storage type.
/// Alternatively, you can refer to the data storage type directly in all
/// the places where you work with the cache.
///
/// See ``makeCache(subviews:)-23agy`` for more information.
public typealias Cache = Void
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension ZStackLayout : Sendable {
}
/// Returns the result of recomputing the view's body with the provided
/// animation, and runs the completion when all animations are complete.
///
/// This function sets the given ``Animation`` as the ``Transaction/animation``
/// property of the thread's current ``Transaction`` as well as calling
/// ``Transaction/addAnimationCompletion`` with the specified completion.
///
/// The completion callback will always be fired exactly one time. If no
/// animations are created by the changes in `body`, then the callback will be
/// called immediately after `body`.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public func withAnimation<Result>(_ animation: Animation? = .default, completionCriteria: AnimationCompletionCriteria = .logicallyComplete, _ body: () throws -> Result, completion: @escaping () -> Void) rethrows -> Result
/// Returns the result of recomputing the view's body with the provided
/// animation.
///
/// This function sets the given ``Animation`` as the ``Transaction/animation``
/// property of the thread's current ``Transaction``.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public func withAnimation<Result>(_ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result
/// Executes a closure with the specified transaction and returns the result.
///
/// - Parameters:
///   - transaction : An instance of a transaction, set as the thread's current
///     transaction.
///   - body: A closure to execute.
///
/// - Returns: The result of executing the closure with the specified
///   transaction.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public func withTransaction<Result>(_ transaction: Transaction, _ body: () throws -> Result) rethrows -> Result
/// Executes a closure with the specified transaction key path and value and
/// returns the result.
///
/// - Parameters:
///   - keyPath: A key path that indicates the property of the ``Transaction``
///     structure to update.
///   - value: The new value to set for the item specified by `keyPath`.
///   - body: A closure to execute.
///
/// - Returns: The result of executing the closure with the specified
///   transaction value.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public func withTransaction<R, V>(_ keyPath: WritableKeyPath<Transaction, V>, _ value: V, _ body: () throws -> R) rethrows -> R
extension AttributeScopes {
/// A property for accessing the attribute scopes defined by SwiftUI.
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
public var swiftUI: AttributeScopes.SwiftUIAttributes.Type { get }
/// Attribute scopes defined by SwiftUI.
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
public struct SwiftUIAttributes : AttributeScope {
/// A property for accessing a font attribute.
public let font: AttributeScopes.SwiftUIAttributes.FontAttribute
/// A property for accessing a foreground color attribute.
public let foregroundColor: AttributeScopes.SwiftUIAttributes.ForegroundColorAttribute
/// A property for accessing a background color attribute.
public let backgroundColor: AttributeScopes.SwiftUIAttributes.BackgroundColorAttribute
/// A property for accessing a strikethrough style attribute.
public let strikethroughStyle: AttributeScopes.SwiftUIAttributes.StrikethroughStyleAttribute
/// A property for accessing an underline style attribute.
public let underlineStyle: AttributeScopes.SwiftUIAttributes.UnderlineStyleAttribute
/// A property for accessing a kerning attribute.
public let kern: AttributeScopes.SwiftUIAttributes.KerningAttribute
/// A property for accessing a tracking attribute.
public let tracking: AttributeScopes.SwiftUIAttributes.TrackingAttribute
/// A property for accessing a baseline offset attribute.
public let baselineOffset: AttributeScopes.SwiftUIAttributes.BaselineOffsetAttribute
/// A property for accessing attributes defined by the Accessibility framework.
public let accessibility: AttributeScopes.AccessibilityAttributes
/// A property for accessing attributes defined by the Foundation framework.
public let foundation: AttributeScopes.FoundationAttributes
public typealias DecodingConfiguration = AttributeScopeCodableConfiguration
public typealias EncodingConfiguration = AttributeScopeCodableConfiguration
}
}
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
extension AttributeDynamicLookup {
public subscript<T>(dynamicMember keyPath: KeyPath<AttributeScopes.SwiftUIAttributes, T>) -> T where T : AttributedStringKey { get }
}
extension NSDirectionalEdgeInsets {
/// Create edge insets from the equivalent EdgeInsets.
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
@available(watchOS, unavailable)
public init(_ edgeInsets: EdgeInsets)
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Never {
/// The type for the internal content of this `AccessibilityRotorContent`.
public typealias Body = Never
/// The internal content of this `AccessibilityRotorContent`.
public var body: Never { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Float : VectorArithmetic {
/// Multiplies each component of this value by the given value.
public mutating func scale(by rhs: Double)
/// Returns the dot-product of this vector arithmetic instance with itself.
public var magnitudeSquared: Double { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Double : VectorArithmetic {
/// Multiplies each component of this value by the given value.
public mutating func scale(by rhs: Double)
/// Returns the dot-product of this vector arithmetic instance with itself.
public var magnitudeSquared: Double { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CGFloat : VectorArithmetic {
/// Multiplies each component of this value by the given value.
public mutating func scale(by rhs: Double)
/// Returns the dot-product of this vector arithmetic instance with itself.
public var magnitudeSquared: Double { get }
}
extension RangeReplaceableCollection where Self : MutableCollection {
/// Removes all the elements at the specified offsets from the collection.
///
/// - Complexity: O(*n*) where *n* is the length of the collection.
///
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public mutating func remove(atOffsets offsets: IndexSet)
}
extension MutableCollection {
/// Moves all the elements at the specified offsets to the specified
/// destination offset, preserving ordering.
///
/// Pass an offset as `destination` to indicate where in the collection the
/// moved elements should be inserted. Of the elements that are not
/// represented by the offsets in `source`, those before `destination` are
/// moved toward the beginning of the collection to make room for the moved
/// elements, while those at or after `destination` are moved toward the
/// end.
///
/// In this example, demonstrating moving several elements to different
/// destination offsets, `lowercaseOffsets` represents the offsets of the
/// lowercase elements in `letters`:
///
///     var letters = Array("ABcDefgHIJKlmNO")
///     let lowercaseOffsets = IndexSet(...)
///     letters.move(fromOffsets: lowercaseOffsets, toOffset: 2)
///     // String(letters) == "ABcefglmDHIJKNO"
///
///     // Reset the `letters` array.
///     letters = Array("ABcDefgHIJKlmNO")
///     letters.move(fromOffsets: lowercaseOffsets, toOffset: 15)
///     // String(letters) == "ABDHIJKNOcefglm"
///
/// If `source` represents a single element, calling this method with its
/// own offset, or the offset of the following element, as `destination`
/// has no effect.
///
///     letters = Array("ABcDefgHIJKlmNO")
///     letters.move(fromOffsets: IndexSet(integer: 2), toOffset: 2)
///     // String(letters) == "ABcDefgHIJKlmNO"
///
/// - Parameters:
///   - source: An index set representing the offsets of all elements that
///     should be moved.
///   - destination: The offset of the element before which to insert the
///     moved elements. `destination` must be in the closed range
///     `0...count`.
///
/// - Complexity: O(*n* log *n*), where *n* is the length of the collection.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public mutating func move(fromOffsets source: IndexSet, toOffset destination: Int)
}
/// Extends `T?` to conform to `Gesture` type if `T` also conforms to
/// `Gesture`. A nil value is mapped to an empty (i.e. failing)
/// gesture.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Optional : Gesture where Wrapped : Gesture {
/// The type representing the gesture's value.
public typealias Value = Wrapped.Value
/// The type of gesture representing the body of `Self`.
public typealias Body = Never
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension Never : AccessibilityRotorContent {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Never : ToolbarContent, CustomizableToolbarContent {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CGPoint {
public func applying(_ m: ProjectionTransform) -> CGPoint
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Optional : View where Wrapped : View {
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Optional : TableRowContent where Wrapped : TableRowContent {
/// The type of value represented by this table row content.
public typealias TableRowValue = Wrapped.TableRowValue
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Never : ShapeStyle {
/// The type of shape style this will resolve to.
///
/// When you create a custom shape style, Swift infers this type
/// from your implementation of the required `resolve` function.
public typealias Resolved = Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Never : TableColumnContent {
/// The type of sort comparator associated with this table column content.
public typealias TableColumnSortComparator = Never
/// The type of content representing the body of this table column content.
public typealias TableColumnBody = Never
/// The composition of content that comprise the table column content.
public var tableColumnBody: Never { get }
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Never : Gesture {
/// The type representing the gesture's value.
public typealias Value = Never
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Never : Scene {
}
@available(iOS 14.0, macOS 11.0, watchOS 9.0, *)
@available(tvOS, unavailable)
extension Never : WidgetConfiguration {
}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension NSUserActivity {
/// Error types when getting/setting typed payload
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public enum TypedPayloadError : Error {
/// UserInfo is empty or invalid
case invalidContent
/// Content failed to encode into a valid Dictionary
case encodingError
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
///   - lhs: A value to compare.
///   - rhs: Another value to compare.
public static func == (a: NSUserActivity.TypedPayloadError, b: NSUserActivity.TypedPayloadError) -> Bool
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
///   don't call `finalize()` on the `hasher` instance provided,
///   or replace it with a different instance.
///   Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
///   of this instance.
public func hash(into hasher: inout Hasher)
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
///
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
///   The compiler provides an implementation for `hashValue` for you.
public var hashValue: Int { get }
}
/// Given a Codable Swift type, return an instance decoded from the
/// NSUserActivity's userInfo dictionary
///
/// - Parameter type: the instance type to be decoded from userInfo
/// - Returns: the type safe instance or raises if it can't be decoded
public func typedPayload<T>(_ type: T.Type) throws -> T where T : Decodable, T : Encodable
/// Given an instance of a Codable Swift type, encode it into the
/// NSUserActivity's userInfo dictionary
///
/// - Parameter payload: the instance to be converted to userInfo
public func setTypedPayload<T>(_ payload: T) throws where T : Decodable, T : Encodable
}
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
extension NSUnderlineStyle {
/// Creates a ``NSUnderlineStyle`` from ``Text.LineStyle``.
///
/// - Parameter lineStyle: A value of ``Text.LineStyle``
/// to wrap with ``NSUnderlineStyle``.
///
/// - Returns: A new ``NSUnderlineStyle``.
public init(_ lineStyle: Text.LineStyle)
}
@available(iOS 16.0, macOS 13.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Optional : Commands where Wrapped : Commands {
public typealias Body = Never
}
extension UIColor {
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
@available(macOS, unavailable)
public convenience init(_ color: Color)
}
extension UIUserInterfaceStyle {
/// Creates a user interface style from its ColorScheme equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ colorScheme: ColorScheme?)
}
extension UIAccessibilityContrast {
/// Create a contrast from its ColorSchemeContrast equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ colorSchemeContrast: ColorSchemeContrast?)
}
extension UIContentSizeCategory {
/// Create a size category from its `ContentSizeCategory` equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ sizeCategory: ContentSizeCategory?)
@available(iOS 15.0, tvOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ dynamicTypeSize: DynamicTypeSize?)
}
extension UITraitEnvironmentLayoutDirection {
/// Create a direction from its LayoutDirection equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ layoutDirection: LayoutDirection)
}
extension UILegibilityWeight {
/// Creates a legibility weight from its LegibilityWeight equivalent.
@available(iOS 14.0, tvOS 14.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
public init(_ legibilityWeight: LegibilityWeight?)
}
extension UIUserInterfaceSizeClass {
/// Creates a UIKit size class from the specified SwiftUI size class.
@available(iOS 14.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public init(_ sizeClass: UserInterfaceSizeClass?)
}
extension Preview {
/// Creates a preview of a SwiftUI view.
///
/// The `#Preview` macro expands into a declaration that calls this initializer. To create a preview
/// that appears in the canvas, you must use the macro, not instantiate a Preview directly.
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
public init(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., body: @escaping @MainActor () -> View)
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Double : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = Double
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension CGFloat : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = CGFloat
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Never {
/// The type of value of rows presented by this column content.
public typealias TableRowValue = Never
}
@available(iOS 16.0, macOS 12.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Never : TableRowContent {
/// The type of content representing the body of this table row content.
public typealias TableRowBody = Never
/// The composition of content that comprise the table row content.
public var tableRowBody: Never { get }
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Optional : ToolbarContent where Wrapped : ToolbarContent {
public typealias Body = Never
}
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension Optional : CustomizableToolbarContent where Wrapped : CustomizableToolbarContent {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Never : View {
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CGPoint : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGFloat, CGFloat>
/// The data to animate.
public var animatableData: CGPoint.AnimatableData
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CGSize : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGFloat, CGFloat>
/// The data to animate.
public var animatableData: CGSize.AnimatableData
}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CGRect : Animatable {
/// The type defining the data to animate.
public typealias AnimatableData = AnimatablePair<CGPoint.AnimatableData, CGSize.AnimatableData>
/// The data to animate.
public var animatableData: CGRect.AnimatableData
}
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Never : Keyframes {
}
@available(iOS 14.0, macOS 11.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension Never : Commands {
}