Updated on 2026-08-14
This commit is contained in:
parent
87c43ab20f
commit
efd439d0ce
7 changed files with 29 additions and 10 deletions
|
|
@ -54,12 +54,12 @@ fun FragmentActivity.openFragment(
|
|||
if (screen.isDialogFragment) {
|
||||
(fragment as DialogFragment).show(transaction, screen.name)
|
||||
if (addToBackstack) {
|
||||
transaction.addToBackStack(null)
|
||||
transaction.addToBackStack(screen.name)
|
||||
}
|
||||
} else {
|
||||
transaction.replace(R.id.fragment_container, fragment, screen.name)
|
||||
if (addToBackstack && (screen != AppScreen.Home && screen != AppScreen.Welcome)) {
|
||||
transaction.addToBackStack(null)
|
||||
if (addToBackstack) {
|
||||
transaction.addToBackStack(screen.name)
|
||||
}
|
||||
transaction.commitAllowingStateLoss()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ sealed class NavigationAction : Action {
|
|||
val addToBackstack: Boolean = true,
|
||||
) : NavigationAction()
|
||||
|
||||
data class PopBackTo(val screen: AppScreen? = null) : NavigationAction()
|
||||
data class PopBackTo(
|
||||
val screen: AppScreen? = null,
|
||||
val inclusive: Boolean = false,
|
||||
) : NavigationAction()
|
||||
|
||||
data class OpenUrl(val url: String) : NavigationAction()
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ val navigationMiddleware: Middleware<AppState> = { _, state ->
|
|||
AppScreen.Home,
|
||||
AppScreen.Welcome,
|
||||
-> {
|
||||
navState?.activity?.get()?.popBackTo(screen = null, inclusive = true)
|
||||
navState?.activity?.get()?.popBackTo(screen, action.inclusive)
|
||||
if (navState?.backStack?.contains(screen) != true) {
|
||||
store.dispatchOnMain(NavigationAction.NavigateTo(screen))
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
navState?.activity?.get()?.popBackTo(screen = action.screen)
|
||||
navState?.activity?.get()?.popBackTo(screen, action.inclusive)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue