Wojciech Rozwadowski
03/08/2023, 9:01 AMlistOfSomething: List<Something>
1️⃣
Scaffold(
...
} { contentPadding ->
LazyColumn(
contentPadding = contentPadding,
) {
items(listOfSomething) { something ->
SomeItem(something)
}
item {
Spacer(Modifier.height(24.dp))
}
}
)
2️⃣
Scaffold(
...
} { contentPadding ->
LazyColumn(
contentPadding = contentPadding + PaddingValues(bottom = 24.dp),
) {
items(listOfSomething) { something ->
SomeItem(something)
}
}
}
PaddingValues
extension:
operator fun PaddingValues.plus(other: PaddingValues) = PaddingValues(
start = this.start + other.start,
top = <http://this.top|this.top> + <http://other.top|other.top>,
end = this.end + other.end,
bottom = this.bottom + other.bottom,
)
private val PaddingValues.start get() = calculateStartPadding(LayoutDirection.Ltr)
private val <http://PaddingValues.top|PaddingValues.top> get() = calculateTopPadding()
private val PaddingValues.end get() = calculateEndPadding(LayoutDirection.Ltr)
private val PaddingValues.bottom get() = calculateBottomPadding()
PaddingValues
extension will be useful with globally defined paddings like
val ScrollableContentPaddingVertical = PaddingValues(vertical = 24.dp)
Then we could use simple
contentPadding = contentPadding + ScrollableContentPaddingVertical
in place of top and bottom spacers