PopToView

PopToView action details and its attributes

What is it?

The PopToView action navigates to a screen that was rendered before the current screen, which is on the same stack. For example, if the application displays a screen that is the third screen in a stack, when navigating to the first, the second and third screens will be destroyed.

The structure of PopToView is:

AttributeTypeRequiredDefinition
routeStringRoute of a screen that is on the stack.
navigationContextNavigationContextContext to be saved on the target screen.

How to use it?

To test, we will use three screens:

  1. The first screen will be the home screen and the first in the stack. The endpoint for this screen should be "/firstscreen".
  2. The second screen should have an endpoint as "/secondscreen"
  3. The third should have an endpoint as "/thirdscreen". It is on the third screen that the PopToView action will be triggered. The url listed in the PopToView action should be "/firstscreen"

Below we list the codes to test this action:

Tela inicial

Screen(
    child = Container(
        children = listOf(
            Text(
                "First Screen on Stack"
            ),
            Button(
                text = "Click me!",
                onPress = listOf(
                    Navigate.PushView(
                        Route.Remote(
                            url = "/secondscreen"
                        )
                    )
                )
            )
        )
    )
)

Tela 2

Screen(
    child = Container(
        children = listOf(
            Text(
                "Second Screen on Stack"
            ),
            Button(
                text = "Click me!",
                onPress = listOf(
                    Navigate.PushView(
                        Route.Remote(
                            url = "/thirdscreen"
                        )
                    )
                )
            )
        )
    )
)

Tela 3

Screen(
    child = Container(
        children = listOf(
            Text(
                "Third Screen on Stack"
            ),
            Button(
                text = "Click me to go to first screen",
                onPress = listOf(
                    Navigate.PopToView(
                      route = "/firstscreen"
                    )
                )
            )
        )
    )
)

Last modified March 7, 2022: fix: Update docs 2.0 (#858) (4368557d)