Updated on 2026-08-14
This commit is contained in:
commit
c86f915e7d
28 changed files with 274 additions and 66 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.swap
|
||||
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.data.common.currency.UserTokensResponseFactory
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectList
|
||||
|
|
@ -26,6 +27,7 @@ internal class DefaultSwapTransactionRepository(
|
|||
) : SwapTransactionRepository {
|
||||
|
||||
private val converter = SavedSwapTransactionListConverter(excludedBlockchains)
|
||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||
|
||||
override suspend fun storeTransaction(
|
||||
userWalletId: UserWalletId,
|
||||
|
|
@ -33,7 +35,13 @@ internal class DefaultSwapTransactionRepository(
|
|||
toCryptoCurrency: CryptoCurrency,
|
||||
transaction: SavedSwapTransactionModel,
|
||||
) {
|
||||
transaction.status?.let { storeTransactionState(transaction.txId, it) }
|
||||
transaction.status?.let {
|
||||
storeTransactionState(
|
||||
txId = transaction.txId,
|
||||
status = it,
|
||||
refundTokenCurrency = null,
|
||||
)
|
||||
}
|
||||
appPreferencesStore.editData { mutablePreferences ->
|
||||
val savedTransactions: List<SavedSwapTransactionListModelInner>? = mutablePreferences.getObjectList(
|
||||
key = PreferencesKeys.SWAP_TRANSACTIONS_KEY,
|
||||
|
|
@ -154,14 +162,22 @@ internal class DefaultSwapTransactionRepository(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun storeTransactionState(txId: String, status: ExchangeStatusModel) {
|
||||
override suspend fun storeTransactionState(
|
||||
txId: String,
|
||||
status: ExchangeStatusModel,
|
||||
refundTokenCurrency: CryptoCurrency?,
|
||||
) {
|
||||
appPreferencesStore.editData { mutablePreferences ->
|
||||
val savedMap = mutablePreferences.getObjectMap<ExchangeStatusModel>(
|
||||
key = PreferencesKeys.SWAP_TRANSACTIONS_STATUSES_KEY,
|
||||
)
|
||||
|
||||
val updatesMap = savedMap.toMutableMap()
|
||||
updatesMap[txId] = status
|
||||
updatesMap[txId] = status.copy(
|
||||
refundTokensResponse = refundTokenCurrency?.let {
|
||||
userTokensResponseFactory.createResponseToken(refundTokenCurrency)
|
||||
},
|
||||
)
|
||||
|
||||
mutablePreferences.setObjectMap(
|
||||
key = PreferencesKeys.SWAP_TRANSACTIONS_STATUSES_KEY,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,15 @@ internal class SavedSwapTransactionListConverter(
|
|||
|
||||
return SavedSwapTransactionListModel(
|
||||
transactions = value.transactions.map { tx ->
|
||||
tx.copy(status = txStatuses[tx.txId])
|
||||
val status = txStatuses[tx.txId]
|
||||
val refundCurrency = status?.refundTokensResponse?.let { id ->
|
||||
responseCryptoCurrenciesFactory.createCurrency(
|
||||
responseToken = id,
|
||||
scanResponse = scanResponse,
|
||||
)
|
||||
}
|
||||
val statusWithRefundCurrency = status?.copy(refundCurrency = refundCurrency)
|
||||
tx.copy(status = statusWithRefundCurrency)
|
||||
},
|
||||
userWalletId = value.userWalletId,
|
||||
fromCryptoCurrencyId = value.fromCryptoCurrencyId,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ dependencies {
|
|||
/** Core modules */
|
||||
implementation(projects.core.utils)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.datasource)
|
||||
|
||||
/** Feature Apis */
|
||||
implementation(projects.features.wallet.api)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.tangem.feature.swap.domain.models.domain
|
|||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ExchangeStatusModel(
|
||||
|
|
@ -19,6 +21,10 @@ data class ExchangeStatusModel(
|
|||
val refundNetwork: String? = null,
|
||||
@Json(name = "refundContractAddress")
|
||||
val refundContractAddress: String? = null,
|
||||
@Json(name = "refundTokensResponse")
|
||||
val refundTokensResponse: UserTokensResponse.Token? = null,
|
||||
@Json(ignore = true)
|
||||
val refundCurrency: CryptoCurrency? = null,
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = false)
|
||||
|
|
@ -64,4 +70,16 @@ enum class ExchangeStatus {
|
|||
|
||||
@Json(name = "Paused")
|
||||
Paused,
|
||||
|
||||
;
|
||||
|
||||
val isTerminal: Boolean
|
||||
get() = this == Refunded ||
|
||||
this == Finished ||
|
||||
this == Cancelled ||
|
||||
this == TxFailed ||
|
||||
this == Unknown
|
||||
|
||||
val isAutoDisposable: Boolean
|
||||
get() = this == Finished
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ interface SwapTransactionRepository {
|
|||
txId: String,
|
||||
)
|
||||
|
||||
suspend fun storeTransactionState(txId: String, status: ExchangeStatusModel)
|
||||
suspend fun storeTransactionState(txId: String, status: ExchangeStatusModel, refundTokenCurrency: CryptoCurrency?)
|
||||
|
||||
suspend fun storeLastSwappedCryptoCurrencyId(userWalletId: UserWalletId, cryptoCurrencyId: CryptoCurrency.ID)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.tokendetails.presentation.tokendetails.state.components
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
|
||||
|
|
@ -133,5 +134,22 @@ internal data class TokenDetailsDialogConfig(
|
|||
onClick = onConfirmClick,
|
||||
)
|
||||
}
|
||||
|
||||
data class ConfirmExpressStatusHideDialogConfig(
|
||||
val onConfirmClick: () -> Unit,
|
||||
val onCancelClick: () -> Unit,
|
||||
) : DialogContentConfig() {
|
||||
override val title: TextReference = resourceReference(R.string.express_status_hide_dialog_title)
|
||||
override val message: TextReference = resourceReference(R.string.express_status_hide_dialog_text)
|
||||
override val confirmButtonConfig: ButtonConfig = ButtonConfig(
|
||||
text = resourceReference(R.string.common_hide),
|
||||
onClick = onConfirmClick,
|
||||
)
|
||||
|
||||
override val cancelButtonConfig: ButtonConfig = ButtonConfig(
|
||||
text = resourceReference(R.string.common_cancel),
|
||||
onClick = onCancelClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ internal data class ExchangeUM(
|
|||
val statuses: ImmutableList<ExchangeStatusState>,
|
||||
val notification: ExchangeStatusNotifications? = null,
|
||||
val showProviderLink: Boolean,
|
||||
val isRefundTerminalStatus: Boolean,
|
||||
val fromCryptoCurrency: CryptoCurrency,
|
||||
val toCryptoCurrency: CryptoCurrency,
|
||||
) : ExpressTransactionStateUM
|
||||
|
|
@ -94,6 +94,7 @@ internal class TokenDetailsOnrampTransactionStateConverter(
|
|||
clickIntents.onGoToProviderClick(it)
|
||||
},
|
||||
onClick = { clickIntents.onExpressTransactionClick(value.txId) },
|
||||
onDisposeExpressStatus = clickIntents::onConfirmDisposeExpressStatus,
|
||||
),
|
||||
providerName = value.providerName,
|
||||
providerImageUrl = value.providerImageUrl,
|
||||
|
|
|
|||
|
|
@ -340,6 +340,22 @@ internal class TokenDetailsStateFactory(
|
|||
return balanceSelectStateConverter.convert(buttonConfig)
|
||||
}
|
||||
|
||||
fun getStateWithConfirmHideExpressStatus(): TokenDetailsState {
|
||||
return currentStateProvider().copy(
|
||||
dialogConfig = TokenDetailsDialogConfig(
|
||||
isShow = true,
|
||||
onDismissRequest = clickIntents::onDismissDialog,
|
||||
content = TokenDetailsDialogConfig.DialogContentConfig.ConfirmExpressStatusHideDialogConfig(
|
||||
onConfirmClick = {
|
||||
clickIntents.onDisposeExpressStatus()
|
||||
clickIntents.onDismissDialog()
|
||||
},
|
||||
onCancelClick = clickIntents::onDismissDialog,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun TokenDetailsAppBarMenuConfig.updateMenu(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
hasDerivations: Boolean,
|
||||
|
|
|
|||
|
|
@ -80,17 +80,20 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
fromFiatAmount = quote.fiatRate.multiply(fromAmount)
|
||||
}
|
||||
}
|
||||
val notifications =
|
||||
getNotification(transaction.status?.status, transaction.status?.txExternalUrl, null)
|
||||
val statusModel = transaction.status
|
||||
val notifications = getNotification(
|
||||
status = statusModel?.status,
|
||||
txUrl = statusModel?.txExternalUrl,
|
||||
refundToken = statusModel?.refundCurrency,
|
||||
)
|
||||
val showProviderLink = getShowProviderLink(notifications, transaction.status)
|
||||
result.add(
|
||||
ExchangeUM(
|
||||
provider = transaction.provider,
|
||||
statuses = getStatuses(transaction.status?.status),
|
||||
statuses = getStatuses(statusModel?.status),
|
||||
notification = notifications,
|
||||
activeStatus = transaction.status?.status,
|
||||
activeStatus = statusModel?.status,
|
||||
showProviderLink = showProviderLink,
|
||||
isRefundTerminalStatus = true,
|
||||
fromCryptoCurrency = fromCryptoCurrency,
|
||||
toCryptoCurrency = toCryptoCurrency,
|
||||
info = createStateInfo(
|
||||
|
|
@ -107,25 +110,19 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
return result.toPersistentList()
|
||||
}
|
||||
|
||||
fun updateTxStatus(
|
||||
tx: ExchangeUM,
|
||||
statusModel: ExchangeStatusModel?,
|
||||
refundToken: CryptoCurrency?,
|
||||
isRefundTerminalStatus: Boolean,
|
||||
): ExchangeUM {
|
||||
fun updateTxStatus(tx: ExchangeUM, statusModel: ExchangeStatusModel?): ExchangeUM {
|
||||
if (statusModel == null || tx.activeStatus == statusModel.status) {
|
||||
Timber.e("UpdateTxStatus isn't required. Current status isn't changed")
|
||||
return tx
|
||||
}
|
||||
val hasFailed = statusModel.status == ExchangeStatus.Failed
|
||||
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, refundToken)
|
||||
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, statusModel.refundCurrency)
|
||||
val showProviderLink = getShowProviderLink(notifications, statusModel)
|
||||
return tx.copy(
|
||||
activeStatus = statusModel.status,
|
||||
notification = notifications,
|
||||
statuses = getStatuses(statusModel.status, hasFailed),
|
||||
showProviderLink = showProviderLink,
|
||||
isRefundTerminalStatus = isRefundTerminalStatus,
|
||||
info = tx.info.copy(txExternalUrl = statusModel.txExternalUrl),
|
||||
)
|
||||
}
|
||||
|
|
@ -164,7 +161,8 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
},
|
||||
iconState = getIconState(transaction.status?.status),
|
||||
status = getStatusState(),
|
||||
notification = null, // fixme [REDACTED_JIRA]
|
||||
notification = null, // fixme [REDACTED_JIRA],
|
||||
onDisposeExpressStatus = clickIntents::onConfirmDisposeExpressStatus,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,13 +79,13 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun removeTransactionOnBottomSheetClosed(isForceTerminal: Boolean = false) {
|
||||
suspend fun removeTransactionOnBottomSheetClosed(isForceDispose: Boolean = false) {
|
||||
val state = currentStateProvider()
|
||||
val bottomSheetConfig = state.bottomSheetConfig?.content as? ExpressStatusBottomSheetConfig ?: return
|
||||
val selectedTx = bottomSheetConfig.value as? ExchangeUM ?: return
|
||||
|
||||
val shouldTerminate = selectedTx.activeStatus.isTerminal(selectedTx.isRefundTerminalStatus) || isForceTerminal
|
||||
if (shouldTerminate) {
|
||||
val shouldDispose = selectedTx.activeStatus?.isAutoDisposable == true || isForceDispose
|
||||
if (shouldDispose) {
|
||||
swapTransactionRepository.removeTransaction(
|
||||
userWalletId = userWalletId,
|
||||
fromCryptoCurrency = selectedTx.fromCryptoCurrency,
|
||||
|
|
@ -96,20 +96,14 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
}
|
||||
|
||||
suspend fun updateSwapTxStatus(swapTx: ExchangeUM): ExchangeUM {
|
||||
return if (swapTx.activeStatus.isTerminal(swapTx.isRefundTerminalStatus)) {
|
||||
return if (swapTx.activeStatus?.isTerminal == true) {
|
||||
swapTx
|
||||
} else {
|
||||
val statusModel = getExchangeStatus(swapTx.info.txId, swapTx.provider)
|
||||
val isRefundTerminalStatus = statusModel?.refundNetwork == null &&
|
||||
statusModel?.refundContractAddress == null &&
|
||||
swapTx.provider.type != ExchangeProviderType.DEX_BRIDGE
|
||||
|
||||
val addedRefundToken = addRefundCurrencyIfNeeded(statusModel, swapTx.provider.type)
|
||||
swapTransactionsStateConverter.updateTxStatus(
|
||||
tx = swapTx,
|
||||
statusModel = statusModel,
|
||||
refundToken = addedRefundToken,
|
||||
isRefundTerminalStatus = isRefundTerminalStatus,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -120,8 +114,11 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
ifLeft = { null },
|
||||
ifRight = { statusModel ->
|
||||
sendStatusUpdateAnalytics(statusModel, provider)
|
||||
swapTransactionRepository.storeTransactionState(txId, statusModel)
|
||||
statusModel
|
||||
|
||||
val refundTokenCurrency = addRefundCurrencyIfNeeded(statusModel, provider.type)
|
||||
|
||||
swapTransactionRepository.storeTransactionState(txId, statusModel, refundTokenCurrency)
|
||||
statusModel.copy(refundCurrency = refundTokenCurrency)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -174,15 +171,6 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun ExchangeStatus?.isTerminal(isRefundTerminal: Boolean): Boolean {
|
||||
val needTerminalRefund = this == ExchangeStatus.Refunded && isRefundTerminal
|
||||
return needTerminalRefund ||
|
||||
this == ExchangeStatus.Finished ||
|
||||
this == ExchangeStatus.Cancelled ||
|
||||
this == ExchangeStatus.TxFailed ||
|
||||
this == ExchangeStatus.Unknown
|
||||
}
|
||||
|
||||
private fun toAnalyticStatus(status: ExchangeStatus?): ExpressAnalyticsStatus? {
|
||||
return when (status) {
|
||||
ExchangeStatus.New,
|
||||
|
|
|
|||
|
|
@ -157,11 +157,13 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
|
||||
suspend fun removeTransactionOnBottomSheetClosed(
|
||||
expressState: ExpressTransactionStateUM,
|
||||
isForceTerminal: Boolean = false,
|
||||
isForceDispose: Boolean = false,
|
||||
) {
|
||||
when (expressState) {
|
||||
is ExchangeUM -> exchangeStatusFactory.removeTransactionOnBottomSheetClosed(isForceTerminal)
|
||||
is ExpressTransactionStateUM.OnrampUM -> onrampStatusFactory.removeTransactionOnBottomSheetClosed()
|
||||
is ExchangeUM -> exchangeStatusFactory.removeTransactionOnBottomSheetClosed(isForceDispose)
|
||||
is ExpressTransactionStateUM.OnrampUM -> onrampStatusFactory.removeTransactionOnBottomSheetClosed(
|
||||
isForceDispose,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ internal class OnrampStatusFactory @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun removeTransactionOnBottomSheetClosed() {
|
||||
suspend fun removeTransactionOnBottomSheetClosed(isForceDispose: Boolean) {
|
||||
val state = currentStateProvider()
|
||||
val bottomSheetConfig = state.bottomSheetConfig?.content as? ExpressStatusBottomSheetConfig ?: return
|
||||
val selectedTx = bottomSheetConfig.value as? ExpressTransactionStateUM.OnrampUM ?: return
|
||||
|
||||
if (selectedTx.activeStatus.isTerminal) {
|
||||
if (selectedTx.activeStatus.isAutoDisposable || isForceDispose) {
|
||||
onrampRemoveTransactionUseCase(externalTxId = selectedTx.info.txExternalId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import com.tangem.common.ui.expressStatus.ExpressEstimate
|
||||
import com.tangem.common.ui.expressStatus.ExpressHideButton
|
||||
import com.tangem.common.ui.expressStatus.ExpressProvider
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.SpacerH10
|
||||
|
|
@ -70,6 +71,11 @@ internal fun ExchangeStatusBottomSheetContent(state: ExchangeUM) {
|
|||
if (state.notification != null) {
|
||||
Notification(state = state.notification, activeStatus = state.activeStatus)
|
||||
}
|
||||
ExpressHideButton(
|
||||
isTerminal = state.activeStatus?.isTerminal == true,
|
||||
isAutoDisposable = state.activeStatus?.isAutoDisposable == true,
|
||||
onClick = state.info.onDisposeExpressStatus,
|
||||
)
|
||||
SpacerH24()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,4 +72,8 @@ interface TokenDetailsClickIntents {
|
|||
fun onGoToRefundedTokenClick(cryptoCurrency: CryptoCurrency)
|
||||
|
||||
fun onOpenUrlClick(url: String)
|
||||
|
||||
fun onConfirmDisposeExpressStatus()
|
||||
|
||||
fun onDisposeExpressStatus()
|
||||
}
|
||||
|
|
@ -784,16 +784,6 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onGoToRefundedTokenClick(cryptoCurrency: CryptoCurrency) {
|
||||
val bottomSheetState = internalUiState.value.bottomSheetConfig?.content
|
||||
if (bottomSheetState is ExpressStatusBottomSheetConfig) {
|
||||
viewModelScope.launch {
|
||||
expressStatusFactory.removeTransactionOnBottomSheetClosed(
|
||||
expressState = bottomSheetState.value,
|
||||
isForceTerminal = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
internalUiState.value = stateFactory.getStateWithClosedBottomSheet()
|
||||
router.openTokenDetails(userWalletId, cryptoCurrency)
|
||||
}
|
||||
|
||||
|
|
@ -950,6 +940,23 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
internalUiState.value = stateFactory.getStateWithUpdatedBalanceSegmentedButtonConfig(config)
|
||||
}
|
||||
|
||||
override fun onConfirmDisposeExpressStatus() {
|
||||
internalUiState.value = stateFactory.getStateWithConfirmHideExpressStatus()
|
||||
}
|
||||
|
||||
override fun onDisposeExpressStatus() {
|
||||
val bottomSheetState = internalUiState.value.bottomSheetConfig?.content
|
||||
if (bottomSheetState is ExpressStatusBottomSheetConfig) {
|
||||
viewModelScope.launch {
|
||||
expressStatusFactory.removeTransactionOnBottomSheetClosed(
|
||||
expressState = bottomSheetState.value,
|
||||
isForceDispose = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
internalUiState.value = stateFactory.getStateWithClosedBottomSheet()
|
||||
}
|
||||
|
||||
private fun handleUnavailabilityReason(
|
||||
unavailabilityReason: ScenarioUnavailabilityReason,
|
||||
tokenSymbol: String,
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ internal class OnrampStatusFactory @Inject constructor(
|
|||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
|
||||
suspend fun removeTransactionOnBottomSheetClosed() {
|
||||
suspend fun removeTransactionOnBottomSheetClosed(forceDispose: Boolean) {
|
||||
val state = stateHolder.getSelectedWallet()
|
||||
val bottomSheetConfig = state.bottomSheetConfig?.content as? ExpressStatusBottomSheetConfig ?: return
|
||||
val selectedTx = bottomSheetConfig.value as? ExpressTransactionStateUM.OnrampUM ?: return
|
||||
|
||||
if (selectedTx.activeStatus.isTerminal) {
|
||||
if (selectedTx.activeStatus.isAutoDisposable || forceDispose) {
|
||||
onrampRemoveTransactionUseCase(externalTxId = selectedTx.info.txExternalId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ internal sealed interface WalletAlertState {
|
|||
open val confirmButtonText: TextReference = resourceReference(id = R.string.common_ok)
|
||||
open val isWarningConfirmButton: Boolean = false
|
||||
abstract val onConfirmClick: (() -> Unit)?
|
||||
open val cancelButtonText: TextReference? = null
|
||||
open val onCancelClick: (() -> Unit)? = null
|
||||
}
|
||||
|
||||
@Immutable
|
||||
|
|
@ -108,4 +110,14 @@ internal sealed interface WalletAlertState {
|
|||
|
||||
override val onConfirmClick: (() -> Unit)? = null
|
||||
}
|
||||
|
||||
data class ConfirmExpressStatusHide(
|
||||
override val onConfirmClick: (() -> Unit),
|
||||
override val onCancelClick: (() -> Unit),
|
||||
) : Basic() {
|
||||
override val title: TextReference = resourceReference(R.string.express_status_hide_dialog_title)
|
||||
override val message: TextReference = resourceReference(R.string.express_status_hide_dialog_text)
|
||||
override val confirmButtonText: TextReference = resourceReference(R.string.common_hide)
|
||||
override val cancelButtonText: TextReference = resourceReference(R.string.common_cancel)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,9 +62,7 @@ internal class SingleWalletOnrampTransactionConverter(
|
|||
value.timestamp.toTimeFormat(),
|
||||
),
|
||||
),
|
||||
toAmount = stringReference(
|
||||
value.toAmount.format { crypto(currency) },
|
||||
),
|
||||
toAmount = stringReference(value.toAmount.format { crypto(currency) }),
|
||||
toFiatAmount = stringReference(
|
||||
status.fiatRate?.multiply(value.toAmount).format {
|
||||
fiat(
|
||||
|
|
@ -94,6 +92,7 @@ internal class SingleWalletOnrampTransactionConverter(
|
|||
analyticsEventHandler.send(TokenOnrampAnalyticsEvent.GoToProvider)
|
||||
clickIntents.onGoToProviderClick(it)
|
||||
},
|
||||
onDisposeExpressStatus = clickIntents::onConfirmDisposeExpressStatus,
|
||||
onClick = {
|
||||
val analyticEvent = TokenOnrampAnalyticsEvent.OnrampStatusOpened(
|
||||
tokenSymbol = currency.symbol,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ internal class WalletEventSender @Inject constructor(
|
|||
stateHolder.update(transformer = SendEventTransformer(event = event, onConsume = ::onConsume))
|
||||
}
|
||||
|
||||
private fun onConsume() {
|
||||
fun onConsume() {
|
||||
stateHolder.update {
|
||||
it.copy(event = consumedEvent())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
|||
import com.tangem.feature.wallet.presentation.wallet.domain.OnrampStatusFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.unwrap
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.ActionsBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.CloseBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.OpenBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.MultiWalletCurrencyActionsConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
|
|
@ -54,6 +56,10 @@ internal interface WalletContentClickIntents {
|
|||
fun onGoToProviderClick(externalTxId: String)
|
||||
|
||||
fun onExpressTransactionClick(txId: String)
|
||||
|
||||
fun onConfirmDisposeExpressStatus()
|
||||
|
||||
fun onDisposeExpressStatus()
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
|
|
@ -70,6 +76,7 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
private val shouldShowMarketsTooltipUseCase: ShouldShowMarketsTooltipUseCase,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
private val reduxStateHolder: ReduxStateHolder,
|
||||
private val walletEventSender: WalletEventSender,
|
||||
) : BaseWalletClickIntents(), WalletContentClickIntents {
|
||||
|
||||
override fun onBackClick() = router.popBackStack()
|
||||
|
|
@ -185,7 +192,7 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
val userWalletId = stateHolder.getSelectedWalletId()
|
||||
if (stateHolder.getSelectedWallet().bottomSheetConfig?.content is ExpressStatusBottomSheetConfig) {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
onrampStatusFactory.removeTransactionOnBottomSheetClosed()
|
||||
onrampStatusFactory.removeTransactionOnBottomSheetClosed(forceDispose = false)
|
||||
}
|
||||
}
|
||||
stateHolder.update(CloseBottomSheetTransformer(userWalletId))
|
||||
|
|
@ -211,4 +218,28 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onConfirmDisposeExpressStatus() {
|
||||
walletEventSender.send(
|
||||
WalletEvent.ShowAlert(
|
||||
WalletAlertState.ConfirmExpressStatusHide(
|
||||
onConfirmClick = {
|
||||
walletEventSender.onConsume()
|
||||
onDisposeExpressStatus()
|
||||
},
|
||||
onCancelClick = walletEventSender::onConsume,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDisposeExpressStatus() {
|
||||
val userWalletId = stateHolder.getSelectedWalletId()
|
||||
if (stateHolder.getSelectedWallet().bottomSheetConfig?.content is ExpressStatusBottomSheetConfig) {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
onrampStatusFactory.removeTransactionOnBottomSheetClosed(forceDispose = true)
|
||||
}
|
||||
}
|
||||
stateHolder.update(CloseBottomSheetTransformer(userWalletId))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue