LavaUI docs GitHub

enum ViewBuilder

Swift

@resultBuilder enum ViewBuilder

Builds a view from the statements of a closure: several views become a TupleView, if becomes an OptionalView and if/else an EitherView.

There is no for loop support, on purpose: children built by a loop could only be identified by position, which gives a row's state to whatever row moves into its place. Use ForEach with an id.

Sources/LavaUI/ViewBuilder.swift:10

Methods

static func buildBlock() -> EmptyView

An empty block: shows nothing.

Sources/LavaUI/ViewBuilder.swift:17

static func buildBlock<Content>(_ content: Content) -> Content where Content : View

A block with one view: that view, unwrapped.

Sources/LavaUI/ViewBuilder.swift:22

static func buildBlock<each Content>(_ content: repeat each Content) -> TupleView<repeat each Content> where repeat each Content : View

A block with several views: them, as siblings in order.

Sources/LavaUI/ViewBuilder.swift:27

static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> EitherView<TrueContent, FalseContent> where TrueContent : View, FalseContent : View

The if branch of an if/else.

Sources/LavaUI/ViewBuilder.swift:41

static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> EitherView<TrueContent, FalseContent> where TrueContent : View, FalseContent : View

The else branch of an if/else.

Sources/LavaUI/ViewBuilder.swift:48

static func buildExpression<Content>(_ content: Content) -> Content where Content : View

Passes a single view through unchanged.

Sources/LavaUI/ViewBuilder.swift:12

static func buildLimitedAvailability<Content>(_ content: Content) -> Content where Content : View

An if #available block: the view unchanged.

Sources/LavaUI/ViewBuilder.swift:55

static func buildOptional<Content>(_ content: Content?) -> OptionalView<Content> where Content : View

An if without an else.

Sources/LavaUI/ViewBuilder.swift:34