Updated on 2026-08-14
This commit is contained in:
parent
9315fd5b15
commit
eaa676e9f5
6 changed files with 79 additions and 30 deletions
|
|
@ -24,7 +24,24 @@ internal class SwapRouter(
|
|||
if (currentScreen == SwapNavScreen.SelectToken) {
|
||||
currentScreen = SwapNavScreen.Main
|
||||
} else {
|
||||
router.pop()
|
||||
val selectTokensIndex = router.stack.getSelectTokensRouteIndexOrNull()
|
||||
|
||||
/*
|
||||
* If select token screen is not in stack, then just pop to previous screen.
|
||||
* Otherwise, pop to previous screen that was before select token screen.
|
||||
*/
|
||||
if (selectTokensIndex == null) {
|
||||
router.pop()
|
||||
} else {
|
||||
// find previous screen that was before select token
|
||||
val prevRoute = router.stack.getOrNull(index = selectTokensIndex - 1)
|
||||
|
||||
if (prevRoute != null) {
|
||||
router.popTo(prevRoute)
|
||||
} else {
|
||||
router.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +63,12 @@ internal class SwapRouter(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun List<AppRoute>.getSelectTokensRouteIndexOrNull(): Int? {
|
||||
return this
|
||||
.indexOfFirst { it::class == AppRoute.SwapCrypto::class }
|
||||
.takeIf { it != -1 }
|
||||
}
|
||||
}
|
||||
|
||||
enum class SwapNavScreen {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue