Skip to content

Using onBack() pattern on a Component with multiple stacks. #506

Answered by arkivanov
YektaDev asked this question in Q&A
Discussion options

You must be logged in to vote

Now the idea is intercepting the back button for stacks in a way that also allows enabling the predictive back gesture.

I think it's not really possible to control multiple stacks by the predictive back gesture at the same time. If your component has more than one stack, then the predictive back gesture can only control only one of them. You write as follows.

@Composable
fun RootContent(component: RootComponent) {
    Children(
        stack = rootComponent.childStack,
        animation = predictiveBackAnimation(
            backHandler = component.backHandler,
            animation = stackAnimation(fade() + scale()), // Your usual animation here
            onBack = component::onBackCl…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@arkivanov
Comment options

Answer selected by YektaDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants