FlexBox is the root-level display component. Create a FlexBox and pass it to Display.send(_:) to show content on glasses.
FlexBox is also the only layout type that accepts the layout-shape modifiers flexGrow(_:), flexShrink(_:), alignSelf(_:), padding(_:)-3lpgz, background(_:), and onTap(_:) — each returns a copy of the same FlexBox with one field changed, never wrapping it in another container.
struct FlexBox: ViewComponentSerializable, RootViewSerializable, FlexShapedComponent, Sendable
init
(
direction
, spacing
, alignment
, crossAlignment
, wrap
, padding
, content
)
|
Creates a FlexBox with children built using the result builder DSL.
Signature
public init( direction: Direction, spacing: CGFloat, alignment: Alignment, crossAlignment: Alignment, wrap: Bool, padding: EdgeInsets?, content: () -> [any ViewComponent]) Parameters spacing: CGFloat
Spacing in dp between children. Defaults to 0.
crossAlignment: Alignment
Alignment of children along the cross axis. Defaults to Alignment.start. For column layouts children always stretch to fill the cross axis; this value applies to row layouts.
wrap: Bool
Whether children should wrap to the next line. Defaults to false.
|
alignment
: Alignment |
Alignment of children along the main axis.
|
alignSelf
: Alignment? |
Per-child cross-axis alignment override applied when this FlexBox is a child of another FlexBox.
|
background
: Background |
Background style for this FlexBox. Defaults to Background.none.
|
children
: [any ViewComponent] |
The child components arranged within this flex layout.
|
crossAlignment
: Alignment |
Alignment of children along the cross axis.
For Direction.column and Direction.columnReverse layouts, children always stretch to fill the cross axis and this value is not applied; it takes effect for row layouts.
|
direction
: Direction |
The layout direction for children.
|
flexGrow
: Float |
Flex-grow factor applied when this FlexBox is itself a child of another FlexBox.
|
flexShrink
: Float |
Flex-shrink factor applied when this FlexBox is itself a child of another FlexBox.
|
onClick
: (@Sendable () -> Void)? |
Optional callback invoked when this FlexBox is tapped on the wearable. Set via onTap(_:).
|
padding
: EdgeInsets? |
Padding applied to the edges of the flex container.
|
spacing
: CGFloat |
Spacing in dp between children.
|
wrap
: Bool |
Whether children should wrap to the next line when they exceed the container.
|
alignSelf
(
value
)
| |
background
(
value
)
|
Sets the background style for this FlexBox.
Signature
public func background(_ value: Background) -> FlexBox Parameters _ value: BackgroundReturns FlexBox |
flexGrow
(
value
)
|
Sets the flex-grow factor for this FlexBox.
Signature
public func flexGrow(_ value: Float) -> FlexBox Parameters _ value: FloatReturns FlexBox |
flexShrink
(
value
)
|
Sets the flex-shrink factor for this FlexBox.
Signature
public func flexShrink(_ value: Float) -> FlexBox Parameters _ value: FloatReturns FlexBox |
onTap
(
handler
)
|
Adds a tap handler.
Signature
public func onTap(_ handler: @escaping @Sendable () -> Void) -> FlexBox Parameters _ handler: @escaping @Sendable () -> VoidReturns FlexBox |
padding
(
value
)
|
Sets edge insets as the FlexBox padding.
Signature
public func padding(_ value: CGFloat) -> FlexBox Parameters _ value: CGFloatReturns FlexBox |
padding
(
edges
, value
)
|