Lazy Table
Lazy table library for Jetpack Compose.
Lazy table allows to display columns and rows of data on the two directional plane. It is build on the MinaBox (which is build on LazyLayout
) and provides methods to register item(s) and handles scrolling on the plane.
Usage
Get a dependency
Step 1. Add the MavenCentral repository to your build file. Add it in your root build.gradle
at the end of repositories:
allprojects {
repositories {
...
mavenCentral()
}
}
Or in settings.gradle
:
pluginManagement {
repositories {
...
mavenCentral()
}
}
Step 2. Add the dependency. Check latest version on the releases page.
dependencies {
implementation 'io.github.oleksandrbalan:lazytable:$version'
}
Use in Composable
The core element of the LazyTable
layout is a content
lambda, where items are registered in the similar manner as in LazyColumn
or LazyRow
. The main difference is that each item must provide its position and size in the layoutInfo
lambda. Each item defines its position by specifying the column
and row
and size by specifying how much columns or rows it occupies (by default is set to 1).
The size of the cells are defined via dimensions
parameter. There are multiple lazyTableDimensions
methods which creates the dimensions for all or each column / row.
Lazy table also allows to specify how many columns / rows should be pinned and thus be visible when user navigates in the table. Check the pinConfiguration
parameter.
It is also possible to observe on the scroll state and change it programmatically using an instance of the LazyTableState
.
val columns = 10 val rows = 10 LazyTable( dimensions = lazyTableDimensions(48.dp, 32.dp) ) { items( count = columns * rows, layoutInfo = { LazyTableItem( column = it % columns, row = it / columns, ) } ) { index -> Text(text = "#$index") } }
See Demo application and examples for more usage examples.
Examples
Simple table with items.
simple.mp4
Advanced example with pinned columns and rows.
advanced.mp4
If you need further customization options, check MinaBox library.