Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-06 18:13:02 +05:00
parent f4a778a9be
commit 6394f7b84f
2 changed files with 20 additions and 1 deletions

View file

@ -5,21 +5,38 @@ import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import com.arkivanov.essenty.lifecycle.subscribe
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.model.getOrCreateModel
import com.tangem.features.onramp.redirect.model.OnrampRedirectModel
import com.tangem.features.onramp.redirect.ui.OnrampRedirectContent
import com.tangem.features.onramp.success.OnrampSuccessScreenTrigger
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.launch
internal class DefaultOnrampRedirectComponent @AssistedInject constructor(
@Assisted appComponentContext: AppComponentContext,
@Assisted private val params: OnrampRedirectComponent.Params,
private val onrampSuccessScreenTrigger: OnrampSuccessScreenTrigger,
) : OnrampRedirectComponent, AppComponentContext by appComponentContext {
private val model: OnrampRedirectModel = getOrCreateModel(params)
init {
lifecycle.subscribe(
onResume = {
// On reopen check if redirect happened. If so trigger close action
if (model.latestOnrampTransaction != null) {
componentScope.launch {
onrampSuccessScreenTrigger.triggerOnrampSuccess(false)
}
}
},
)
}
@Composable
override fun Content(modifier: Modifier) {
BackHandler(onBack = params.onBack)

View file

@ -46,7 +46,7 @@ internal class OnrampRedirectModel @Inject constructor(
private val params: OnrampRedirectComponent.Params = paramsContainer.require()
private val selectedUserWallet = getWalletsUseCase.invokeSync().first { it.walletId == params.userWalletId }
private var latestOnrampTransaction: OnrampTransaction? = null
var latestOnrampTransaction: OnrampTransaction? = null
val state = OnrampRedirectUM(
topBarConfig = OnrampRedirectTopBarUM(
@ -100,10 +100,12 @@ internal class OnrampRedirectModel @Inject constructor(
val replaceOnrampScreens = appRouter.stack
.filterNot { it is AppRoute.Onramp }
.toMutableList()
latestOnrampTransaction = null
replaceOnrampScreens.add(AppRoute.OnrampSuccess(latestTxId))
appRouter.replaceAll(*replaceOnrampScreens.toTypedArray())
} else {
// Close redirect screen and show last onramp state
latestOnrampTransaction = null
params.onBack()
}
}