Mark
02/12/2023, 3:57 AMFlowRow
to apply SpaceBetween
on all rows except the last one?
Ideally there would be an extra optional arg:
lastRowHorizontalArrangement: Arrangement.Horizontal = horizontalArrangement,
orangy
02/12/2023, 7:02 AMMark
02/12/2023, 8:25 AMFlowRow
because SpaceBetween
looks pretty terrible when the last row only has a couple of a items and the FlowRow
is rather wide. It should be possible to look like normal justified text.orangy
02/12/2023, 11:22 AMMark
02/12/2023, 12:29 PMSpaceBetween
except for the last row, which would be Start
. I can’t think of too many cases where it would look good to have the last row with one item on each edge with a large space in between. If you wanted to keep symmetry, then Center
would work for the last row.
I suppose this could potentially happen on any row (if next item is very wide), and that’s why we have hyphenation in text. But in most cases, when we are using SpaceBetween
we are doing so with relatively narrow items because we understand this.
Thinking more about this, what you really want is a way for the FlowRow
content to indicate to FlowRow
to start a new row (and at the same time indicate which horizontalArrangement
to apply to that latest row). Analogy here is when there is a line break in text.orangy
02/12/2023, 1:16 PMFlowRow
from accompanist?Mark
02/12/2023, 1:17 PMandroidx.compose.foundation.layout.FlowRow
orangy
02/12/2023, 2:06 PMFlowRow
would be a proper way to fix it. Instead, I’d extend API of Arrangements
.
Thinking out loud, one way to do it would be to introduce Table
(name TBD) interface inside Arrangement
object, that would have an additional function arrange2D
(or just an overload for arrange
) to indicate 2D layouts:
fun Density.arrange2D(
totalSize: Int,
sizes: IntArray,
layoutDirection: LayoutDirection,
outPositions: IntArray,
sliceIndex: Int, // current column/row
totalSlices: Int // total columns/rows
)
That would make it possible for arrangement to decide on first/last/whatever row/column. FlowRow
and related code would do something like arrangement2D = (arrangement as? Table) ?: wrapTable(arrangement)
where wrapTable
would provide Table API and just ignore extra parameters. Then two-dimensional layouts, like `FlowRow`/`FlowColumn`, grids, etc would feed Table arrangement with the current index of row/column and total number of those.jossiwolf
02/13/2023, 6:44 AMMark
02/13/2023, 7:02 AMjossiwolf
02/13/2023, 7:06 AM