diff --git a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressProvider.kt b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressProvider.kt index 1f8f4f8eb3..11fb6924e5 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressProvider.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressProvider.kt @@ -39,6 +39,7 @@ fun ExpressProvider( val hapticFeedback = LocalHapticFeedback.current val context = LocalContext.current Column( + verticalArrangement = Arrangement.spacedBy(2.dp), modifier = Modifier .clip(TangemTheme.shapes.roundedCornersXMedium) .background(TangemTheme.colors.background.action), diff --git a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressStatusBlock.kt b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressStatusBlock.kt index d31f527a9d..ad3c3c1c94 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressStatusBlock.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/ExpressStatusBlock.kt @@ -19,16 +19,16 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import com.tangem.common.ui.R import com.tangem.common.ui.expressStatus.state.ExpressLinkUM import com.tangem.common.ui.expressStatus.state.ExpressStatusItemState import com.tangem.common.ui.expressStatus.state.ExpressStatusItemUM import com.tangem.common.ui.expressStatus.state.ExpressStatusUM import com.tangem.core.ui.components.SpacerWMax -import com.tangem.core.ui.extensions.resolveReference -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.extensions.stringReference +import com.tangem.core.ui.extensions.* import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import kotlinx.collections.immutable.persistentListOf @@ -53,6 +53,7 @@ fun ExpressStatusBlock(state: ExpressStatusUM, modifier: Modifier = Modifier) { ) { Row( verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier .padding(bottom = TangemTheme.dimens.spacing16), ) { @@ -77,8 +78,14 @@ fun ExpressStatusBlock(state: ExpressStatusUM, modifier: Modifier = Modifier) { .padding(end = TangemTheme.dimens.spacing2), ) Text( - text = link.text.resolveReference(), - style = TangemTheme.typography.body2, + modifier = Modifier.align(Alignment.CenterVertically), + text = resourceReference( + id = R.string.express_transaction_id, + formatArgs = wrappedList(link.text), + ).resolveReference(), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + style = TangemTheme.typography.subtitle2, color = TangemTheme.colors.text.tertiary, ) } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt index df498f267a..03201dcd0a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import androidx.compose.ui.unit.dp import com.tangem.core.ui.R import com.tangem.core.ui.components.SpacerWMax import com.tangem.core.ui.components.inputrow.inner.DividerContainer @@ -76,7 +77,7 @@ fun InputRowBestRate( text = subtitle.resolveReference(), style = TangemTheme.typography.body2, color = TangemTheme.colors.text.tertiary, - modifier = Modifier.padding(top = TangemTheme.dimens.spacing8), + modifier = Modifier.padding(top = 2.dp), ) } SpacerWMax() diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/DefaultOnrampRedirectComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/DefaultOnrampRedirectComponent.kt index 17904c58e6..3f0059348b 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/DefaultOnrampRedirectComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/DefaultOnrampRedirectComponent.kt @@ -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) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/model/OnrampRedirectModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/model/OnrampRedirectModel.kt index c9a11d1cb5..ce08252b7b 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/model/OnrampRedirectModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/redirect/model/OnrampRedirectModel.kt @@ -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() } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt index 93ae9d4370..06644ff6e6 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt @@ -219,7 +219,11 @@ internal class TokenDetailsOnrampTransactionStateConverter( resourceReference(R.string.express_status_bought, wrappedList(cryptoCurrency.name)) } }, - state = getStatusState(OnrampStatus.Status.Paid), + state = when { + this == OnrampStatus.Status.RefundInProgress || + this == OnrampStatus.Status.Refunded -> ExpressStatusItemState.Error + else -> getStatusState(OnrampStatus.Status.Paid) + }, ) private fun OnrampStatus.Status.getSendingItem() = ExpressStatusItemUM( @@ -251,7 +255,7 @@ internal class TokenDetailsOnrampTransactionStateConverter( }, state = when { this == OnrampStatus.Status.RefundInProgress -> ExpressStatusItemState.Active - this == OnrampStatus.Status.Refunded -> ExpressStatusItemState.Error + this == OnrampStatus.Status.Refunded -> ExpressStatusItemState.Done else -> getStatusState(OnrampStatus.Status.Sending) }, ) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt index 780910ba7b..8e57128ffa 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt @@ -24,10 +24,10 @@ import com.tangem.feature.swap.domain.models.domain.ExchangeStatus.Companion.isF import com.tangem.feature.swap.domain.models.domain.ExchangeStatusModel import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionListModel import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionModel +import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotification import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeStatusState import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeUM -import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents import com.tangem.features.tokendetails.impl.R import com.tangem.utils.Provider import com.tangem.utils.converter.Converter @@ -131,7 +131,10 @@ internal class TokenDetailsSwapTransactionsStateConverter( notification = notification, statuses = getStatuses(statusModel.status, hasFailed), showProviderLink = showProviderLink, - info = tx.info.copy(txExternalUrl = statusModel.txExternalUrl), + info = tx.info.copy( + txExternalId = statusModel.txExternalId, + txExternalUrl = statusModel.txExternalUrl, + ), ) } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/OnrampStatusFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/OnrampStatusFactory.kt index 9ba8330394..76ca1a1052 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/OnrampStatusFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/OnrampStatusFactory.kt @@ -14,8 +14,8 @@ import com.tangem.domain.onramp.model.OnrampStatus.Status.* import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.analytics.TokenOnrampAnalyticsEvent -import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents import com.tangem.domain.wallets.models.UserWallet +import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.TokenDetailsOnrampTransactionStateConverter import com.tangem.utils.Provider @@ -89,7 +89,13 @@ internal class OnrampStatusFactory @AssistedInject constructor( }, ifRight = { statusModel -> sendStatusUpdateAnalytics(onrampTx, statusModel) - onrampTx.copy(activeStatus = statusModel.status) + onrampTx.copy( + activeStatus = statusModel.status, + info = onrampTx.info.copy( + txExternalId = statusModel.externalTxId, + txExternalUrl = statusModel.externalTxUrl, + ), + ) }, ) }