Coder Social home page Coder Social logo

minabox's Introduction

Maven Central

Mina Box

Lazy box library for Jetpack Compose.

Mina box allows to display lazy loaded items on the 2D plane. It is build on the LazyLayout and provides methods to register item(s) and handles scrolling on the plane.

Mina?

Maybe you are asking yourself why library has such a strange name? It is named after our family cat "Mina", and she is too damn lazy and likes to sit in the boxes, thus I think it matches perfectly this layout's purpose.

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()
        maven { url "https://jitpack.io" }
    }
}

Or in settings.gradle:

pluginManagement {
    repositories {
        ...
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency. Check latest version on the releases page.

dependencies {
    implementation 'io.github.camapblue:minabox:$version'
}

Use in Composable

The core element of the MinaBox 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 could be locked horizontally or vertically to create pinned rows and / or columns of data. The item size could be defined absolutely (in pixels) or relatively to parent size.

val columns = 10
val rows = 10
val width = 128f // pixels
val height = 64f // pixels
MinaBox {
    items(
        count = columns * rows,
        layoutInfo = {
            MinaBoxItem(
                x = width * (it % columns),
                y = height * (it / columns),
                width = width,
                height = height,
            )
        }
    ) { index ->
        Text(text = "#$index")
    }
}

See Demo application and examples for more usage examples.

More usages

There are two libraries which are build on top of the Mina Box layout:

  • LazyTable - displays columns and rows of data on the two directional plane.
  • ProgramGuide - displays program guide data on the two directional plane.

Make sure to check them for tip & tricks if you want to build your own implementation.

Examples

Simple table with items aligned in columns and rows.

simple.mp4

⬡ Fancy hexagons ⬡.

hexagons.mp4

Lazy table with pinned columns & rows, check LazyTable library.

lazytable.mp4

Program Guide (aka EPG), check ProgramGuide library.

programguide.mp4

minabox's People

Contributors

oleksandrbalan avatar joshafeinberg avatar daole-ptc avatar tgo1014 avatar

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.