LavaUI docs GitHub

struct Alignment

Swift

struct Alignment

A point in a box: one horizontal choice and one vertical one.

Two axes in a struct rather than nine cases in an enum, which is what SwiftUI settled on and for the reason that shows up immediately here: the nine named corners are combinations, and everything that consumes an alignment consumes one axis at a time. A row container justifies its main axis and aligns its cross axis, and asking a nine-case enum for that means two nine-arm switches that have to stay consistent with each other by inspection. OverlayAnchor was exactly those two switches, and is now a spelling of this.

Named corners still read best at a call site, so they stay — as static members, which pattern-match the same way in an if and compose the way an enum cannot.

Sources/LavaUI/Alignment.swift:55

Constructors

init(horizontal: HorizontalAlignment, vertical: VerticalAlignment)

Creates an alignment from one choice per axis.

Sources/LavaUI/Alignment.swift:62

Properties

static let bottom: Alignment

Centred along the bottom edge.

Sources/LavaUI/Alignment.swift:82

static let bottomLeading: Alignment

The bottom-left corner.

Sources/LavaUI/Alignment.swift:80

static let bottomTrailing: Alignment

The bottom-right corner.

Sources/LavaUI/Alignment.swift:84

static let center: Alignment

Centred on both axes.

Sources/LavaUI/Alignment.swift:76

var horizontal: HorizontalAlignment

Placement along the horizontal axis.

Sources/LavaUI/Alignment.swift:57

static let leading: Alignment

Centred along the left edge.

Sources/LavaUI/Alignment.swift:74

static let top: Alignment

Centred along the top edge.

Sources/LavaUI/Alignment.swift:70

static let topLeading: Alignment

The top-left corner.

Sources/LavaUI/Alignment.swift:68

static let topTrailing: Alignment

The top-right corner.

Sources/LavaUI/Alignment.swift:72

static let trailing: Alignment

Centred along the right edge.

Sources/LavaUI/Alignment.swift:78

var vertical: VerticalAlignment

Placement along the vertical axis.

Sources/LavaUI/Alignment.swift:59