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) -> CGSizeParameters
constraintThe size constraint.
environmentThe environment to measure in.
Return Value
The layout size needed by this content.
-
Declaration
Swift
public var childCount: Int { get }
-
Initializes a new
ElementContentwith the given layout and children.Declaration
Parameters
layoutThe layout to use.
configureA closure that configures the layout and adds children to the container.
-
Initializes a new
ElementContentwith the given element and layout.Declaration
Swift
public init( child: Element, key: AnyHashable? = nil, layout: some SingleChildLayout )Parameters
elementThe single child element.
keyThe key to use to unique the element during updates.
layoutThe layout that will be used.
-
Initializes a new
ElementContentwith 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
elementThe single child element.
-
Initializes a new
ElementContentthat will lazily create its storage during a layout and measurement pass, based on theEnvironmentpassed to thebuilderclosure.Declaration
Swift
public init( build builder: @escaping (SizeConstraint, Environment) -> Element )Parameters
builderA closure that provides the content
Elementbased on the providedSizeConstraintandEnvironment.
-
Initializes a new
ElementContentwith no children that delegates to the providedMeasurable.Declaration
Swift
public init(measurable: Measurable)Parameters
measurableHow to measure the
ElementContent. -
Initializes a new
ElementContentwith no children that delegates to the provided measure function.Declaration
Swift
public init( measureFunction: @escaping (SizeConstraint) -> CGSize )Parameters
measureFunctionHow to measure the
ElementContentin the givenSizeConstraint. -
Initializes a new
ElementContentwith no children that delegates to the provided measure function.Declaration
Swift
public init( measureFunction: @escaping (SizeConstraint, Environment) -> CGSize )Parameters
measureFunctionHow to measure the
ElementContentin the givenSizeConstraintandEnvironment. -
Initializes a new
ElementContentwith no children that uses the provided intrinsic size for measuring.Declaration
Swift
public init(intrinsicSize: CGSize)
-
Initializes a new
ElementContentwith 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
childThe child element to display.
environmentAdapterHow to adapt the
Environmentfor the child and elements further down the tree. -
Initializes a new
ElementContentwith 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: EnvironmentKeyParameters
childThe child element to display.
keyThe key to set in the
Environment.valueThe value to set in the
Environmentfor the given key.
-
Creates a new
ElementContentwhich 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)
View on GitHub
ElementContent Structure Reference