Updated on 2026-08-14
This commit is contained in:
parent
934197f787
commit
23a5174a92
6 changed files with 28 additions and 18 deletions
|
|
@ -486,6 +486,8 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
network = currencyToSend.currency.network,
|
||||
)
|
||||
|
||||
val externalUrl = (exchangeData.dataModel.transaction as? ExpressTransactionModel.CEX)?.externalTxUrl
|
||||
|
||||
return result.fold(
|
||||
ifLeft = {
|
||||
when (it) {
|
||||
|
|
@ -519,6 +521,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
currencyToSend.currency.network.backendId,
|
||||
derivationPath,
|
||||
).orEmpty(),
|
||||
txExternalUrl = externalUrl,
|
||||
timestamp = timestamp,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ sealed class TxState {
|
|||
val fromAmount: String? = null,
|
||||
val toAmount: String? = null,
|
||||
val txAddress: String,
|
||||
val txExternalUrl: String? = null,
|
||||
val timestamp: Long,
|
||||
) : TxState()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@ data class SwapSuccessStateHolder(
|
|||
val toTokenFiatAmount: TextReference,
|
||||
val fromTokenIconState: TokenIconState?,
|
||||
val toTokenIconState: TokenIconState?,
|
||||
val onSecondaryButtonClick: () -> Unit,
|
||||
val onExploreButtonClick: () -> Unit,
|
||||
val onStatusButtonClick: () -> Unit,
|
||||
)
|
||||
|
|
@ -585,7 +585,8 @@ internal class StateBuilder(
|
|||
fromAmount: BigDecimal,
|
||||
toAmount: BigDecimal,
|
||||
txUrl: String,
|
||||
onSecondaryBtnClick: () -> Unit,
|
||||
onExploreClick: () -> Unit,
|
||||
onStatusClick: () -> Unit,
|
||||
): SwapStateHolder {
|
||||
val providerState = uiState.providerState as ProviderState.Content
|
||||
val fromToken = requireNotNull((uiState.sendCardData as? SwapCardState.SwapCardData)?.token)
|
||||
|
|
@ -612,7 +613,8 @@ internal class StateBuilder(
|
|||
toTokenFiatAmount = TextReference.Str(toFiatAmount),
|
||||
fromTokenIconState = fromTokenIconState,
|
||||
toTokenIconState = toTokenIconState,
|
||||
onSecondaryButtonClick = onSecondaryBtnClick,
|
||||
onExploreButtonClick = onExploreClick,
|
||||
onStatusButtonClick = onStatusClick,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import androidx.compose.material.Scaffold
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.components.*
|
||||
|
|
@ -20,7 +17,6 @@ import com.tangem.core.ui.components.inputrow.InputRowDefault
|
|||
import com.tangem.core.ui.components.inputrow.InputRowImage
|
||||
import com.tangem.core.ui.components.transactions.TransactionDoneTitle
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.shareText
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeProviderType
|
||||
import com.tangem.feature.swap.models.SwapSuccessStateHolder
|
||||
|
|
@ -44,7 +40,8 @@ fun SwapSuccessScreen(state: SwapSuccessStateHolder, onBack: () -> Unit) {
|
|||
textRes = R.string.common_close,
|
||||
txUrl = state.txUrl,
|
||||
showStatusButton = state.showStatusButton,
|
||||
onExploreClick = state.onSecondaryButtonClick,
|
||||
onExploreClick = state.onExploreButtonClick,
|
||||
onStatusClick = state.onStatusButtonClick,
|
||||
onDoneClick = onBack,
|
||||
)
|
||||
},
|
||||
|
|
@ -102,17 +99,16 @@ private fun SwapSuccessScreenContent(state: SwapSuccessStateHolder, padding: Pad
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
private fun SwapSuccessScreenButtons(
|
||||
@StringRes textRes: Int,
|
||||
txUrl: String,
|
||||
showStatusButton: Boolean,
|
||||
onExploreClick: () -> Unit,
|
||||
onStatusClick: () -> Unit,
|
||||
onDoneClick: () -> Unit,
|
||||
) {
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.background(TangemTheme.colors.background.secondary)
|
||||
|
|
@ -131,10 +127,7 @@ private fun SwapSuccessScreenButtons(
|
|||
SecondaryButtonIconStart(
|
||||
text = stringResource(id = R.string.express_cex_status_button_title),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
context.shareText(txUrl)
|
||||
},
|
||||
onClick = onStatusClick,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
|
|
@ -167,7 +160,8 @@ private val state = SwapSuccessStateHolder(
|
|||
fromTokenIconState = TokenIconState.Loading,
|
||||
toTokenIconState = TokenIconState.Loading,
|
||||
rate = TextReference.Str("1 000 DAI ~ 1 000 MATIC"),
|
||||
onSecondaryButtonClick = {},
|
||||
onExploreButtonClick = {},
|
||||
onStatusButtonClick = {},
|
||||
)
|
||||
|
||||
@Preview(showBackground = true)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ import com.tangem.feature.swap.domain.models.domain.SwapDataModel
|
|||
import com.tangem.feature.swap.domain.models.domain.SwapProvider
|
||||
import com.tangem.feature.swap.domain.models.formatToUIRepresentation
|
||||
import com.tangem.feature.swap.domain.models.ui.*
|
||||
import com.tangem.feature.swap.models.*
|
||||
import com.tangem.feature.swap.models.ApproveType
|
||||
import com.tangem.feature.swap.models.SwapStateHolder
|
||||
import com.tangem.feature.swap.models.UiActions
|
||||
import com.tangem.feature.swap.models.toDomainApproveType
|
||||
import com.tangem.feature.swap.presentation.SwapFragment
|
||||
import com.tangem.feature.swap.router.SwapNavScreen
|
||||
import com.tangem.feature.swap.router.SwapRouter
|
||||
|
|
@ -402,12 +405,18 @@ internal class SwapViewModel @Inject constructor(
|
|||
fromAmount = dataState.amount?.toBigDecimal() ?: BigDecimal.ZERO,
|
||||
toAmount = dataState.swapDataModel?.toTokenAmount?.value ?: BigDecimal.ZERO,
|
||||
txUrl = url,
|
||||
onSecondaryBtnClick = {
|
||||
onExploreClick = {
|
||||
val txHash = it.txAddress
|
||||
if (txHash.isNotEmpty()) {
|
||||
swapRouter.openUrl(url)
|
||||
}
|
||||
},
|
||||
onStatusClick = {
|
||||
val txExternalUrl = it.txExternalUrl
|
||||
if (!txExternalUrl.isNullOrBlank()) {
|
||||
swapRouter.openUrl(txExternalUrl)
|
||||
}
|
||||
},
|
||||
)
|
||||
analyticsEventHandler.send(SwapEvents.SwapInProgressScreen)
|
||||
swapRouter.openScreen(SwapNavScreen.Success)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue