![](https://private-user-images.githubusercontent.com/20944869/240820634-616a3df3-d83a-4e2f-896a-b6be6cb98a29.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM5MjExNDIsIm5iZiI6MTcyMzkyMDg0MiwicGF0aCI6Ii8yMDk0NDg2OS8yNDA4MjA2MzQtNjE2YTNkZjMtZDgzYS00ZTJmLTg5NmEtYjZiZTZjYjk4YTI5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDE4NTQwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3YjkwYTI3ZDMxMGUyNGRlZTRiN2U4MGViZDY5MDM2YWQ5M2RlMDc5ZGQ2ZmMzMTVjZDRmM2U2NmNjY2M5ZGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.mDCOv-rpR0M-KOKHOVX2G2gIIiE0b5LaJMWFghnIFvo)
Lazy box library for Compose UI.
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.
Library supports Android, iOS, Desktop (Windows, MacOS, Linux) and Wasm targets.
![](https://private-user-images.githubusercontent.com/20944869/240820796-7af845f2-617f-4edb-bf34-9a12335f963d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM5MjExNDIsIm5iZiI6MTcyMzkyMDg0MiwicGF0aCI6Ii8yMDk0NDg2OS8yNDA4MjA3OTYtN2FmODQ1ZjItNjE3Zi00ZWRiLWJmMzQtOWExMjMzNWY5NjNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDE4NTQwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjODJlMDVhZGNiZDgwNWZhOWU2ZDg4Njk5MWVkYmMzNjdmODEyNmE3MTJlNjU5NzJhNTZlNGY4YjBhYTUyOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0EBFc4jaowJrR5mHIGoGmYrOnBp7buAm5aQ902r_dDM)
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.
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
:
dependencyResolutionManagement {
repositories {
...
mavenCentral()
}
}
Step 2. Add the dependency. Check latest version on the releases page.
dependencies {
implementation("io.github.oleksandrbalan:minabox:$version")
}
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.
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.
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.