Skip to content

Compose Navigator Tutorials

Kaustubh Patange edited this page Jun 13, 2021 · 20 revisions

These are small tutorials that covers some specific implementation detail.

Table of contents

Navigating with animation

Navigator provides some custom enter (FadeIn, SlideInRight, SlideInLeft, ShrinkIn) & exit (FadeOut, SlideOutRight, SlideOutLeft, ShrinkOut) animation.

controller.navigateTo(dest) {
    withAnimation {
        enter = EnterAnimation.FadeIn
        exit = ExitAnimation.FadeOut
    }
}

On back press/back navigation these enter, exit animation will be played in reversed order. These information is also preserved accross configuration & process death.

Navigate with single top instance & popUpTo

controller.navigateTo(dest) {
    singleTop = true // makes sure that there is only one instance of this destination in backstack.
}
controller.navigateTo(dest) {
    popUpTo(dest) { // recursivly pops the backstack till the destination.
        inclusive = true // inclusive
        all = false // last added one will be chosen.
    }
}
Clone this wiki locally