ElementContent
public struct ElementContent
Represents the content of an element.
-
Measures the required size of this element’s content.
Declaration
Swift
public func measure(in constraint: SizeConstraint, environment: Environment) -> CGSize
Parameters
constraint
The size constraint.
environment
The environment to measure in.
Return Value
The layout size needed by this content.
-
Declaration
Swift
public var childCount: Int { get }
-
Initializes a new
ElementContent
with the given layout and children.Declaration
Parameters
layout
The layout to use.
configure
A closure that configures the layout and adds children to the container.
-
Initializes a new
ElementContent
with the given element and layout.Declaration
Swift
public init( child: Element, key: AnyHashable? = nil, layout: some SingleChildLayout )
Parameters
element
The single child element.
key
The key to use to unique the element during updates.
layout
The layout that will be used.
-
Initializes a new
ElementContent
with the given element.The given element will be used for measuring, and it will always fill the extent of the parent element.
Declaration
Swift
public init(child: Element)
Parameters
element
The single child element.
-
Initializes a new
ElementContent
that will lazily create its storage during a layout and measurement pass, based on theEnvironment
passed to thebuilder
closure.Declaration
Swift
public init( build builder: @escaping (SizeConstraint, Environment) -> Element )
Parameters
builder
A closure that provides the content
Element
based on the providedSizeConstraint
andEnvironment
.
-
Initializes a new
ElementContent
with no children that delegates to the providedMeasurable
.Declaration
Swift
public init(measurable: Measurable)
Parameters
measurable
How to measure the
ElementContent
. -
Initializes a new
ElementContent
with no children that delegates to the provided measure function.Declaration
Swift
public init( measureFunction: @escaping (SizeConstraint) -> CGSize )
Parameters
measureFunction
How to measure the
ElementContent
in the givenSizeConstraint
. -
Initializes a new
ElementContent
with no children that delegates to the provided measure function.Declaration
Swift
public init( measureFunction: @escaping (SizeConstraint, Environment) -> CGSize )
Parameters
measureFunction
How to measure the
ElementContent
in the givenSizeConstraint
andEnvironment
. -
Initializes a new
ElementContent
with no children that uses the provided intrinsic size for measuring.Declaration
Swift
public init(intrinsicSize: CGSize)
-
Initializes a new
ElementContent
with the given child element, measurement caching key, and environment adapter, which allows adapting the environment to affect the element, plus elements further down the tree.Declaration
Swift
public init( child: Element, environment environmentAdapter: @escaping (inout Environment) -> Void )
Parameters
child
The child element to display.
environmentAdapter
How to adapt the
Environment
for the child and elements further down the tree. -
Initializes a new
ElementContent
with the given child element, measurement caching key, and environment key + value. which adapts the environment to affect the element, plus elements further down the tree.Declaration
Swift
public init<Key>( child: Element, key: Key.Type, value: Key.Value ) where Key: EnvironmentKey
Parameters
child
The child element to display.
key
The key to set in the
Environment
.value
The value to set in the
Environment
for the given key.
-
Creates a new
ElementContent
which uses the provided element to measure its size, but does not place the element as a child in the final, laid out hierarchy.This is useful if you are placing the element in a nested
BlueprintView
, for example (eg to create a stateful element) and just need this element to be correctly sized.Declaration
Swift
public init(measuring element: Element)