Git Product home page Git Product logo

architect's Introduction

Architect

A small code generating library, that generates boilerplate code for defining your Navigation Graph, setting up TopAppBar, and BottomNavigation in Jetpack Compose.

Features

  • Removes code duplication when describing your routes through out the application.
  • Removes code for setting up bottom and top navigation.

Setup

in your project level build.gradle

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}	
}

And then in you app level build.gradle

dependencies { 
  // KSP processor
  ksp("com.github.nicholasmata.architect:compiler:1.0.0-alpha")

  implementation("com.github.nicholasmata.architect:annotations:1.0.0-alpha")
  implementation("com.github.nicholasmata.architect:core:1.0.0-alpha")
}

applicationVariants.all { variant ->
    kotlin.sourceSets {
        getByName(variant.name) {
            kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
        }
    }
}

Basic Usage

At the core of the Architect there is a @Route annotation. This annotation is used to describe your composable destination. Here is the basic setup for the Profile Screen

@Route(route = "profile", title = "Profile")
@Composable
fun ProfileScreen() {
    /** your screen */
}

After you build the project, Architect will generate multiple files based on the @Route annotations. These files now fully describe your Routes and can be used to describe you navigation graph easier and to navigate from one Route to another, and setup Tab bar.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Architect(
                tabs = Tab.values().toList(),
                screenGraph = ScreenGraph()
            )
        }
    }
}

enum class Tab(
    override val id: String,
    override val title: String,
    override val start: ArchitectScreen,
    override val icon: ImageVector,
    override var navState: Bundle = Bundle()
) : ArchitectTab {
    Profile(id = "profile", title = "Profile", start = Screen.Profile, icon = Icons.Default.Person)
}

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.