diff --git a/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt b/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt index 09c66ed8c8..a2eed383f5 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt @@ -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, + ) + }, ) } \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt index 435ced42ba..834e4fb850 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt @@ -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( 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 9fc0a051b5..3b8d00da73 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 @@ -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 diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt index f6443b6ed5..606d0ed064 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt @@ -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