Lazy Grid Scope
Declares keyed lazy-grid entries with spans and separated logical and physical ownership.
Typed items declarations evaluate their selectors on every parent declaration pass. Equal item identity and revisions still reuse canonical logical items and their sessions.
Samples
val rows = listOf(RevisionSampleRow(id = 7L, version = 3, label = "Ready"))
val compact = true
val list = buildVNodeTree {
LazyColumn(
items = rows,
key = RevisionSampleRow::id,
contentType = { "status-row" },
// Ordinary captures that affect item content also belong in its semantic revision.
contentRevision = { row -> row.version to compact },
) { row ->
Text(if (compact) row.label else "Status: ${row.label}")
}
}.single()
val item = (list.spec as LazyColumnNodeProps).items.single()
check(item.key == 7L)
check(item.contentType == "status-row")
check(item.contentRevision == (3 to true))
val topLevelVariants = buildVNodeTree {
LazyRow(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
LazyVerticalGrid(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
LazyColumn {
items(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
}
LazyVerticalGrid {
items(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
}
}
val nestedCollections = buildVNodeTree {
PullToRefresh(isRefreshing = false, onRefresh = {}) {
LazyColumn(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
}
PullToRefresh(isRefreshing = false, onRefresh = {}) {
LazyRow(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
}
PullToRefresh(isRefreshing = false, onRefresh = {}) {
LazyVerticalGrid(
items = rows,
key = RevisionSampleRow::id,
contentRevision = RevisionSampleRow::version,
) { row ->
Text(row.label)
}
}
}
check(topLevelVariants.size == 4)
check((nestedCollections[1].children.single().spec as LazyRowNodeProps).items.single().key == 7L)Content copied to clipboard
Functions
Link copied to clipboard
Link copied to clipboard
fun stickyHeader(key: Any, contentRevision: Any, contentType: Any? = null, content: UiTreeBuilder.() -> Unit)
Adds one independently versioned sticky header spanning the full grid row.