loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / COLLECTIONS AND INTERACTION

List

A selectable, scrollable collection with custom row rendering and shared hit-test geometry.

Sorting/filtering belong to the caller. Pass stable, unique IDs for selection to survive reordering. Only visible rows are rendered. Row heights are explicit by default; automatic measurement is opt-in.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

var list = List([ListItem(id: "a", "First"), ListItem(id: "b", "Second")])
list.automaticHeights = true
var state = SelectionState(selectedID: "a")
var frame = Frame(width: 30, height: 6)
frame.render(list, in: frame.area, state: &state)
Members on this page

Feature guides and release status

List

Structure
struct List<ID> where ID : Hashable

Conforms to: StatefulWidget.

A selectable, scrollable collection with custom row rendering and shared hit-test geometry.

Sorting/filtering belong to the caller. Pass stable, unique IDs for selection to survive reordering. Only visible rows are rendered. Row heights are explicit by default; automatic measurement is opt-in.

Source · List.swift:41

items

Instance Property
var items: [ListItem<ID>]

The menu’s choices in display order.

Source · List.swift:42

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · List.swift:43

selectionStyle

Instance Property
var selectionStyle: Style

Style used for the selected choice/icon.

Source · List.swift:44

markedStyle

Instance Property
var markedStyle: Style

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:45

selectionSymbol

Instance Property
var selectionSymbol: String

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:46

prefixReservation

Instance Property
var prefixReservation: SelectionPrefixReservation

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:47

selectionPatch

Instance Property
var selectionPatch: StylePatch?

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:48

markedPatch

Instance Property
var markedPatch: StylePatch?

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:49

emptyMessage

Instance Property
var emptyMessage: String

Text shown when the popup has no items.

Source · List.swift:50

alignment

Instance Property
var alignment: CellAlignment

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:51

reversed

Instance Property
var reversed: Bool

Places the first item at the bottom; navigation follows screen direction.

Source · List.swift:53

automaticHeights

Instance Property
var automaticHeights: Bool

Measures default text at its final content width when enabled.

Source · List.swift:55

wrapping

Instance Property
var wrapping: TextWrapping

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:56

wrapOptions

Instance Property
var wrapOptions: TextWrapOptions

A public field of this type. Its value type and mutability are shown in the declaration.

Source · List.swift:57

measureRow

Instance Property
var measureRow: ((ListItem<ID>, Int) -> Int)?

Required to measure custom row rendering; width excludes the selection prefix.

Source · List.swift:59

renderRow

Instance Property
var renderRow: ((ListItem<ID>, ListRowAppearance, Rect, inout Buffer) -> Void)?

Optional custom drawing, clipped to the row and viewport.

Coordinates remain absolute.

Source · List.swift:64

init(_:)

Initializer
init(_ items: [ListItem<ID>])

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (1)
items
Choices in display order.
Source · List.swift:66

update(in:state:)

Instance Method
func update(in area: Rect, state: inout SelectionState<ID>)

Synchronizes data/geometry before event dispatch.

Rendering also calls this method.

Parameters (2)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
state
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · List.swift:73

render(in:buffer:state:)

Instance Method
func render(in area: Rect, buffer: inout Buffer, state: inout SelectionState<ID>)

Reconciles the caller-owned selection metrics and paints visible rows using the same geometry as hit testing.

Parameters (3)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
state
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · List.swift:86

item(at:in:state:)

Instance Method
func item(at point: Point, in area: Rect, state: SelectionState<ID>) -> ID?

Call after update/draw with the same items and area.

Padding below the last item returns nil.

Parameters (3)
at
Argument type and any default are shown in the declaration; see the behavior notes above.
in
Argument type and any default are shown in the declaration; see the behavior notes above.
state
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns ID?.

Source · List.swift:146