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

add Navigator.previousEntry #255

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ internal class BackStackManager : LifecycleObserver {
val currentBackStackEntry: Flow<BackStackEntry?>
get() = backStacks.asSharedFlow().map { it.lastOrNull() }

val prevBackStackEntry: Flow<BackStackEntry?>
get() = backStacks.asSharedFlow().map { it.dropLast(1).lastOrNull() }

val canGoBack: Flow<Boolean>
get() = backStacks.asSharedFlow().map { it.size > 1 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ class Navigator {
*/
val currentEntry = stackManager.currentBackStackEntry

/**
* Previous route
* @ return Returns the previous navigation back stack entry.
*/
val previousEntry = stackManager.prevBackStackEntry

/**
* Check if navigator can navigate, it will be false when performing navigation animation.
* @return Returns true if navigator can perform navigation, false otherwise.
Expand Down