Skip to content

This library is useful for easy and fast building of tree structures (including menus) For any suggestions and comments open new issue

Notifications You must be signed in to change notification settings

lifestreamy/TreeBuilder

Repository files navigation

TreeBuilder

This library is useful for easy and fast building of tree structures (made specifically for menus).

It supports imperative, declarative and mixed ways of building the menus, storing current location in the tree for navigation, cloning the trees, and much more.

Each node has a unique path and can be reached easily.

Usage example

// See GenericMixed in the examples.

val rootL = listOf("a0", "a1", "a2", "a3")

val tree = tree {
            treeName = "Generic Tree"
            root {
                name = "Generic Root"
                attributes = listOf(1, 2, 3) // The type of the tree can be auto-inferred from this list type
            }

            emptyNodes(rootL)
            emptyNode("Empty")
            // will switch context to [Root -> index 0 child node]
            atPath(0) {
                emptyNodes("b0", "b1", "b2")

                // will switch to 0,0
                atRelativePath(0) {
                    emptyNodes("f0", "f1")

                    // will switch to 0,0,1
                    atRelativePath(1) {
                        emptyNodes("j0")
                    }
                    emptyNodes("") 
                }
                emptyNodes("Empty1", "Empty2")
                emptyNode("")
            }
        }

Setup

For now, use Jitpack to add this library (add the code below to build.gradle), check the examples folder for different usage scenarios and explanations.

Link to the library on jitpack

build.gradle:

allprojects {
    repositories{
        maven { url 'https://jitpack.io' }    
    } 
}
dependencies {
    implementation 'com.github.lifestreamy:TreeBuilder:v2.0' 
}

Read the documentation in the code, it should provide all the needed info.

Contribution

Always open for suggestions and contributions.

For any suggestions and comments open new issues

About

This library is useful for easy and fast building of tree structures (including menus) For any suggestions and comments open new issue

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages