Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ilyasshafigin
Copy link
Contributor

@ilyasshafigin ilyasshafigin commented Feb 14, 2023

Description

If using custom transition with keyTransition, then returning to previous screen occurred with wrong animation.

For example, there is screen A, B, C. Screens A and C open with a default transition. Screen B with a custom transition.
Open screens A -> B -> C. In this case all screens will display with a correct transition.
Now, if you go back to screen B, the transition from C to B will be with a custom animation, while it should be with a default transition, because screen C opened with default.

For example, I added DetailsCustomTransitionKey with VerticalSlideTransition.

Screen record
device-2023-02-14-140606.mp4

Solution

Fixed function Navigator.getTransition.
If there is a pop to previous screen, then take the transition for previousEntry.

Screen record
device-2023-02-14-140612.mp4

@roudikk roudikk self-assigned this Feb 14, 2023
# Conflicts:
#	guia/src/test/java/com/roudikk/guia/NavigatorTest.kt
@roudikk
Copy link
Owner

roudikk commented Feb 17, 2023

Thanks for the PR ! I actually was working on a fix at b11a085. Basically, we should be running the logic in the when statement for the previous and new entry. To make sure both can have a fallback. Do you mind merging master to your branch and making sure that the custom key you added in the sample app still behaves as you expect?

# Conflicts:
#	guia/src/main/java/com/roudikk/guia/core/Navigator.kt
#	guia/src/test/java/com/roudikk/guia/NavigatorTest.kt
@ilyasshafigin
Copy link
Contributor Author

I merged your commit to my branch. Behavior is not as expected. Even the forward transition is not the same as before.
You have the transition associated with only one screen. I think the transition is defined between the current screen and the next screen, they have a similar animation. You have a combination of two different animations

Screen record
screen-20230217-112219.mp4

@roudikk
Copy link
Owner

roudikk commented Feb 17, 2023

I merged your commit to my branch. Behavior is not as expected. Even the forward transition is not the same as before. You have the transition associated with only one screen. I think the transition is defined between the current screen and the next screen, they have a similar animation. You have a combination of two different animations

Screen record

I think your recording here is showing the proper transitions.

I gave this article a read:
https://medium.com/androiddevelopers/animations-in-navigation-compose-36d48870776b

image

So my understanding is the following:

  • Details Screen plays its exit transition (Slide left + fade out) then custom key screen plays its enter (Slide in up)
  • When you pop, the custom key will play its slide out while the details screen will play its slide in animation

That's basically what I understood when going through the fragment transition doc and the accompanist animation library for NavHost.

If I'm mistaken please let me know, it's actually quite confusing trying to understand.

@ilyasshafigin
Copy link
Contributor Author

I'm confused too.
I think a navigation library has different approaches.
You want to use the same approach as the accompanist animation library, but there is a different API.
Let's say we use your approach. Can you please tell me how to achieve the same animation as here with keyTransition/nodeTransition?

Sample
device-2023-02-14-140612.mp4

@roudikk
Copy link
Owner

roudikk commented Feb 18, 2023

That's actually a good point. I'm actually doing some research now and trying out different use cases to see what fits better in Guia.

@roudikk
Copy link
Owner

roudikk commented Feb 23, 2023

Alright, I think for Guia it makes more sense the previous/your approach. Let's go with your changes! Fix conflicts and let's get this PR in. Thank you!

@roudikk roudikk merged commit c0e682a into roudikk:master Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants