AdaptedEnvironment

public struct AdaptedEnvironment : Element

Wraps an element tree with a modified environment.

By specifying environmental values with this element, all child elements nested will automatically inherit those values automatically. Values can be changed anywhere in a sub-tree by inserting another AdaptedEnvironment element.

  • Takes in a mutable Environment which can be mutated to add or override values.

    Declaration

    Swift

    public typealias Adapter = (inout Environment) -> Void
  • Wraps an element with an environment that is modified using the given configuration block.

    Declaration

    Swift

    public init(
        by adapt: @escaping Adapter,
        wrapping wrapped: Element
    )

    Parameters

    by

    A block that will set environmental values.

    wrapping

    The element to be wrapped.

  • Wraps an element with an environment that is modified for a single key and value.

    Declaration

    Swift

    public init<Key>(
        key: Key.Type,
        value: Key.Value,
        wrapping child: Element
    ) where Key: EnvironmentKey

    Parameters

    key

    The environment key to modify.

    value

    The new environment value to cascade.

    wrapping

    The element to be wrapped.

  • Wraps an element with an environment that is modified for a single value.

    Declaration

    Swift

    public init<Value>(
        keyPath: WritableKeyPath<Environment, Value>,
        value: Value,
        wrapping child: Element
    )

    Parameters

    keyPath

    The keypath of the environment value to modify.

    value

    The new environment value to cascade.

    wrapping

    The element to be wrapped.

  • Declaration

    Swift

    public var content: ElementContent { get }
  • Declaration

    Swift

    public func backingViewDescription(with context: ViewDescriptionContext) -> ViewDescription?