Giter VIP home page Giter VIP logo

scrollabletable's Introduction

Maven Central

Lazy Table

Lazy table library for Compose UI.

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.

Multiplatform

Library supports Android, iOS and Desktop (Windows, MacOS, Linux) targets.

Usage

Get a dependency

Step 1. Add the MavenCentral repository to your build file. Add it in your root build.gradle.kts at the end of repositories:

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

Or in settings.gradle.kts:

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.