oleksandrbalan / lazytable

Lazy layout to display columns and rows of data on the two directional plane.
Apache License 2.0
296 stars 12 forks source link

Allow to change the table's content alignment (or use standard TopStart alignment by default) #23

Open leinardi opened 9 months ago

leinardi commented 9 months ago

Right now a LazyTable will align its content to the its center, resulting in situations similar to this, when there are not items big enough to fill its size.

For example in the following screenshot the LazyTable is using .fillMaxSize().background(Color.Green.copy(alpha = 0.2f)) and the single cell has a fixed width and height, smaller than the size of the table:

image

It would be nice to be able to set the content alignment, in a similar way to what the LazyList offer:

    /** The alignment to align items horizontally */
    horizontalAlignment: Alignment.Horizontal? = null,
    /** The alignment to align items vertically */
    verticalAlignment: Alignment.Vertical? = null,

Alternatively, would it be possible to use the same alignment conventions as the LazyColumn and LazyRow, where the content is always aligned to the top start?

This way it will allow to use the .fillMaxSize(), .fillMaxWidth() and .fillMaxHeight() modifiers without having to be sure that the items inside will actually fill the entire size of the table.

oleksandrbalan commented 9 months ago

Yeap, that defintely could be added.

But even now if you do not use fill modifiers the table will be aligned in the top start corner? Does not this be enough for your case?

leinardi commented 9 months ago

But even now if you do not use fill modifiers the table will be aligned in the top start corner

In most cases this can be worked around by not using the fill modifiers but in some cases you really need to fill the space around the empty items and, if you need to do it both horizontally and vertically, it can be tricky to achieve, while being able to use .fillMaxSize() on the LazyTable would make it trivial.

This enhancement it is also a requirement for addressing #22 (you want to be able to pull to refresh also when the items are not filling the entire space) and #24 (when showing overscroll indicators the table must fill the entire space available).