Skip to content

STRUCT

AdaptedEnvironmentScreen¶

public struct AdaptedEnvironmentScreen<Content>

Wraps a Screen tree with a modified ViewEnvironment.

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

MyScreen(...)
    .adaptedEnvironment(keyPath: \.myValue, to: newValue)

Properties¶

wrapped¶

public var wrapped: Content

The screen wrapped by this screen.

Methods¶

init(wrapping:adapting:)¶

public init(
    wrapping wrapped: Content,
    adapting: @escaping Adapter
)

Wraps a Screen with an environment that is modified using the given configuration block.

  • Parameters:
  • wrapping: The screen to be wrapped.
  • adapting: A block that will set environmental values.

Parameters¶

Name Description
wrapping The screen to be wrapped.
adapting A block that will set environmental values.

init(wrapping:key:value:)¶

public init<Key: ViewEnvironmentKey>(
    wrapping screen: Content,
    key: Key.Type,
    value: Key.Value
)

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

  • Parameters:
  • wrapping: The screen to be wrapped.
  • key: The environment key to modify.
  • value: The new environment value to cascade.

Parameters¶

Name Description
wrapping The screen to be wrapped.
key The environment key to modify.
value The new environment value to cascade.

init(wrapping:keyPath:value:)¶

public init<Value>(
    wrapping screen: Content,
    keyPath: WritableKeyPath<ViewEnvironment, Value>,
    value: Value
)

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

  • Parameters:
  • wrapping: The screen to be wrapped.
  • keyPath: The keypath of the environment value to modify.
  • value: The new environment value to cascade.

Parameters¶

Name Description
wrapping The screen to be wrapped.
keyPath The keypath of the environment value to modify.
value The new environment value to cascade.