GithubHelp home page GithubHelp logo

roudikk / guia Goto Github PK

View Code? Open in Web Editor NEW
173.0 2.0 7.0 129.25 MB

Navigation Component for Jetpack Compose with support for screens, dialogs, bottomsheets, transitions and multi module projects

License: Apache License 2.0

Kotlin 100.00%
android android-library kotlin kotlin-android android-navigation navigation-component transition-animation navigation navigator composer

guia's Introduction

Overview

Guia is a Navigation Library for Jetpack Compose.

Check out the documentation on Gitbook.

The motivation behind creating this library is to provide a simple, yet customizable API, for building multi module android navigation system with support for screens, dialogs, bottom sheets or any other representation of a UI.

Guia also has proper android Lifecycle, ViewModel and saved state support.

To get started, check the Setup page.

For a comprehensive guide on how Guia works check The Lore, for a quick start and a small overview check Express Lore.

Screens + BottomNav BottomSheest Dialogs Nested ViewPager + Stack
viewmodel bottomsheet dialogs nested viewpager-stack

Guia ~ [ˈɡia] feminine noun. Means guidance.

guia's People

Contributors

ilyasshafigin avatar roudikk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

guia's Issues

(Unrelated) How to create a simplest navigation

So i'm working on a project where I'm building a compose navigator which gets composables from outside Composable code
For this purpose the implementation is kept simple:

Maintain a list of objects with a @composable Content( ) function and loop over it in a Box composable.
However it's buggy and removing a layer doesn't remove it from UI for some reasons.

I was looking into how other compose navigation libraries do it but none fit the purpose so I was hoping if you could help me improve this implementation

Here's all the code

public class UI {
    private val layers = mutableStateListOf<Layer>()

    @Composable
    public fun drawLayers() {
        remember { layers }.forEach {
            it.draw()
        }
    }

    public fun draw(content: @Composable (Modifier) -> Unit): Layer {
        return Layer(content) {
            layers.remove(it)
        }.also {
            layers.add(it)
        }
    }

    public class Layer(public val content: @Composable (Modifier) -> Unit, internal val onDestroy: (Layer)->Unit) {

        @Composable
        public fun draw() {
            content(Modifier.fillMaxSize())
        }

        public fun destroy() {
            onDestroy(this)
        }
    }
}

I use it like this, I can add multiple layers reacting to app state this way


val ui = UI()

override fun onCreateView(){
    return ComposeView(this).also { setContent { ui.drawLayers() } }
  }
  
 fun onSomethingHappened(){
    val layer = ui.draw{
      // composable content
    }
 }

override fun onDestroy(){
    layer.destroy()
}

Scroll down in the bottomSheet does not work correctly

Hi

I have a problem with the bottomSheet.
Screen record from guia sample app:

screen-20230212-215251.mp4

Velocity of fling is not passed to children list.

I found the problem in this method:

        override suspend fun onPreFling(available: Velocity): Velocity {
            val toFling = Offset(available.x, available.y).toFloat()
            return if (toFling < 0 && offset.value > Float.NEGATIVE_INFINITY) {
                performFling(velocity = toFling)
                // since we go to the anchor with tween settling, consume all for the best UX
                available
            } else {
                Velocity.Zero
            }
        }

If you replace it with this, it will work, but I don't know side effects:

        override suspend fun onPreFling(available: Velocity): Velocity {
            return Velocity.Zero
        }
screen-20230212-220745.mp4

Guia blocks us upgrade compose from 1.4 to 1.5 due to removed AnimatedContentScope

First of all, the library is amazing and it suits our use cases well. My current issue is I am getting this error when I update compose dependencies to 1.5, compiler to 1.4.5. the app is compiling successfully but it crashes saying:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/animation/AnimatedContentScope.
at com.roudikk.guia.containers.ScreenContainerKt$ScreenContainer$2.invoke(ScreenContainer.kt:25)
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.animation.AnimatedContentScope"

as they renamed AnimatedContentScope to AnimatedContentTransitionScope in 1.5.

Can we have an update for compose 1.5?

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.