Updated on 2026-08-14
This commit is contained in:
commit
8d02ac6406
12 changed files with 69 additions and 46 deletions
|
|
@ -6,23 +6,27 @@ import com.tangem.core.ui.extensions.resourceReference
|
|||
|
||||
object ExpressNotificationsUM {
|
||||
|
||||
data class NeedVerification(val onGoToProviderClick: () -> Unit) : NotificationUM.Warning(
|
||||
data class NeedVerification(val onGoToProviderClick: (() -> Unit)?) : NotificationUM.Warning(
|
||||
title = resourceReference(R.string.express_exchange_notification_verification_title),
|
||||
subtitle = resourceReference(R.string.express_exchange_notification_verification_text),
|
||||
iconResId = R.drawable.ic_alert_triangle_20,
|
||||
buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = resourceReference(R.string.common_go_to_provider),
|
||||
onClick = onGoToProviderClick,
|
||||
),
|
||||
buttonsState = onGoToProviderClick?.let { onClick ->
|
||||
NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = resourceReference(R.string.common_go_to_provider),
|
||||
onClick = onClick,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
data class FailedByProvider(val onGoToProviderClick: () -> Unit) : NotificationUM.Error(
|
||||
data class FailedByProvider(val onGoToProviderClick: (() -> Unit)?) : NotificationUM.Error(
|
||||
title = resourceReference(R.string.express_exchange_notification_failed_title),
|
||||
subtitle = resourceReference(R.string.express_exchange_notification_failed_text),
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = resourceReference(R.string.common_go_to_provider),
|
||||
onClick = onGoToProviderClick,
|
||||
),
|
||||
buttonState = onGoToProviderClick?.let { onClick ->
|
||||
NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = resourceReference(R.string.common_go_to_provider),
|
||||
onClick = onClick,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.domain.tokens.model.analytics
|
||||
|
||||
import com.tangem.core.analytics.models.AnalyticsEvent
|
||||
import com.tangem.core.analytics.models.AnalyticsParam.Key.CURRENCY
|
||||
import com.tangem.core.analytics.models.AnalyticsParam.Key.PROVIDER
|
||||
import com.tangem.core.analytics.models.AnalyticsParam.Key.STATUS
|
||||
import com.tangem.core.analytics.models.AnalyticsParam.Key.TOKEN_PARAM
|
||||
|
|
@ -16,7 +15,7 @@ class TokenOnrampAnalyticsEvent(
|
|||
params = mapOf(
|
||||
TOKEN_PARAM to tokenSymbol,
|
||||
PROVIDER to provider,
|
||||
CURRENCY to fiatCurrency,
|
||||
"Currency Type" to fiatCurrency,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -27,7 +26,7 @@ class TokenOnrampAnalyticsEvent(
|
|||
TOKEN_PARAM to tokenSymbol,
|
||||
STATUS to status,
|
||||
PROVIDER to provider,
|
||||
CURRENCY to fiatCurrency,
|
||||
"Currency Type" to fiatCurrency,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -70,12 +70,14 @@ internal class DefaultConfirmResidencyComponent @AssistedInject constructor(
|
|||
context = childByContext(componentContext),
|
||||
params = SelectCountryComponent.Params(
|
||||
cryptoCurrency = params.cryptoCurrency,
|
||||
onDismiss = {
|
||||
onDismiss = { isCountrySelected ->
|
||||
// Dismiss country select sheet
|
||||
model.bottomSheetNavigation.dismiss()
|
||||
|
||||
// Dismiss confirm residency sheet
|
||||
config.onDismiss()
|
||||
if (isCountrySelected) {
|
||||
// Dismiss confirm residency sheet
|
||||
config.onDismiss()
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ internal class DefaultSelectCountryComponent @AssistedInject constructor(
|
|||
private val model: OnrampSelectCountryModel = getOrCreateModel(params)
|
||||
|
||||
override fun dismiss() {
|
||||
model.dismiss()
|
||||
model.dismiss(isCountrySelected = false)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
|||
|
||||
internal interface SelectCountryComponent : ComposableBottomSheetComponent {
|
||||
|
||||
data class Params(val cryptoCurrency: CryptoCurrency, val onDismiss: () -> Unit)
|
||||
data class Params(val cryptoCurrency: CryptoCurrency, val onDismiss: (Boolean) -> Unit)
|
||||
|
||||
interface Factory : ComponentFactory<Params, SelectCountryComponent>
|
||||
}
|
||||
|
|
@ -60,8 +60,8 @@ internal class OnrampSelectCountryModel @Inject constructor(
|
|||
modelScope.launch { subscribeOnUpdateState() }
|
||||
}
|
||||
|
||||
fun dismiss() {
|
||||
params.onDismiss()
|
||||
fun dismiss(isCountrySelected: Boolean) {
|
||||
params.onDismiss(isCountrySelected)
|
||||
}
|
||||
|
||||
private suspend fun subscribeOnUpdateState() {
|
||||
|
|
@ -92,7 +92,7 @@ internal class OnrampSelectCountryModel @Inject constructor(
|
|||
analyticsEventHandler.send(OnrampAnalyticsEvent.OnResidenceChosen(country.name))
|
||||
modelScope.launch {
|
||||
saveDefaultCountryUseCase.invoke(country)
|
||||
dismiss()
|
||||
dismiss(isCountrySelected = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ internal class DefaultOnrampSettingsComponent @AssistedInject constructor(
|
|||
context = childByContext(componentContext),
|
||||
params = SelectCountryComponent.Params(
|
||||
params.cryptoCurrency,
|
||||
model.bottomSheetNavigation::dismiss,
|
||||
onDismiss = { model.bottomSheetNavigation.dismiss() },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,22 +52,27 @@ internal class SetOnrampSuccessContentConverter(
|
|||
}
|
||||
|
||||
private fun getNotification(status: OnrampStatus.Status, externalTxUrl: String?): NotificationUM? {
|
||||
if (externalTxUrl == null) return null
|
||||
return when (status) {
|
||||
OnrampStatus.Status.Verifying -> {
|
||||
ExpressNotificationsUM.NeedVerification {
|
||||
goToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.NeedVerification(
|
||||
onGoToProviderClick = onProviderClick(externalTxUrl),
|
||||
)
|
||||
}
|
||||
OnrampStatus.Status.Failed -> {
|
||||
ExpressNotificationsUM.FailedByProvider {
|
||||
goToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.FailedByProvider(
|
||||
onGoToProviderClick = onProviderClick(externalTxUrl),
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) {
|
||||
{ goToProviderClick(externalTxUrl) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
private fun convertStatuses(status: OnrampStatus.Status, externalTxUrl: String?): ExpressStatusUM {
|
||||
val statuses = with(status) {
|
||||
persistentListOf(
|
||||
|
|
|
|||
|
|
@ -79,10 +79,17 @@ internal class OnrampSuccessComponentModel @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun loadTransactionStatus(transaction: OnrampTransaction) {
|
||||
val cryptoCurrency = getCryptoCurrencyUseCase(
|
||||
val multiCryptoCurrency = getCryptoCurrencyUseCase(
|
||||
transaction.userWalletId,
|
||||
transaction.toCurrencyId,
|
||||
).getOrElse { error("Crypto currency not found") }
|
||||
).getOrNull()
|
||||
|
||||
val cryptoCurrency = multiCryptoCurrency
|
||||
?: getCryptoCurrencyUseCase.invoke(transaction.userWalletId).getOrElse {
|
||||
Timber.e("Crypto currency not found")
|
||||
showErrorAlert(OnrampError.DomainError(null))
|
||||
return
|
||||
}
|
||||
|
||||
getOnrampStatusUseCase(txId = transaction.txId)
|
||||
.fold(
|
||||
|
|
|
|||
|
|
@ -108,23 +108,24 @@ internal class TokenDetailsOnrampTransactionStateConverter(
|
|||
externalTxUrl: String?,
|
||||
providerName: String,
|
||||
): NotificationUM? {
|
||||
if (externalTxUrl == null) return null
|
||||
return when (status) {
|
||||
OnrampStatus.Status.Verifying -> {
|
||||
analyticsEventHandler.send(TokenOnrampAnalyticsEvent.NoticeKYC(cryptoCurrency.symbol, providerName))
|
||||
ExpressNotificationsUM.NeedVerification {
|
||||
clickIntents.onGoToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.NeedVerification(onGoToProviderClick = onProviderClick(externalTxUrl))
|
||||
}
|
||||
OnrampStatus.Status.Failed -> {
|
||||
ExpressNotificationsUM.FailedByProvider {
|
||||
clickIntents.onGoToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.FailedByProvider(onGoToProviderClick = onProviderClick(externalTxUrl))
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) {
|
||||
{ clickIntents.onGoToProviderClick(externalTxUrl) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
private fun getIconState(status: OnrampStatus.Status): ExpressTransactionStateIconUM {
|
||||
return when (status) {
|
||||
OnrampStatus.Status.Verifying -> ExpressTransactionStateIconUM.Warning
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ internal class OnrampStatusFactory @Inject constructor(
|
|||
analyticsEventHandler.send(
|
||||
TokenOnrampAnalyticsEvent.OnrampStatusChanged(
|
||||
tokenSymbol = onrampTx.info.toAmountSymbol,
|
||||
status = status.name,
|
||||
status = status.value,
|
||||
provider = onrampTx.providerName,
|
||||
fiatCurrency = onrampTx.fromCurrencyCode,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -117,25 +117,30 @@ internal class SingleWalletOnrampTransactionConverter(
|
|||
externalTxUrl: String?,
|
||||
providerName: String,
|
||||
): NotificationUM? {
|
||||
if (externalTxUrl == null) return null
|
||||
return when (status) {
|
||||
OnrampStatus.Status.Verifying -> {
|
||||
analyticsEventHandler.send(
|
||||
TokenOnrampAnalyticsEvent.NoticeKYC(currency.symbol, providerName),
|
||||
)
|
||||
ExpressNotificationsUM.NeedVerification {
|
||||
clickIntents.onGoToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.NeedVerification(
|
||||
onGoToProviderClick = onProviderClick(externalTxUrl),
|
||||
)
|
||||
}
|
||||
OnrampStatus.Status.Failed -> {
|
||||
ExpressNotificationsUM.FailedByProvider {
|
||||
clickIntents.onGoToProviderClick(externalTxUrl)
|
||||
}
|
||||
ExpressNotificationsUM.FailedByProvider(
|
||||
onGoToProviderClick = onProviderClick(externalTxUrl),
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) {
|
||||
{ clickIntents.onGoToProviderClick(externalTxUrl) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
private fun getIconState(status: OnrampStatus.Status): ExpressTransactionStateIconUM {
|
||||
return when (status) {
|
||||
OnrampStatus.Status.Verifying -> ExpressTransactionStateIconUM.Warning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue