Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Navigation] Add mechanism for specifying zOrder in transitions #1001

Closed
hvisser opened this issue Feb 8, 2022 · 20 comments
Closed

[Navigation] Add mechanism for specifying zOrder in transitions #1001

hvisser opened this issue Feb 8, 2022 · 20 comments
Assignees
Labels
stale Stale issues which are marked for closure

Comments

@hvisser
Copy link

hvisser commented Feb 8, 2022

Description
AnimatedContent supports setting a z-order on the transitions which can be useful for navigation transitions. For example when trying to implement a "slide from bottom" transition, the enter transition slides over the exiting composable (good) but the reverse will slide the exiting (popping) composable under the entering composable. If specifying the z-order could help to explicitly set the desired order for the composables.

@ianhanniballake
Copy link
Collaborator

How would you expect z-order to be exposed? As a property on each composable destination? Something else?

@hvisser
Copy link
Author

hvisser commented Feb 9, 2022

I think exposing it (somehow) on the definition of the transition would make sense. In the context of the transition (initial and target) I'd know what ordering I want...That might mean the transition block is no longer an AnimatedContentScope but an extension of it maybe?

@jbw0033 jbw0033 assigned jbw0033 and unassigned jbw0033 Feb 15, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label Mar 18, 2022
@ianhanniballake ianhanniballake removed the stale Stale issues which are marked for closure label Mar 18, 2022
@mvarnagiris
Copy link

I have the same issue. Having it inside transition definition would work I suppose.

Having it for each composable destination wouldn't work. If we take @hvisser example of "slide from bottom"

  • A -> B. B on top of A
  • A, B -> C. C on top of B
  • A, B <- C. C on top B
  • A <- B. B on top of A

@joshrvezy
Copy link

any idea if this is something being worked on. it would be great to have.

@vadimpikha
Copy link

I think targetContentZIndex should somehow depend on screen index in backstack

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label May 15, 2022
@ianhanniballake ianhanniballake removed the stale Stale issues which are marked for closure label May 15, 2022
@SergKlimov
Copy link

SergKlimov commented May 27, 2022

Same issue for me, I just copied AnimatedNavHost and modified like this

val zIndex = visibleBackStack.indexOf(backStackEntry).toFloat()

And then changed AnimatedContent

transitionSpec = { finalEnter(this) with finalExit(this) },
to

transitionSpec = { 
ContentTransform(
   targetContentEnter = finalEnter(this),
   initialContentExit = finalExit(this),
   targetContentZIndex = zIndex,
},

@x4080
Copy link

x4080 commented Jun 25, 2022

@SergKlimov Thats cool solution, but sadly, I tried to copy the AnimatedNavHost.kt content to my local package and it wont even compile :)

Can you give tip how you do it ?

Thanks

@x4080
Copy link

x4080 commented Jun 25, 2022

@SergKlimov Never mind, we must also copy file AnimatedComposeNavigator

Edit : I cant find visibleBackStack variable, is your AnimatedNavHost have that variable ?
Edit2 : Just copying (without modifying anything), make screen blank, dont know what's going on now :)
Edit3 : I got success by copying all the files from accompanist navigation, but still cannot find the variable visibleBackStack

@codingfd
Copy link

codingfd commented Jul 5, 2022

@x4080 #1160

transition.AnimatedContent(modifier, transitionSpec = {
            val targetIndex = navController.backQueue.indexOf(targetState).takeIf { it >= 0 }
                ?: navController.backQueue.size
            ContentTransform(
                targetContentEnter = finalEnter(this),
                initialContentExit = finalExit(this),
                targetContentZIndex = targetIndex.toFloat()
            )
        }

@x4080
Copy link

x4080 commented Jul 16, 2022

@codingfd thanks

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label Aug 16, 2022
@ianhanniballake ianhanniballake removed the stale Stale issues which are marked for closure label Aug 16, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label Sep 15, 2022
@ianhanniballake ianhanniballake removed the stale Stale issues which are marked for closure label Sep 19, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label Oct 20, 2022
@ianhanniballake ianhanniballake removed the stale Stale issues which are marked for closure label Oct 20, 2022
@hvisser
Copy link
Author

hvisser commented Oct 20, 2022

Maybe it's time to get rid of stale bot?

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale Stale issues which are marked for closure label Nov 20, 2022
@ianhanniballake
Copy link
Collaborator

We've added what we believe is the correct z-ordering in #1384, released as part of v0.27.1 and aren't planning on offering any ability to override it at this time. Please upgrade and try it out!

@ommiao
Copy link

ommiao commented Dec 17, 2022

We've added what we believe is the correct z-ordering in #1384, released as part of v0.27.1 and aren't planning on offering any ability to override it at this time. Please upgrade and try it out!

Hey @ianhanniballake , I had a try but it's not good. I tried the navigation route: A -> B -> C -> B -> A, when the screen transition running from B -> A, the zIndex looks not good. Could you have a try?

@ianhanniballake
Copy link
Collaborator

Sounds like #1411, please follow along there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues which are marked for closure
Projects
None yet
Development

No branches or pull requests

10 participants