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

onBackPress returns on the unexpected page #7

Open
YakubenkoAndrii opened this issue Sep 27, 2022 · 1 comment
Open

onBackPress returns on the unexpected page #7

YakubenkoAndrii opened this issue Sep 27, 2022 · 1 comment

Comments

@YakubenkoAndrii
Copy link

Context:

  • after first launch the user passes through Onboarding to MainPage
  • by onBackPress on MainPage user returns to Onboarding

Issue:

this part of code working only for the next launches after first
NavHost( navController = navController, startDestination = if(shouldShowOnboarding) { Route.WELCOME } else Route.TRACKER_OVERVIEW )

Step to reproduce:

  • branches: master / Part25/ImproovingNavigation+BugFix
  • fully delete app from device
  • install app
  • pass onboarding
  • call onBackPress on the main page
@cbarrios
Copy link

cbarrios commented Oct 11, 2022

Hi @YakubenkoAndrii,

This can be fixed by implementing the following inside the TrackerOverviewScreen.kt file (you must have a lambda to navigate up). Please put this at the beginning of the body:

BackHandler {
onNavigateUp()
}

...then on MainActivity on your TrackerOverviewScreen composable inside your NavHost:
onNavigateUp = { finish() }

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

No branches or pull requests

2 participants