Giter VIP home page Giter VIP logo

composenavissue's Introduction

This app demonstrates a potential defect with Compose Navigation and animaitons. It's a basic app that includes a "Home Screen" destination and a "Login Screen" destination, and a NavHost to manage navigation between the two destinations. when the app launches it starts on the Home screen, and immediately navigates to the Login screen (and pops the entire backstack), and you can see the (incorrect) animation that is used.

To reproduce the defect:

  1. Build and run the attached app.
  2. Observe the animation of the screens that appear

Expected Result:

The screen animates to the "login screen" destination using the enterTransition defined on the NavHost (the default, fadeIn), or no animation at all.

Actual Result:

The screen animates to the "login screen" destination by "sliding in" diagonally from the bottom right. This is odd because there is no transition defined on the NavHost (or anywhere) that uses a sliding animation.

Screen_recording_20240412_160831.webm

App Architecture

The MyNavHost.kt file defines a NavHost with destinations for the "Home Screen" and the "Login Screen". The "Home Screen" is set as the start destination. It also defines NavController extension methods for navigating to the Home and Login destinations, popping the entire existing backstack when doing so.

The MyApp.kt file has a MyApp composable that is loaded (via the MainActivity) when the app launches. MyApp calls the MyNavHost composable that is discussed above.

The MyApp composable has a MyAppState instance (also defined in the MyApp.kt) and uses a LaunchedEffect to navigate to the "Login Screen" if the user is not logged in (MyAppState.isLoggedIn == false).

This acheives the desired result, demonstrating the defect. When the app launches, it uses the "Home Screen" as the start destination, but because the user is not logged in, it immediately navigates to the "Login Screen" destination, and in doing so, uses the (defective) diagonaly slide-in animation, which is not defined anyhere.

composenavissue's People

Contributors

bradleycorn avatar

Watchers

 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.