-
Notifications
You must be signed in to change notification settings - Fork 662
Use NavigationManager in LinkActivity #10329
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
base: master
Are you sure you want to change the base?
Conversation
) | ||
) | ||
} | ||
navigationManager.tryNavigateBack() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goBack
will go away in favor of specific screens using NavigationManager
.
fun linkScreenCreated() { | ||
viewModelScope.launch { | ||
val currentRoute = navController?.currentBackStackEntry?.destination?.route | ||
if (currentRoute == null || currentRoute == LinkScreen.Loading.route) { | ||
navigateToLinkScreen() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed anymore:UI does not need to signal component rendering to trigger loading. Instead, we'll wait to render the component until we have the necessary info loaded.
private suspend fun buildFullScreenState(): ScreenState.FullScreen { | ||
val accountStatus = linkAccountManager.accountStatus.first() | ||
val screen = when (accountStatus) { | ||
AccountStatus.Verified -> { | ||
LinkScreen.Wallet | ||
} | ||
AccountStatus.NeedsVerification, AccountStatus.VerificationStarted -> { | ||
LinkScreen.Verification | ||
} | ||
AccountStatus.SignedOut, AccountStatus.Error -> { | ||
LinkScreen.SignUp | ||
return ScreenState.FullScreen( | ||
initialDestination = when (accountStatus) { | ||
AccountStatus.Verified -> { | ||
LinkScreen.Wallet | ||
} | ||
AccountStatus.NeedsVerification, AccountStatus.VerificationStarted -> { | ||
LinkScreen.Verification | ||
} | ||
AccountStatus.SignedOut, AccountStatus.Error -> { | ||
LinkScreen.SignUp | ||
} | ||
} | ||
} | ||
navigate(screen, clearStack = true, launchSingleTop = true) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial step to consolidate state build logic into ScreenState
.
Diffuse output:
APK
|
064d2dc
to
1578ea5
Compare
36cda1b
to
b6aaa1f
Compare
LaunchedEffect(Unit) { | ||
onNavControllerCreated(navController) | ||
onLinkScreenScreenCreated() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compose does not need to signal the VM to initiate rendering anymore - instead the state has the initialDestination
bundled.
PopUpToBehavior.Start -> popUpTo( | ||
navHostController.graph.startDestinationId | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added clear stack navigation support!
…gation-manager # Conflicts: # paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt # paymentsheet/src/main/java/com/stripe/android/link/ui/FullScreenContent.kt # paymentsheet/src/main/java/com/stripe/android/link/ui/LinkContent.kt
…gation-manager # Conflicts: # paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt
Summary
NavigationManager
to handle navigation ((flow based navigation communication via a DI shared instance).navController
<>viewModel
couplingMotivation
Testing
Screenshots
Changelog