From 40fe8bb5cbce6f3c5176474abd4c97edf63c1d6c Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 29 Apr 2026 20:50:41 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../configs/feature_toggles_config.json | 4 - .../models/response/ReissueCardResponse.kt | 2 +- data/account/build.gradle.kts | 2 - .../DefaultSingleAccountListProducer.kt | 13 +- .../DefaultSingleAccountListProducerTest.kt | 19 +- .../tangem/data/pay/di/TangemPayDataModule.kt | 20 -- .../DefaultPaymentAccountStatusFetcher.kt | 4 +- .../DefaultCustomerOrderRepository.kt | 10 +- .../DefaultReissueCardRepository.kt | 7 +- .../data/pay/util/OrderStatusConverter.kt | 16 ++ .../tokens/wallet/WalletBalanceFetcher.kt | 26 +-- .../tokens/wallet/WalletBalanceFetcherTest.kt | 15 -- .../tangem/domain/pay/model/OrderStatus.kt | 14 -- .../TangemPayMainScreenCustomerInfoUseCase.kt | 179 ------------------ features/details/impl/build.gradle.kts | 1 - .../tangempay/TangemPayFeatureToggles.kt | 4 +- .../DefaultTangemPayFeatureToggles.kt | 10 +- .../tangempay/di/TangemPayDetailsModule.kt | 5 +- .../tangempay/model/TangemPayCardPageModel.kt | 2 +- features/tokendetails/impl/build.gradle.kts | 1 - .../DefaultTokenDetailsDeepLinkHandler.kt | 7 +- .../DefaultTokenDetailsDeepLinkHandlerTest.kt | 6 - features/wallet/impl/build.gradle.kts | 1 - .../wallet/child/wallet/model/WalletModel.kt | 20 +- .../model/intents/TangemPayClickIntents.kt | 7 +- .../preview/WalletScreenPreviewDataLegacy.kt | 7 - .../WalletTangemPayAnalyticsEventSender.kt | 31 ++- .../wallet/domain/WalletContentFetcher.kt | 12 +- .../wallet/state/model/TangemPayState.kt | 49 ----- .../wallet/state/model/WalletState.kt | 6 - .../transformers/AddWalletTransformer.kt | 2 - .../InitializeWalletsTransformer.kt | 2 - .../ReinitializeNewWalletTransformer.kt | 2 - .../ReinitializeWalletTransformer.kt | 2 - .../TangemPayExposedDeviceTransformer.kt | 22 --- .../TangemPayHiddenStateTransformer.kt | 23 --- ...TangemPayHideOnboardingStateTransformer.kt | 3 +- .../TangemPayLoadingStateTransformer.kt | 20 -- ...ngemPayOnboardingBannerStateTransformer.kt | 30 --- .../TangemPayRefreshNeededStateTransformer.kt | 39 ---- ...TangemPayRefreshShowProgressTransformer.kt | 11 +- .../TangemPayUnavailableStateTransformer.kt | 28 --- .../TangemPayUpdateInfoStateTransformer.kt | 130 ------------- .../transformers/UnlockWalletTransformer.kt | 4 +- .../state/utils/WalletLoadingStateFactory.kt | 5 - .../subscribers/TangemPayMainSubscriber.kt | 106 ++--------- .../presentation/wallet/ui/WalletScreen.kt | 11 +- .../singlecurrency/TangemPayCardMainBlock.kt | 103 ---------- .../visa/TangemPayExposedDeviceState.kt | 41 ---- .../visa/TangemPayFailedIssueState.kt | 36 ---- .../visa/TangemPayLoadingScreenBlock.kt | 37 ---- .../visa/TangemPayMainScreenBlock.kt | 106 ----------- .../visa/TangemPayOnboardingBanner.kt | 120 ------------ .../components/visa/TangemPayProgressState.kt | 35 ---- .../components/visa/TangemPayRefreshBlock.kt | 79 -------- .../components/visa/TangemUnavailableBlock.kt | 76 -------- 56 files changed, 82 insertions(+), 1491 deletions(-) create mode 100644 data/visa/src/main/kotlin/com/tangem/data/pay/util/OrderStatusConverter.kt delete mode 100644 domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/TangemPayState.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayExposedDeviceTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHiddenStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayLoadingStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayOnboardingBannerStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshNeededStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUnavailableStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUpdateInfoStateTransformer.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayExposedDeviceState.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayFailedIssueState.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayLoadingScreenBlock.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayOnboardingBanner.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayProgressState.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayRefreshBlock.kt delete mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemUnavailableBlock.kt diff --git a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json index d4053a9ee6..c161b3d49d 100644 --- a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json +++ b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json @@ -27,10 +27,6 @@ "name": "GASLESS_APPROVAL_ENABLED", "version": "5.37" }, - { - "name": "TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED", - "version": "5.37" - }, { "name": "DYNAMIC_ADDRESSES_ENABLED", "version": "undefined" diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/pay/models/response/ReissueCardResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/pay/models/response/ReissueCardResponse.kt index 49fb34198e..4b173d08f3 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/pay/models/response/ReissueCardResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/pay/models/response/ReissueCardResponse.kt @@ -10,6 +10,6 @@ data class ReissueCardResponse( @JsonClass(generateAdapter = true) data class Result( @Json(name = "order_id") val orderId: String, - @Json(name = "status") val status: String, + @Json(name = "status") val status: OrderResponse.Result.Status, ) } \ No newline at end of file diff --git a/data/account/build.gradle.kts b/data/account/build.gradle.kts index 9f3fa0d8a4..9e1cd33fea 100644 --- a/data/account/build.gradle.kts +++ b/data/account/build.gradle.kts @@ -36,8 +36,6 @@ dependencies { api(projects.domain.visa) // endregion - implementation(projects.features.tangempay.details.api) // Remove after TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED - // region Project - Data implementation(projects.data.common) // endregion diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountListProducer.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountListProducer.kt index 28fd5fd6be..fcad8c9615 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountListProducer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountListProducer.kt @@ -11,7 +11,6 @@ import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.account.Account import com.tangem.domain.models.wallet.UserWallet -import com.tangem.features.tangempay.TangemPayFeatureToggles import com.tangem.hot.sdk.model.HotWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider import dagger.assisted.Assisted @@ -36,7 +35,6 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor( @Assisted val params: SingleAccountListProducer.Params, override val flowProducerTools: FlowProducerTools, private val walletAccountListFlowFactory: WalletAccountListFlowFactory, - private val tangemPayFeatureToggles: TangemPayFeatureToggles, private val userWalletsListRepository: UserWalletsListRepository, private val dispatchers: CoroutineDispatcherProvider, ) : SingleAccountListProducer { @@ -45,16 +43,6 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor( @OptIn(ExperimentalCoroutinesApi::class) override fun produce(): Flow { - val accountListFlow: Flow = if (tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled) { - combineWithPaymentAccount() - } else { - walletAccountListFlowFactory.create(userWalletId = params.userWalletId) - } - - return accountListFlow.flowOn(dispatchers.default) - } - - private fun combineWithPaymentAccount(): Flow { return walletAccountListFlowFactory.create(params.userWalletId) .map { accountList -> val userWallet = userWalletsListRepository.getSyncStrict(id = params.userWalletId) @@ -66,6 +54,7 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor( accountList } } + .flowOn(dispatchers.default) } private fun UserWallet.isPaymentAccountSupported(): Boolean = when (this) { diff --git a/data/account/src/test/java/com/tangem/data/account/producer/DefaultSingleAccountListProducerTest.kt b/data/account/src/test/java/com/tangem/data/account/producer/DefaultSingleAccountListProducerTest.kt index 4837e4f2a6..d4138d111c 100644 --- a/data/account/src/test/java/com/tangem/data/account/producer/DefaultSingleAccountListProducerTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/producer/DefaultSingleAccountListProducerTest.kt @@ -8,7 +8,7 @@ import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.TokensSortType import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.features.tangempay.TangemPayFeatureToggles +import com.tangem.hot.sdk.model.HotWalletId import com.tangem.test.core.getEmittedValues import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* @@ -31,21 +31,22 @@ class DefaultSingleAccountListProducerTest { private val userWalletId = UserWalletId("011") private val flowProducerTools: FlowProducerTools = mockk() - private val tangemPayFeatureToggles = mockk { - every { this@mockk.isTangemPayAccountsRefactorEnabled } returns false + private val userWallet = mockk { + every { walletId } returns userWalletId + every { hotWalletId } returns mockk { + every { authType } returns HotWalletId.AuthType.NoPassword + } } - private val userWalletsListRepository = mockk() - private val userWallet = mockk { - every { this@mockk.walletId } returns userWalletId + private val userWalletsListRepository = mockk { + every { userWallets } returns MutableStateFlow?>(value = listOf(userWallet)) } private val producer = DefaultSingleAccountListProducer( params = SingleAccountListProducer.Params(userWalletId = userWalletId), walletAccountListFlowFactory = walletAccountListFlowFactory, - dispatchers = TestingCoroutineDispatcherProvider(), flowProducerTools = flowProducerTools, - tangemPayFeatureToggles = tangemPayFeatureToggles, userWalletsListRepository = userWalletsListRepository, + dispatchers = TestingCoroutineDispatcherProvider(), ) @AfterEach @@ -56,8 +57,6 @@ class DefaultSingleAccountListProducerTest { @Test fun produce() = runTest { // Arrange - MutableStateFlow(listOf(userWallet)) - val accountList = AccountList.empty(userWalletId) every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList) diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt index 97394190aa..3187eeba11 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt @@ -11,7 +11,6 @@ import com.tangem.data.pay.converter.PaymentAccountStatusValueDMConverter import com.tangem.data.pay.flow.DefaultPaymentAccountStatusFetcher import com.tangem.data.pay.flow.DefaultPaymentAccountStatusProducer import com.tangem.data.pay.repository.* -import com.tangem.domain.pay.repository.TangemPayReissueCardRepository import com.tangem.data.pay.store.PaymentAccountStatusesStore import com.tangem.data.pay.usecase.DefaultGetTangemPayCurrencyStatusUseCase import com.tangem.data.pay.usecase.DefaultGetTangemPayCustomerIdUseCase @@ -30,12 +29,10 @@ import com.tangem.domain.pay.repository.* import com.tangem.domain.pay.usecase.GetPaymentAccountCryptoCurrencyStatusUseCase import com.tangem.domain.pay.usecase.ProduceTangemPayInitialDataUseCase import com.tangem.domain.pay.usecase.SetTangemPayCardLimitUseCase -import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase import com.tangem.domain.tangempay.GetTangemPayCurrencyStatusUseCase import com.tangem.domain.tangempay.GetTangemPayCustomerIdUseCase import com.tangem.domain.tangempay.TangemPayWithdrawUseCase import com.tangem.domain.tangempay.repository.TangemPayTxHistoryRepository -import com.tangem.security.DeviceSecurityInfoProvider import com.tangem.utils.coroutines.AppCoroutineScope import com.tangem.utils.coroutines.CoroutineDispatcherProvider import dagger.Binds @@ -167,23 +164,6 @@ internal interface TangemPayDataModule { return GetPaymentAccountCryptoCurrencyStatusUseCase(paymentAccountStatusSupplier) } - @Provides - @Singleton - fun provideTangemPayMainScreenCustomerInfoUseCase( - repository: OnboardingRepository, - customerOrderRepository: CustomerOrderRepository, - tangemPayOnboardingRepository: OnboardingRepository, - eligibilityManager: TangemPayEligibilityManager, - deviceSecurity: DeviceSecurityInfoProvider, - ): TangemPayMainScreenCustomerInfoUseCase { - return TangemPayMainScreenCustomerInfoUseCase( - onboardingRepository = repository, - customerOrderRepository = customerOrderRepository, - eligibilityManager = eligibilityManager, - deviceSecurity = deviceSecurity, - ) - } - @Provides @Singleton fun provideProduceTangemPayInitialDataUseCase( diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/flow/DefaultPaymentAccountStatusFetcher.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/flow/DefaultPaymentAccountStatusFetcher.kt index b9bfca6812..a278b0a4dd 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/flow/DefaultPaymentAccountStatusFetcher.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/flow/DefaultPaymentAccountStatusFetcher.kt @@ -11,8 +11,8 @@ import com.tangem.domain.models.account.PaymentAccountStatusValue import com.tangem.domain.models.kyc.KycStatus import com.tangem.domain.models.pay.TangemPayCard import com.tangem.domain.models.pay.TangemPayCardLimitData -import com.tangem.domain.pay.TangemPayEligibilityManager import com.tangem.domain.models.wallet.UserWalletId +import com.tangem.domain.pay.TangemPayEligibilityManager import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher import com.tangem.domain.pay.model.CustomerInfo import com.tangem.domain.pay.model.OrderData @@ -188,7 +188,6 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor( when (orderData.status) { OrderStatus.CANCELED -> handleCanceledOrder(account, orderData) OrderStatus.COMPLETED -> handleCompletedOrder(account) - OrderStatus.UNKNOWN -> PaymentAccountStatusValue.Error.Unavailable OrderStatus.NEW, OrderStatus.PROCESSING, -> { @@ -228,7 +227,6 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor( OrderStatus.COMPLETED -> return handleCompletedOrder(account) OrderStatus.NEW, OrderStatus.PROCESSING, - OrderStatus.UNKNOWN, -> Unit // Continue polling } }, diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultCustomerOrderRepository.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultCustomerOrderRepository.kt index 8cc392d6ed..8871a7d804 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultCustomerOrderRepository.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultCustomerOrderRepository.kt @@ -1,8 +1,8 @@ package com.tangem.data.pay.repository import arrow.core.Either +import com.tangem.data.pay.util.OrderStatusConverter import com.tangem.datasource.api.pay.TangemPayApi -import com.tangem.datasource.api.pay.models.response.OrderResponse import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.pay.model.OrderData import com.tangem.domain.pay.model.OrderStatus @@ -19,13 +19,7 @@ internal class DefaultCustomerOrderRepository @Inject constructor( return requestHelper.performRequest(userWalletId) { authHeader -> tangemPayApi.getOrder(authHeader = authHeader, orderId = orderId) }.map { response -> - val status = when (response.result?.status) { - null -> OrderStatus.PROCESSING - OrderResponse.Result.Status.NEW -> OrderStatus.NEW - OrderResponse.Result.Status.PROCESSING -> OrderStatus.PROCESSING - OrderResponse.Result.Status.COMPLETED -> OrderStatus.COMPLETED - OrderResponse.Result.Status.CANCELED -> OrderStatus.CANCELED - } + val status = response.result?.status?.let(OrderStatusConverter::convert) ?: OrderStatus.PROCESSING OrderData( customerId = response.result?.customerId.orEmpty(), status = status, diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultReissueCardRepository.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultReissueCardRepository.kt index b6ee3b4b76..0e85fa2f63 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultReissueCardRepository.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultReissueCardRepository.kt @@ -4,6 +4,7 @@ import arrow.core.Either import arrow.core.raise.either import arrow.core.right import com.tangem.core.error.UniversalError +import com.tangem.data.pay.util.OrderStatusConverter import com.tangem.datasource.api.pay.TangemPayApi import com.tangem.datasource.api.pay.models.request.ReissueCardRequest import com.tangem.datasource.api.pay.models.response.OrderResponse @@ -59,8 +60,10 @@ internal class DefaultReissueCardRepository @Inject constructor( body = ReissueCardRequest(cardId = cardId), ) }.bind() - - TangemPayReissueOrderInfo(response.result.orderId, OrderStatus.fromString(response.result.status)) + TangemPayReissueOrderInfo( + orderId = response.result.orderId, + orderStatus = OrderStatusConverter.convert(response.result.status), + ) } override suspend fun storeReissueOrderId(cardId: String, orderId: String): Either = diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/util/OrderStatusConverter.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/util/OrderStatusConverter.kt new file mode 100644 index 0000000000..2c143fd252 --- /dev/null +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/util/OrderStatusConverter.kt @@ -0,0 +1,16 @@ +package com.tangem.data.pay.util + +import com.tangem.datasource.api.pay.models.response.OrderResponse +import com.tangem.domain.pay.model.OrderStatus +import com.tangem.utils.converter.Converter + +internal object OrderStatusConverter : Converter { + override fun convert(value: OrderResponse.Result.Status): OrderStatus { + return when (value) { + OrderResponse.Result.Status.PROCESSING -> OrderStatus.PROCESSING + OrderResponse.Result.Status.COMPLETED -> OrderStatus.COMPLETED + OrderResponse.Result.Status.NEW -> OrderStatus.NEW + OrderResponse.Result.Status.CANCELED -> OrderStatus.CANCELED + } + } +} \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcher.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcher.kt index ccaee70b62..8f43d68f33 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcher.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcher.kt @@ -1,7 +1,6 @@ package com.tangem.domain.tokens.wallet import arrow.core.Either -import arrow.core.right import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.tokens.CardCryptoCurrencyFactory import com.tangem.domain.common.wallets.UserWalletsListRepository @@ -147,18 +146,10 @@ class WalletBalanceFetcher internal constructor( fetchExpressAssets(userWallet = userWallet, currencies = currencies) - fetcher.fetch( - userWalletId = userWalletId, - currencies = currencies, - paymentAccountRefactorEnabled = params.isPaymentAccountRefactorEnabled, - ) + fetcher.fetch(userWalletId = userWalletId, currencies = currencies) } - private suspend fun BaseWalletBalanceFetcher.fetch( - userWalletId: UserWalletId, - currencies: Set, - paymentAccountRefactorEnabled: Boolean, - ) { + private suspend fun BaseWalletBalanceFetcher.fetch(userWalletId: UserWalletId, currencies: Set) { coroutineScope { // Fetch balance sources in parallel val balanceErrors = fetchingSources.filterIsInstance() @@ -182,7 +173,7 @@ class WalletBalanceFetcher internal constructor( // Fetch TangemPay separately — may run long-polling, so it must not block balance error checking if (fetchingSources.any { it is WalletFetchingSource.TangemPay }) { - fetchPaymentAccount(userWalletId, paymentAccountRefactorEnabled) + paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) } } } @@ -197,19 +188,10 @@ class WalletBalanceFetcher internal constructor( expressServiceFetcher.fetch(userWallet = userWallet, assetIds = assetIds) } - private suspend fun fetchPaymentAccount( - userWalletId: UserWalletId, - paymentAccountRefactorEnabled: Boolean, - ): Either { - if (!paymentAccountRefactorEnabled) return Unit.right() - - return paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) - } - /** * Params of [WalletBalanceFetcher] * * @property userWalletId user wallet id */ - data class Params(val userWalletId: UserWalletId, val isPaymentAccountRefactorEnabled: Boolean) + data class Params(val userWalletId: UserWalletId) } \ No newline at end of file diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcherTest.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcherTest.kt index c3ab25891d..a345573819 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcherTest.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/wallet/WalletBalanceFetcherTest.kt @@ -96,7 +96,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -133,7 +132,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -171,7 +169,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -209,7 +206,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -260,7 +256,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -315,7 +310,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -376,7 +370,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -428,7 +421,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -479,7 +471,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -536,7 +527,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -607,7 +597,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -682,7 +671,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -743,7 +731,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -802,7 +789,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) @@ -869,7 +855,6 @@ internal class WalletBalanceFetcherTest { val actual = fetcher( params = WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = false, ), ) diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/OrderStatus.kt b/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/OrderStatus.kt index c304832170..fd3d717107 100644 --- a/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/OrderStatus.kt +++ b/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/OrderStatus.kt @@ -1,22 +1,8 @@ package com.tangem.domain.pay.model -import java.util.Locale - enum class OrderStatus { - UNKNOWN, // TODO remove it after TangemPay accounts refactor TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED NEW, PROCESSING, COMPLETED, CANCELED, - ; - - companion object { - fun fromString(value: String) = when (value.uppercase(Locale.US)) { - "NEW" -> NEW - "PROCESSING" -> PROCESSING - "COMPLETED" -> COMPLETED - "CANCELED" -> CANCELED - else -> UNKNOWN - } - } } \ No newline at end of file diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt b/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt deleted file mode 100644 index 04780f63c1..0000000000 --- a/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt +++ /dev/null @@ -1,179 +0,0 @@ -package com.tangem.domain.pay.usecase - -import arrow.core.Either -import arrow.core.left -import arrow.core.right -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.domain.pay.TangemPayEligibilityManager -import com.tangem.domain.pay.model.* -import com.tangem.domain.pay.repository.CustomerOrderRepository -import com.tangem.domain.pay.repository.OnboardingRepository -import com.tangem.domain.visa.error.VisaApiError -import com.tangem.security.DeviceSecurityInfoProvider -import com.tangem.security.isSecurityExposed -import com.tangem.utils.logging.TangemLogger -import kotlinx.coroutines.flow.* - -class TangemPayMainScreenCustomerInfoUseCase( - private val onboardingRepository: OnboardingRepository, - private val customerOrderRepository: CustomerOrderRepository, - private val eligibilityManager: TangemPayEligibilityManager, - private val deviceSecurity: DeviceSecurityInfoProvider, -) { - - val state: StateFlow>> - field = MutableStateFlow(value = mapOf()) - - private val logger = TangemLogger.withTag("TangemPayMainScreenCustomerInfoUseCase") - - suspend fun fetch(userWalletId: UserWalletId) { - logger.i("fetch: ${userWalletId.stringValue}") - - if (onboardingRepository.isTangemPayDeactivated(userWalletId)) { - updateState(userWalletId, MainCustomerInfoContentState.Empty.right()) - return - } - - if (deviceSecurity.isSecurityExposed()) { - logger.i("fetch security info: rooted: ${deviceSecurity.isRooted}") - logger.i("fetch security info: xposed: ${deviceSecurity.isXposed}") - logger.i("fetch security info: bootloader unlocked: ${deviceSecurity.isBootloaderUnlocked}") - - updateState(userWalletId = userWalletId, either = TangemPayCustomerInfoError.ExposedDeviceError.left()) - return // fast exit - } - - onboardingRepository.hasTangemPayInWallet(userWalletId) - .fold( - ifLeft = { error -> - logger.e("Failed checkCustomerWallet for $userWalletId: ${error.javaClass.simpleName}") - if (error is VisaApiError.NotPaeraCustomer) { - showOnboardingBannerIfEligible(userWalletId) - } else { - updateState(userWalletId, TangemPayCustomerInfoError.UnknownError.left()) - } - }, - ifRight = { hasTangemPay -> - logger.i("checkCustomerWallet for $userWalletId: $hasTangemPay") - if (hasTangemPay) { - val oldResult = state.value[userWalletId] - if (oldResult == null) { - updateState(userWalletId, MainCustomerInfoContentState.Loading.right()) - } - - val result = proceedWithPaeraCustomerResult(userWalletId) - if (result.leftOrNull() is TangemPayCustomerInfoError.DeactivatedError) { - updateState(userWalletId, MainCustomerInfoContentState.Empty.right()) - return - } - updateState(userWalletId, result.map(MainCustomerInfoContentState::Content)) - } else { - // if there's no tangem pay, check eligibility and show onboarding banner - showOnboardingBannerIfEligible(userWalletId) - } - }, - ) - } - - private suspend fun showOnboardingBannerIfEligible(userWalletId: UserWalletId) { - val tangemPayEntryPoint = TangemPayEntryPoint.BANNER - if (eligibilityManager.isPaeraCustomerForAnyWallet(tangemPayEntryPoint)) { - updateState(userWalletId, MainCustomerInfoContentState.Empty.right()) - return - } - val isEligible = eligibilityManager - .getEligibleWallets( - shouldExcludePaeraCustomers = false, - entryPoint = tangemPayEntryPoint, - ) - .any { it.walletId == userWalletId } - if (isEligible) { - if (onboardingRepository.getHideMainOnboardingBanner(userWalletId)) { - updateState(userWalletId, MainCustomerInfoContentState.Empty.right()) - } else { - updateState(userWalletId, MainCustomerInfoContentState.OnboardingBanner.right()) - } - } else { - updateState(userWalletId, MainCustomerInfoContentState.Empty.right()) - } - } - - operator fun invoke( - userWalletId: UserWalletId, - ): Flow> { - return state.mapNotNull { map -> map[userWalletId] } - } - - private fun updateState( - userWalletId: UserWalletId, - either: Either, - ) { - state.update { currentMap -> - currentMap.toMutableMap().apply { this[userWalletId] = either } - } - } - - private suspend fun proceedWithPaeraCustomerResult( - userWalletId: UserWalletId, - ): Either { - if (!onboardingRepository.isTangemPayInitialDataProduced(userWalletId)) { - return TangemPayCustomerInfoError.RefreshNeededError.left() - } - val orderId = onboardingRepository.getOrderId(userWalletId) - return if (orderId != null) { - proceedWithOrderId(userWalletId = userWalletId, orderId = orderId) - } else { - proceedWithoutOrder(userWalletId = userWalletId) - } - } - - private suspend fun proceedWithoutOrder( - userWalletId: UserWalletId, - ): Either { - return onboardingRepository.getCustomerInfo(userWalletId) - .mapLeft { error -> - logger.e("mapErrorForCustomer: $error") - error.mapErrorForCustomer() - } - .map { customerInfo -> - logger.i("customerInfo") - if (customerInfo.productInstance == null) { - onboardingRepository.createOrder(userWalletId) - MainScreenCustomerInfo(info = customerInfo, orderStatus = OrderStatus.NEW) - } else { - MainScreenCustomerInfo(info = customerInfo, orderStatus = OrderStatus.COMPLETED) - } - } - } - - private suspend fun proceedWithOrderId( - userWalletId: UserWalletId, - orderId: String, - ): Either { - return customerOrderRepository.getOrderData(userWalletId, orderId = orderId) - .fold( - ifLeft = { error -> - error.mapErrorForCustomer().left() - }, - ifRight = { orderData -> - if (orderData.status in setOf(OrderStatus.COMPLETED, OrderStatus.UNKNOWN)) { - onboardingRepository.clearOrderId(userWalletId) - } - onboardingRepository.getCustomerInfo(userWalletId = userWalletId) - .mapLeft { it.mapErrorForCustomer() } - .map { customerInfo -> - MainScreenCustomerInfo(info = customerInfo, orderStatus = orderData.status) - } - }, - ) - } - - private fun VisaApiError.mapErrorForCustomer(): TangemPayCustomerInfoError { - return when (this) { - is VisaApiError.RefreshTokenExpired -> TangemPayCustomerInfoError.RefreshNeededError - is VisaApiError.NotPaeraCustomer -> TangemPayCustomerInfoError.UnknownError - is VisaApiError.Deactivated -> TangemPayCustomerInfoError.DeactivatedError - else -> TangemPayCustomerInfoError.UnavailableError - } - } -} \ No newline at end of file diff --git a/features/details/impl/build.gradle.kts b/features/details/impl/build.gradle.kts index d188416da8..e86fe43d33 100644 --- a/features/details/impl/build.gradle.kts +++ b/features/details/impl/build.gradle.kts @@ -19,7 +19,6 @@ dependencies { implementation(projects.features.disclaimer.api) implementation(projects.features.tester.api) implementation(projects.features.createWalletSelection.api) - implementation(projects.features.tangempay.details.api) implementation(projects.features.onboardingV2.api) /* Project - Core */ diff --git a/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/TangemPayFeatureToggles.kt b/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/TangemPayFeatureToggles.kt index 0f2ae969eb..aca7d9b879 100644 --- a/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/TangemPayFeatureToggles.kt +++ b/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/TangemPayFeatureToggles.kt @@ -1,5 +1,3 @@ package com.tangem.features.tangempay -interface TangemPayFeatureToggles { - val isTangemPayAccountsRefactorEnabled: Boolean -} \ No newline at end of file +interface TangemPayFeatureToggles \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/DefaultTangemPayFeatureToggles.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/DefaultTangemPayFeatureToggles.kt index a46d768445..e8a0c42caf 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/DefaultTangemPayFeatureToggles.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/DefaultTangemPayFeatureToggles.kt @@ -1,11 +1,3 @@ package com.tangem.features.tangempay -import com.tangem.core.configtoggle.FeatureToggles -import com.tangem.core.configtoggle.feature.FeatureTogglesManager - -internal class DefaultTangemPayFeatureToggles( - private val featureTogglesManager: FeatureTogglesManager, -) : TangemPayFeatureToggles { - override val isTangemPayAccountsRefactorEnabled - get() = featureTogglesManager.isFeatureEnabled(FeatureToggles.TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED) -} \ No newline at end of file +internal class DefaultTangemPayFeatureToggles : TangemPayFeatureToggles \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/di/TangemPayDetailsModule.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/di/TangemPayDetailsModule.kt index a6ea142d28..6f0b9ea597 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/di/TangemPayDetailsModule.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/di/TangemPayDetailsModule.kt @@ -1,6 +1,5 @@ package com.tangem.features.tangempay.di -import com.tangem.core.configtoggle.feature.FeatureTogglesManager import com.tangem.features.tangempay.DefaultTangemPayFeatureToggles import com.tangem.features.tangempay.TangemPayFeatureToggles import dagger.Module @@ -15,7 +14,7 @@ internal object TangemPayDetailsModule { @Provides @Singleton - fun provideTangemPayFeatureToggles(featureTogglesManager: FeatureTogglesManager): TangemPayFeatureToggles { - return DefaultTangemPayFeatureToggles(featureTogglesManager) + fun provideTangemPayFeatureToggles(): TangemPayFeatureToggles { + return DefaultTangemPayFeatureToggles() } } \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayCardPageModel.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayCardPageModel.kt index 5bee5538b2..59b353136e 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayCardPageModel.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayCardPageModel.kt @@ -303,7 +303,7 @@ internal class TangemPayCardPageModel @Inject constructor( private fun onReissueOrderStatusReceived(orderStatus: OrderStatus) { when (orderStatus) { - OrderStatus.NEW, OrderStatus.PROCESSING, OrderStatus.COMPLETED, OrderStatus.UNKNOWN -> { + OrderStatus.NEW, OrderStatus.PROCESSING, OrderStatus.COMPLETED -> { uiState.update { state -> state.copy( addToWalletBlockState = null, diff --git a/features/tokendetails/impl/build.gradle.kts b/features/tokendetails/impl/build.gradle.kts index 379ae600f2..d538fa28d5 100644 --- a/features/tokendetails/impl/build.gradle.kts +++ b/features/tokendetails/impl/build.gradle.kts @@ -111,7 +111,6 @@ dependencies { implementation(projects.features.sendV2.api) implementation(projects.features.tokenRecieve.api) implementation(projects.features.yieldSupply.api) - implementation(projects.features.tangempay.details.api) implementation(deps.decompose.ext.compose) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt index d912665f4e..e9ee88d2bd 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt @@ -23,7 +23,6 @@ import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.GetUserWalletUseCase import com.tangem.domain.wallets.usecase.SelectWalletUseCase import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents -import com.tangem.features.tangempay.TangemPayFeatureToggles import com.tangem.features.tokendetails.deeplink.TokenDetailsDeepLinkHandler import com.tangem.features.wallet.deeplink.WalletDeepLinkActionTrigger import com.tangem.utils.logging.TangemLogger @@ -47,7 +46,6 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor( private val getUserWalletUseCase: GetUserWalletUseCase, private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase, private val walletBalanceFetcher: WalletBalanceFetcher, - private val tangemPayFeatureToggles: TangemPayFeatureToggles, private val singleAccountListSupplier: SingleAccountListSupplier, ) : TokenDetailsDeepLinkHandler { @@ -133,10 +131,7 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor( currency = cryptoCurrency, ) !isMultiCurrency -> walletBalanceFetcher( - params = WalletBalanceFetcher.Params( - userWalletId = userWallet.walletId, - isPaymentAccountRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, - ), + params = WalletBalanceFetcher.Params(userWalletId = userWallet.walletId), ) } } diff --git a/features/tokendetails/impl/src/test/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandlerTest.kt b/features/tokendetails/impl/src/test/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandlerTest.kt index 4be98e40a0..079ec97e5a 100644 --- a/features/tokendetails/impl/src/test/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandlerTest.kt +++ b/features/tokendetails/impl/src/test/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandlerTest.kt @@ -25,7 +25,6 @@ import com.tangem.domain.wallets.models.GetUserWalletError import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.GetUserWalletUseCase import com.tangem.domain.wallets.usecase.SelectWalletUseCase -import com.tangem.features.tangempay.TangemPayFeatureToggles import com.tangem.features.wallet.deeplink.WalletDeepLinkActionTrigger import com.tangem.utils.logging.TangemLogger import io.mockk.* @@ -50,7 +49,6 @@ class DefaultTokenDetailsDeepLinkHandlerTest { private val analyticsEventHandler: AnalyticsEventHandler = mockk() private val getUserWalletUseCase: GetUserWalletUseCase = mockk() private val walletBalanceFetcher: WalletBalanceFetcher = mockk() - private val tangemPayFeatureToggles: TangemPayFeatureToggles = mockk() private val singleAccountListSupplier: SingleAccountListSupplier = mockk() @BeforeEach @@ -443,12 +441,10 @@ class DefaultTokenDetailsDeepLinkHandlerTest { userWalletId = userWalletId, cryptoCurrencies = listOf(expectedCryptoCurrency), ) - every { tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled } returns true coEvery { walletBalanceFetcher.invoke( WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = true ) ) } returns mockk() @@ -460,7 +456,6 @@ class DefaultTokenDetailsDeepLinkHandlerTest { walletBalanceFetcher.invoke( WalletBalanceFetcher.Params( userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = true ) ) } @@ -483,7 +478,6 @@ class DefaultTokenDetailsDeepLinkHandlerTest { analyticsEventHandler = analyticsEventHandler, getUserWalletUseCase = getUserWalletUseCase, walletBalanceFetcher = walletBalanceFetcher, - tangemPayFeatureToggles = tangemPayFeatureToggles, singleAccountListSupplier = singleAccountListSupplier, getSelectedWalletSyncUseCase = getSelectedWalletSync, ) diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index 83c646bcc9..0f05b2b6c7 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -147,7 +147,6 @@ dependencies { implementation(projects.features.kyc.api) implementation(projects.features.tokenRecieve.api) implementation(projects.features.yieldSupply.api) - implementation(projects.features.tangempay.details.api) implementation(projects.features.feed.api) implementation(projects.features.promoBanners.api) implementation(projects.features.tangempay.main.api) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index da57b17d4e..6bc6f97a27 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -14,12 +14,13 @@ import com.tangem.core.decompose.model.Model import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.ui.utils.parseBigDecimal import com.tangem.datasource.local.appsflyer.AppsFlyerStore -import com.tangem.domain.account.supplier.SingleAccountListSupplier import com.tangem.domain.account.status.usecase.IsAccountsModeEnabledUseCase +import com.tangem.domain.account.supplier.SingleAccountListSupplier import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.apptheme.GetAppThemeModeUseCase import com.tangem.domain.apptheme.model.AppThemeMode +import com.tangem.domain.assetsdiscovery.usecase.StartAssetsDiscoveryUseCase import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase import com.tangem.domain.common.wallets.UserWalletsListRepository import com.tangem.domain.models.wallet.* @@ -27,7 +28,6 @@ import com.tangem.domain.notifications.GetIsHuaweiDeviceWithoutGoogleServicesUse import com.tangem.domain.notifications.repository.NotificationsRepository import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher import com.tangem.domain.pay.repository.OnboardingRepository -import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase import com.tangem.domain.qrscanning.models.ClassifiedQrContent import com.tangem.domain.qrscanning.models.QrResultSource import com.tangem.domain.qrscanning.models.QrSendTarget @@ -38,8 +38,6 @@ import com.tangem.domain.settings.* import com.tangem.domain.tokens.RefreshMultiCurrencyWalletQuotesUseCase import com.tangem.domain.walletconnect.WcPairService import com.tangem.domain.walletconnect.model.WcPairRequest -import com.tangem.domain.assetsdiscovery.usecase.StartAssetsDiscoveryUseCase -import com.tangem.features.hotwallet.HotWalletFeatureToggles import com.tangem.domain.wallets.usecase.* import com.tangem.domain.yield.supply.usecase.YieldSupplyApyUpdateUseCase import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents @@ -62,15 +60,15 @@ import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSend import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.KycRejectedCallbacks import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider import com.tangem.features.biometry.AskBiometryComponent +import com.tangem.features.hotwallet.HotWalletFeatureToggles import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks -import com.tangem.features.tangempay.TangemPayFeatureToggles import com.tangem.features.wallet.deeplink.WalletDeepLinkActionListener import com.tangem.utils.Provider import com.tangem.utils.coroutines.* +import com.tangem.utils.logging.TangemLogger import kotlinx.coroutines.* import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.* -import com.tangem.utils.logging.TangemLogger import javax.inject.Inject private const val TANGEM_PAY_UPDATE_INTERVAL = 60_000L @@ -108,7 +106,6 @@ internal class WalletModel @Inject constructor( private val userWalletsListRepository: UserWalletsListRepository, private val yieldSupplyApyUpdateUseCase: YieldSupplyApyUpdateUseCase, private val tangemPayOnboardingRepository: OnboardingRepository, - private val tangemPayMainScreenCustomerInfoUseCase: TangemPayMainScreenCustomerInfoUseCase, private val getAppThemeModeUseCase: GetAppThemeModeUseCase, private val trackingContextProxy: TrackingContextProxy, private val singleAccountListSupplier: SingleAccountListSupplier, @@ -121,7 +118,6 @@ internal class WalletModel @Inject constructor( private val wcPairService: WcPairService, private val resolveQrSendTargetsUseCase: ResolveQrSendTargetsUseCase, private val paymentAccountStatusFetcher: PaymentAccountStatusFetcher, - private val tangemPayFeatureToggles: TangemPayFeatureToggles, private val uiMessageSender: UiMessageSender, private val hotWalletFeatureToggles: HotWalletFeatureToggles, private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase, @@ -436,17 +432,14 @@ internal class WalletModel @Inject constructor( if (isShouldLaunchPeriodicUpdate) { updateTangemPayJobHolder.cancel() modelScope.launch { - tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) while (isActive) { delay(TANGEM_PAY_UPDATE_INTERVAL) - tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) } }.saveIn(updateTangemPayJobHolder) } else { // Don't refresh customer info periodically if the card was already issued, only update on swipe to refresh - tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) } }.launchIn(modelScope) @@ -555,7 +548,6 @@ internal class WalletModel @Inject constructor( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, ), ) @@ -602,7 +594,6 @@ internal class WalletModel @Inject constructor( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, ), ) } @@ -624,7 +615,6 @@ internal class WalletModel @Inject constructor( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, ), ) } @@ -639,7 +629,6 @@ internal class WalletModel @Inject constructor( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, ), ) @@ -701,7 +690,6 @@ internal class WalletModel @Inject constructor( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, ), ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/TangemPayClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/TangemPayClickIntents.kt index efa8fe4574..5f01821a79 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/TangemPayClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/TangemPayClickIntents.kt @@ -22,11 +22,10 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.pay.TangemPayDetailsConfig import com.tangem.domain.pay.TangemPayEligibilityManager -import com.tangem.domain.pay.model.TangemPayEntryPoint import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher +import com.tangem.domain.pay.model.TangemPayEntryPoint import com.tangem.domain.pay.repository.OnboardingRepository import com.tangem.domain.pay.usecase.ProduceTangemPayInitialDataUseCase -import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase import com.tangem.domain.tangempay.TangemPayAnalyticsEvents import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController import com.tangem.feature.wallet.presentation.wallet.state.model.WalletDialogConfig @@ -72,7 +71,6 @@ internal class TangemPayClickIntentsImplementor @Inject constructor( private val produceInitialDataTangemPay: ProduceTangemPayInitialDataUseCase, private val getWalletMetainfoUseCase: GetWalletMetaInfoUseCase, private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase, - private val tangemPayMainScreenCustomerInfoUseCase: TangemPayMainScreenCustomerInfoUseCase, private val tangemPayOnboardingRepository: OnboardingRepository, private val tangemPayEligibilityManager: TangemPayEligibilityManager, private val uiMessageSender: UiMessageSender, @@ -85,7 +83,6 @@ internal class TangemPayClickIntentsImplementor @Inject constructor( if (!onboardingRepository.isTangemPayInitialDataProduced(userWalletId)) { return } - tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) } @@ -100,7 +97,6 @@ internal class TangemPayClickIntentsImplementor @Inject constructor( modelScope.launch { produceInitialDataTangemPay.invoke(userWallet.walletId) .onRight { - tangemPayMainScreenCustomerInfoUseCase.fetch(userWallet.walletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWallet.walletId)) } .onLeft { @@ -277,7 +273,6 @@ internal class TangemPayClickIntentsImplementor @Inject constructor( modelScope.launch { tangemPayOnboardingRepository.disableTangemPay(userWalletId) .onRight { - tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) paymentAccountStatusFetcher.invoke(PaymentAccountStatusFetcher.Params(userWalletId)) } .onLeft { uiMessageSender.send(ToastMessage(resourceReference(R.string.common_something_went_wrong))) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewDataLegacy.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewDataLegacy.kt index bbdd063032..c8d1027107 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewDataLegacy.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewDataLegacy.kt @@ -217,15 +217,8 @@ internal object WalletScreenPreviewDataLegacy { isFlickering = false, onItemClick = { }, ), - tangemPayState = TangemPayState.Card( - lastFourDigits = stringReference("*1234"), - balanceText = stringReference("$10"), - balanceSymbol = stringReference("USDC"), - onClick = {}, - ), type = WalletType.Cold, tangemPayMainUM = TangemPayMainUM.Empty, - isTangemPayRefactorEnabled = false, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletTangemPayAnalyticsEventSender.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletTangemPayAnalyticsEventSender.kt index a54705233c..beb32f4027 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletTangemPayAnalyticsEventSender.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletTangemPayAnalyticsEventSender.kt @@ -2,9 +2,7 @@ package com.tangem.feature.wallet.presentation.wallet.analytics.utils import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.decompose.di.ModelScoped -import com.tangem.domain.models.kyc.KycStatus -import com.tangem.domain.pay.model.MainScreenCustomerInfo -import com.tangem.domain.pay.model.OrderStatus +import com.tangem.domain.models.account.PaymentAccountStatusValue import com.tangem.domain.tangempay.TangemPayAnalyticsEvents import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider import javax.inject.Inject @@ -15,26 +13,23 @@ internal class WalletTangemPayAnalyticsEventSender @Inject constructor( private val screenLifecycleProvider: ScreenLifecycleProvider, ) { - private val sentEvents = mutableSetOf() + private val sentEvents = mutableSetOf() - fun send(customerInfo: MainScreenCustomerInfo) { + fun send(statusValue: PaymentAccountStatusValue) { if (screenLifecycleProvider.isBackgroundState.value) return - val cardInfo = customerInfo.info.cardInfo - val productInstance = customerInfo.info.productInstance - - // TODO: TangemPay refactor analytics - // when statement copied from TangemPayUpdateInfoStateTransformer. Be careful when editing - val event = when { - // ignore cancelled state on analytics - customerInfo.orderStatus == OrderStatus.CANCELED -> return - // ignore kyc not approved state on analytics - customerInfo.info.kycStatus != KycStatus.APPROVED -> return - cardInfo != null && productInstance != null -> return - else -> TangemPayAnalyticsEvents.IssuingBannerDisplayed() + val event = when (statusValue) { + is PaymentAccountStatusValue.IssuingCard -> TangemPayAnalyticsEvents.IssuingBannerDisplayed() + PaymentAccountStatusValue.Empty, + is PaymentAccountStatusValue.Error, + is PaymentAccountStatusValue.Loaded, + PaymentAccountStatusValue.Loading, + PaymentAccountStatusValue.NotCreated, + is PaymentAccountStatusValue.UnderReview, + -> return } - if (sentEvents.add(event)) { + if (sentEvents.add(event.id)) { analyticsEventHandler.send(event) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletContentFetcher.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletContentFetcher.kt index b4cae53df1..c6b203e64d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletContentFetcher.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletContentFetcher.kt @@ -2,16 +2,15 @@ package com.tangem.feature.wallet.presentation.wallet.domain import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.tokens.wallet.WalletBalanceFetcher -import com.tangem.features.tangempay.TangemPayFeatureToggles import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.coroutines.JobHolder import com.tangem.utils.coroutines.saveInAndJoin +import com.tangem.utils.logging.TangemLogger import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withContext -import com.tangem.utils.logging.TangemLogger import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import javax.inject.Singleton @@ -28,7 +27,6 @@ import javax.inject.Singleton internal class WalletContentFetcher @Inject constructor( private val walletBalanceFetcher: WalletBalanceFetcher, private val dispatchers: CoroutineDispatcherProvider, - private val tangemPayFeatureToggles: TangemPayFeatureToggles, ) { private val fetchingJobMap = ConcurrentHashMap() @@ -66,12 +64,8 @@ internal class WalletContentFetcher @Inject constructor( TangemLogger.d("Start fetching for $userWalletId") val maybeResult = launch { - walletBalanceFetcher( - params = WalletBalanceFetcher.Params( - userWalletId = userWalletId, - isPaymentAccountRefactorEnabled = tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled, - ), - ).onLeft { TangemLogger.e("Error", it) } + walletBalanceFetcher(params = WalletBalanceFetcher.Params(userWalletId = userWalletId)) + .onLeft { TangemLogger.e("Error", it) } } .saveInAndJoin(jobHolder) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/TangemPayState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/TangemPayState.kt deleted file mode 100644 index 4eae554a24..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/TangemPayState.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.model - -import androidx.annotation.DrawableRes -import androidx.compose.runtime.Immutable -import com.tangem.core.ui.extensions.TextReference - -@Immutable -internal sealed class TangemPayState { - - object Empty : TangemPayState() - - data object Loading : TangemPayState() - - data class OnboardingBanner( - val onClick: () -> Unit, - val closeOnClick: () -> Unit, - ) : TangemPayState() - - data class Progress( - val title: TextReference, - val description: TextReference, - val buttonText: TextReference, - @DrawableRes val iconRes: Int, - val onButtonClick: () -> Unit, - val showProgress: Boolean = false, - ) : TangemPayState() - - data class FailedIssue( - val title: TextReference, - val description: TextReference, - @DrawableRes val iconRes: Int, - val onButtonClick: () -> Unit, - ) : TangemPayState() - - data class Card( - val lastFourDigits: TextReference, - val balanceText: TextReference, - val balanceSymbol: TextReference, - val onClick: () -> Unit, - ) : TangemPayState() - - data class RefreshNeeded( - val notification: WalletNotification, - ) : TangemPayState() - - data class TemporaryUnavailable(val notification: WalletNotification) : TangemPayState() - - data object ExposedDevice : TangemPayState() -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt index 82b4da90cc..6ee912f8fc 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt @@ -24,9 +24,7 @@ internal sealed interface WalletState : WalletStateHolder { abstract val tokensListState: WalletTokensListState abstract val nftState: WalletNFTItemUM abstract val type: WalletType - abstract val tangemPayState: TangemPayState abstract val tangemPayMainUM: TangemPayMainUM - abstract val isTangemPayRefactorEnabled: Boolean // TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED abstract val assetsDiscoveryProgressUM: AssetsDiscoveryProgressUM data class Content( @@ -38,9 +36,7 @@ internal sealed interface WalletState : WalletStateHolder { override val tokensListState: WalletTokensListState, override val nftState: WalletNFTItemUM, override val type: WalletType, - override val tangemPayState: TangemPayState, override val tangemPayMainUM: TangemPayMainUM, - override val isTangemPayRefactorEnabled: Boolean, override val assetsDiscoveryProgressUM: AssetsDiscoveryProgressUM = AssetsDiscoveryProgressUM.Idle, ) : MultiCurrency() @@ -60,9 +56,7 @@ internal sealed interface WalletState : WalletStateHolder { override val tokensListState = WalletTokensListState.ContentState.Locked override val nftState: WalletNFTItemUM = WalletNFTItemUM.Hidden - override val tangemPayState: TangemPayState = TangemPayState.Empty override val tangemPayMainUM: TangemPayMainUM = TangemPayMainUM.Empty - override val isTangemPayRefactorEnabled: Boolean = false override val assetsDiscoveryProgressUM: AssetsDiscoveryProgressUM = AssetsDiscoveryProgressUM.Idle } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/AddWalletTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/AddWalletTransformer.kt index 7cba602ffb..ec3d6943be 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/AddWalletTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/AddWalletTransformer.kt @@ -13,7 +13,6 @@ internal class AddWalletTransformer( private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) : WalletScreenStateTransformer { private val walletLoadingStateFactory by lazy { @@ -21,7 +20,6 @@ internal class AddWalletTransformer( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt index fe74c26c2b..a9774d2e2d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt @@ -27,7 +27,6 @@ internal class InitializeWalletsTransformer( private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) : WalletScreenStateTransformer { private val walletLoadingStateFactory by lazy { @@ -35,7 +34,6 @@ internal class InitializeWalletsTransformer( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeNewWalletTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeNewWalletTransformer.kt index ed1b3a1b10..0c1b198d0c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeNewWalletTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeNewWalletTransformer.kt @@ -24,7 +24,6 @@ internal class ReinitializeNewWalletTransformer( private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) : WalletScreenStateTransformer { private val walletLoadingStateFactory by lazy { @@ -32,7 +31,6 @@ internal class ReinitializeNewWalletTransformer( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeWalletTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeWalletTransformer.kt index 00a8977b27..6dab085776 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeWalletTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/ReinitializeWalletTransformer.kt @@ -20,7 +20,6 @@ internal class ReinitializeWalletTransformer( private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) : WalletStateTransformer(userWalletId = userWallet.walletId) { private val walletLoadingStateFactory by lazy { @@ -28,7 +27,6 @@ internal class ReinitializeWalletTransformer( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayExposedDeviceTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayExposedDeviceTransformer.kt deleted file mode 100644 index cd344f9f4f..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayExposedDeviceTransformer.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayExposedDeviceTransformer( - userWalletId: UserWalletId, -) : WalletStateTransformer(userWalletId) { - override fun transform(prevState: WalletState): WalletState { - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = TangemPayState.ExposedDevice) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHiddenStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHiddenStateTransformer.kt deleted file mode 100644 index bbb5035c07..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHiddenStateTransformer.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayHiddenStateTransformer( - userWalletId: UserWalletId, -) : WalletStateTransformer(userWalletId) { - - override fun transform(prevState: WalletState): WalletState { - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = TangemPayState.Empty) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHideOnboardingStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHideOnboardingStateTransformer.kt index 9997dc0bcb..a25a960e0b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHideOnboardingStateTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayHideOnboardingStateTransformer.kt @@ -1,7 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.state.transformers import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM import com.tangem.features.tangempay.entity.TangemPayMainUM @@ -12,7 +11,7 @@ internal class TangemPayHideOnboardingStateTransformer( override fun transform(prevState: WalletState): WalletState { return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = TangemPayState.Empty, tangemPayMainUM = TangemPayMainUM.Empty) + prevState.copy(tangemPayMainUM = TangemPayMainUM.Empty) } else { prevState } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayLoadingStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayLoadingStateTransformer.kt deleted file mode 100644 index 6404796e7d..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayLoadingStateTransformer.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayLoadingStateTransformer(userWalletId: UserWalletId) : WalletStateTransformer(userWalletId) { - override fun transform(prevState: WalletState): WalletState { - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = TangemPayState.Loading) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayOnboardingBannerStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayOnboardingBannerStateTransformer.kt deleted file mode 100644 index 4659e5f486..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayOnboardingBannerStateTransformer.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayOnboardingBannerStateTransformer( - userWalletId: UserWalletId, - private val onClick: (UserWalletId) -> Unit, - private val closeOnClick: (UserWalletId) -> Unit, -) : WalletStateTransformer(userWalletId) { - - override fun transform(prevState: WalletState): WalletState { - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy( - tangemPayState = TangemPayState.OnboardingBanner( - onClick = { onClick(userWalletId) }, - closeOnClick = { closeOnClick(userWalletId) }, - ), - ) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshNeededStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshNeededStateTransformer.kt deleted file mode 100644 index b8673b8774..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshNeededStateTransformer.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.domain.models.wallet.UserWallet -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.impl.R -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification.Warning.TangemPayRefreshNeeded -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayRefreshNeededStateTransformer( - userWalletId: UserWalletId, - private val userWallet: UserWallet, - private val onRefreshClick: () -> Unit, -) : WalletStateTransformer(userWalletId = userWalletId) { - - override fun transform(prevState: WalletState): WalletState { - val tangemPayState = TangemPayState.RefreshNeeded( - notification = TangemPayRefreshNeeded( - buttonText = when (userWallet) { - is UserWallet.Cold -> resourceReference(id = R.string.home_button_scan) - is UserWallet.Hot -> resourceReference(id = R.string.tangempay_sync_needed_restore_access) - }, - onRefreshClick = onRefreshClick, - shouldShowProgress = false, - ), - ) - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = tangemPayState) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshShowProgressTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshShowProgressTransformer.kt index 17ff78b37f..77158bdb99 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshShowProgressTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayRefreshShowProgressTransformer.kt @@ -1,7 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.state.transformers import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM @@ -14,9 +13,6 @@ internal class TangemPayRefreshShowProgressTransformer( override fun transform(prevState: WalletState): WalletState { val multiContentState = prevState as? WalletState.MultiCurrency.Content ?: return prevState - val refreshNeededState = multiContentState.tangemPayState as? TangemPayState.RefreshNeeded ?: return prevState - val refreshNotification = - refreshNeededState.notification as? WalletNotification.Warning.TangemPayRefreshNeeded ?: return prevState val newWarnings = prevState.warnings.map { warning -> if (warning is WalletNotification.Warning.TangemPayRefreshNeeded) { warning.copy(shouldShowProgress = shouldShowProgress) @@ -25,12 +21,7 @@ internal class TangemPayRefreshShowProgressTransformer( } } - return multiContentState.copy( - tangemPayState = refreshNeededState.copy( - notification = refreshNotification.copy(shouldShowProgress = shouldShowProgress), - ), - warnings = newWarnings.toImmutableList(), - ) + return multiContentState.copy(warnings = newWarnings.toImmutableList()) } override fun transform(walletUM: WalletUM): WalletUM { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUnavailableStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUnavailableStateTransformer.kt deleted file mode 100644 index 5b2a7765a9..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUnavailableStateTransformer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM - -internal class TangemPayUnavailableStateTransformer( - userWalletId: UserWalletId, -) : WalletStateTransformer(userWalletId) { - - override fun transform(prevState: WalletState): WalletState { - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy( - tangemPayState = TangemPayState.TemporaryUnavailable( - notification = WalletNotification.Warning.TangemPayUnreachable, - ), - ) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUpdateInfoStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUpdateInfoStateTransformer.kt deleted file mode 100644 index 238c8a36f1..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayUpdateInfoStateTransformer.kt +++ /dev/null @@ -1,130 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.state.transformers - -import com.tangem.common.ui.R -import com.tangem.core.ui.extensions.TextReference -import com.tangem.core.ui.extensions.stringReference -import com.tangem.core.ui.format.bigdecimal.fiat -import com.tangem.core.ui.format.bigdecimal.format -import com.tangem.domain.models.kyc.KycStatus -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.domain.pay.TangemPayDetailsConfig -import com.tangem.domain.pay.model.CustomerInfo.CardInfo -import com.tangem.domain.pay.model.CustomerInfo.ProductInstance -import com.tangem.domain.pay.model.MainScreenCustomerInfo -import com.tangem.domain.pay.model.OrderStatus -import com.tangem.domain.visa.model.TangemPayCardFrozenState -import com.tangem.feature.wallet.child.wallet.model.intents.TangemPayIntents -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState.Progress -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM -import java.util.Currency - -/** - * Hardcode Polygon chain id only for F&F. - * Later chain id will be fetched from BFF. - */ -private const val POLYGON_CHAIN_ID = 137 - -internal class TangemPayUpdateInfoStateTransformer( - userWalletId: UserWalletId, - private val value: MainScreenCustomerInfo, - private val cardFrozenState: TangemPayCardFrozenState, - private val tangemPayClickIntents: TangemPayIntents, -) : WalletStateTransformer(userWalletId = userWalletId) { - - override fun transform(prevState: WalletState): WalletState { - val tangemPayState = createInitialState() - return if (prevState is WalletState.MultiCurrency.Content) { - prevState.copy(tangemPayState = tangemPayState) - } else { - prevState - } - } - - override fun transform(walletUM: WalletUM): WalletUM { - return walletUM // todo redesign main - } - - private fun createInitialState(): TangemPayState { - val cardInfo = value.info.cardInfo - val productInstance = value.info.productInstance - val customerId = value.info.customerId ?: "Unknown" - - // when statement copied to WalletTangemPayAnalyticsEventSender. Be careful when editing. - return when { - value.info.kycStatus != KycStatus.APPROVED && !value.info.customerId.isNullOrEmpty() -> - createKycInProgressState(kycStatus = value.info.kycStatus, customerId = customerId) - value.orderStatus == OrderStatus.CANCELED -> createCancelledState(customerId) - cardInfo != null && productInstance != null && value.orderStatus == OrderStatus.COMPLETED -> - getCardInfoState(customerId, cardInfo, productInstance) - else -> createIssueProgressState() - } - } - - private fun getCardInfoState( - customerId: String, - cardInfo: CardInfo, - productInstance: ProductInstance, - ): TangemPayState = TangemPayState.Card( - lastFourDigits = TextReference.Str("*${cardInfo.lastFourDigits}"), - balanceText = TextReference.Str(getBalanceText(cardInfo)), - balanceSymbol = stringReference("USDC"), // TODO hardcode for now - onClick = { - tangemPayClickIntents.openDetails( - userWalletId, - TangemPayDetailsConfig( - customerId = customerId, - cardId = productInstance.cardId, - isPinSet = cardInfo.isPinSet, - cardFrozenState = cardFrozenState, - cardNumberEnd = cardInfo.lastFourDigits, - chainId = POLYGON_CHAIN_ID, - displayName = productInstance.displayName, - ), - ) - }, - ) - - private fun getBalanceText(cardInfo: CardInfo): String { - val currency = Currency.getInstance(cardInfo.currencyCode) - return cardInfo.balance.format { - fiat(fiatCurrencyCode = currency.currencyCode, fiatCurrencySymbol = currency.symbol) - } - } - - private fun createKycInProgressState(kycStatus: KycStatus, customerId: String): TangemPayState = Progress( - title = TextReference.Res(R.string.tangempay_payment_account), - description = when (kycStatus) { - KycStatus.REJECTED -> TextReference.Res(R.string.tangempay_kyc_has_failed) - else -> TextReference.Res(R.string.tangempay_kyc_in_progress) - }, - buttonText = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_button), - iconRes = R.drawable.ic_promo_kyc_36, - onButtonClick = { - when (kycStatus) { - KycStatus.REJECTED -> tangemPayClickIntents.onKycRejectedClicked( - userWalletId = userWalletId, - customerId = customerId, - ) - else -> tangemPayClickIntents.onKycProgressClicked(userWalletId) - } - }, - ) - - private fun createIssueProgressState(): TangemPayState = Progress( - title = TextReference.Res(R.string.tangempay_payment_account), - description = TextReference.Res(R.string.tangempay_issuing_your_card), - buttonText = TextReference.EMPTY, - iconRes = R.drawable.ic_tangem_pay_promo_card_36, - onButtonClick = tangemPayClickIntents::onIssuingCardClicked, - showProgress = true, - ) - - private fun createCancelledState(customerId: String): TangemPayState = TangemPayState.FailedIssue( - title = TextReference.Res(R.string.tangempay_payment_account), - description = TextReference.Res(R.string.tangempay_failed_to_issue_card), - iconRes = R.drawable.ic_alert_24, - onButtonClick = { tangemPayClickIntents.onIssuingFailedClicked(customerId) }, - ) -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/UnlockWalletTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/UnlockWalletTransformer.kt index 6e44868ca7..d80feaec8e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/UnlockWalletTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/UnlockWalletTransformer.kt @@ -9,16 +9,15 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenSta import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory +import com.tangem.utils.logging.TangemLogger import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toPersistentList -import com.tangem.utils.logging.TangemLogger internal class UnlockWalletTransformer( private val unlockedWallets: List, private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) : WalletScreenStateTransformer { private val walletLoadingStateFactory by lazy { @@ -26,7 +25,6 @@ internal class UnlockWalletTransformer( clickIntents = clickIntents, walletImageResolver = walletImageResolver, getWalletIconUseCase = getWalletIconUseCase, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt index 1b1be5d304..1140b80dd0 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt @@ -34,7 +34,6 @@ internal class WalletLoadingStateFactory( private val clickIntents: WalletClickIntents, private val walletImageResolver: WalletImageResolver, private val getWalletIconUseCase: GetWalletIconUseCase, - private val isTangemPayRefactorEnabled: Boolean, ) { fun create(userWallet: UserWallet): WalletState { @@ -83,9 +82,7 @@ internal class WalletLoadingStateFactory( tokensListState = WalletTokensListState.ContentState.Loading, nftState = WalletNFTItemUM.Hidden, type = WalletType.Hot, - tangemPayState = TangemPayState.Empty, tangemPayMainUM = TangemPayMainUM.Empty, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } @@ -99,9 +96,7 @@ internal class WalletLoadingStateFactory( tokensListState = WalletTokensListState.ContentState.Loading, nftState = WalletNFTItemUM.Hidden, type = WalletType.Cold, - tangemPayState = TangemPayState.Empty, tangemPayMainUM = TangemPayMainUM.Empty, - isTangemPayRefactorEnabled = isTangemPayRefactorEnabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/TangemPayMainSubscriber.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/TangemPayMainSubscriber.kt index a800e1a2a7..e58aa664f5 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/TangemPayMainSubscriber.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/TangemPayMainSubscriber.kt @@ -1,122 +1,38 @@ package com.tangem.feature.wallet.presentation.wallet.subscribers import com.tangem.domain.models.wallet.UserWallet -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.domain.pay.model.MainCustomerInfoContentState -import com.tangem.domain.pay.model.MainScreenCustomerInfo -import com.tangem.domain.pay.model.TangemPayCustomerInfoError -import com.tangem.domain.pay.repository.TangemPayCardDetailsRepository +import com.tangem.domain.pay.flow.PaymentAccountStatusSupplier import com.tangem.domain.pay.repository.TangemPayWithdrawRepository -import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase -import com.tangem.domain.visa.model.TangemPayCardFrozenState -import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletTangemPayAnalyticsEventSender -import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController -import com.tangem.feature.wallet.presentation.wallet.state.transformers.* import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch -import com.tangem.utils.logging.TangemLogger -@Suppress("LongParameterList") internal class TangemPayMainSubscriber @AssistedInject constructor( @Assisted private val userWallet: UserWallet, - private val stateController: WalletStateController, - private val clickIntents: WalletClickIntents, - private val cardDetailsRepository: TangemPayCardDetailsRepository, - private val tangemPayMainScreenCustomerInfoUseCase: TangemPayMainScreenCustomerInfoUseCase, private val tangemPayWithdrawRepository: TangemPayWithdrawRepository, + private val paymentAccountStatusSupplier: PaymentAccountStatusSupplier, private val analytics: WalletTangemPayAnalyticsEventSender, ) : WalletSubscriber() { override fun create(coroutineScope: CoroutineScope): Flow<*> { coroutineScope.launch { + // TODO: Doston move this logic to proper place(e.g. WalletBalanceFetcher) tangemPayWithdrawRepository.pollWithdrawOrdersIfNeeds(userWallet) } - return subscribeOnTangemPayInfoUpdates() + subscribeToStatus(coroutineScope) + return emptyFlow() } - private fun subscribeOnTangemPayInfoUpdates(): Flow<*> { - return tangemPayMainScreenCustomerInfoUseCase(userWalletId = userWallet.walletId) + private fun subscribeToStatus(coroutineScope: CoroutineScope) { + paymentAccountStatusSupplier.invoke(userWalletId = userWallet.walletId) + .map { it.value } .distinctUntilChanged() - .onEach { mainInfoData -> - val userWalletId = userWallet.walletId - mainInfoData.onLeft { tangemPayError -> - when (tangemPayError) { - TangemPayCustomerInfoError.RefreshNeededError -> { - stateController.update( - transformer = TangemPayRefreshNeededStateTransformer( - userWalletId = userWalletId, - userWallet = userWallet, - onRefreshClick = { clickIntents.onRefreshPayToken(userWallet) }, - ), - ) - } - TangemPayCustomerInfoError.UnavailableError -> { - stateController.update( - transformer = TangemPayUnavailableStateTransformer(userWalletId), - ) - } - TangemPayCustomerInfoError.ExposedDeviceError -> { - stateController.update(TangemPayExposedDeviceTransformer(userWalletId)) - } - TangemPayCustomerInfoError.DeactivatedError -> { - stateController.update( - transformer = TangemPayHiddenStateTransformer(userWalletId), - ) - } - TangemPayCustomerInfoError.UnknownError -> { - // hide TangemPay block - TangemLogger.e("Failed when loading main screen TangemPay info: $tangemPayError") - stateController.update( - transformer = TangemPayHiddenStateTransformer(userWalletId), - ) - } - } - }.onRight { contentState -> handleContentState(state = contentState) } - } - } - - private suspend fun handleContentState(state: MainCustomerInfoContentState) { - val userWalletId = userWallet.walletId - when (state) { - MainCustomerInfoContentState.Loading -> stateController.update( - transformer = TangemPayLoadingStateTransformer(userWalletId), - ) - is MainCustomerInfoContentState.Content -> { - updateTangemPay(data = state.info, userWalletId = userWalletId) - analytics.send(customerInfo = state.info) - } - is MainCustomerInfoContentState.OnboardingBanner -> stateController.update( - transformer = TangemPayOnboardingBannerStateTransformer( - userWalletId = userWalletId, - onClick = clickIntents::onOnboardingBannerClick, - closeOnClick = clickIntents::onOnboardingBannerCloseClick, - ), - ) - is MainCustomerInfoContentState.Empty -> stateController.update( - transformer = TangemPayHiddenStateTransformer(userWalletId), - ) - } - } - - private suspend fun updateTangemPay(data: MainScreenCustomerInfo, userWalletId: UserWalletId) { - val cardFrozenState = - data.info.productInstance?.cardId?.let { cardDetailsRepository.cardFrozenStateSync(it) } - ?: TangemPayCardFrozenState.Unfrozen - stateController.update( - transformer = TangemPayUpdateInfoStateTransformer( - userWalletId = userWalletId, - value = data, - cardFrozenState = cardFrozenState, - tangemPayClickIntents = clickIntents, - ), - ) + .onEach(analytics::send) + .launchIn(coroutineScope) } @AssistedFactory diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt index 1dcf79012d..23de72403e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt @@ -82,7 +82,6 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.common.* import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.nftCollections import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.organizeTokensButton import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.marketPriceBlock -import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.TangemPayMainScreenBlock import com.tangem.feature.wallet.presentation.wallet.ui.utils.changeWalletAnimator import com.tangem.features.tangempay.component.TangemPayMainBlockComponent import com.tangem.features.tangempay.entity.TangemPayMainUM @@ -752,14 +751,8 @@ internal fun LazyListScope.tangemPayItem( ) { if (state !is WalletState.MultiCurrency) return - if (state.isTangemPayRefactorEnabled) { - with(tangemPayComponent) { - tangemPayMainContent(modifier = modifier, state = state.tangemPayMainUM, isBalanceHidden = isHidingMode) - } - } else { - item(key = "TangemPayMainScreenBlock", contentType = state.tangemPayState::class.java) { - TangemPayMainScreenBlock(modifier = modifier, state = state.tangemPayState, isBalanceHidden = isHidingMode) - } + with(tangemPayComponent) { + tangemPayMainContent(modifier = modifier, state = state.tangemPayMainUM, isBalanceHidden = isHidingMode) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt deleted file mode 100644 index c155df8fd4..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency - -import android.content.res.Configuration -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import com.tangem.common.ui.R -import com.tangem.core.ui.extensions.TextReference -import com.tangem.core.ui.extensions.orMaskWithStars -import com.tangem.core.ui.extensions.resolveReference -import com.tangem.core.ui.extensions.stringResourceSafe -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.TangemPayMainScreenBlock - -@Composable -internal fun TangemPayCardMainBlock( - state: TangemPayState.Card, - isBalanceHidden: Boolean, - modifier: Modifier = Modifier, -) { - Surface( - modifier = modifier.fillMaxWidth(), - shape = TangemTheme.shapes.roundedCornersXMedium, - color = TangemTheme.colors.background.primary, - onClick = state.onClick, - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .height(IntrinsicSize.Min) - .padding(horizontal = 12.dp, vertical = 16.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(12.dp), - ) { - Image( - painter = painterResource(R.drawable.img_visa_36), - contentDescription = null, - modifier = Modifier.size(36.dp), - ) - - Column( - modifier = Modifier.weight(1f), - verticalArrangement = Arrangement.spacedBy(2.dp), - ) { - Text( - text = stringResourceSafe(R.string.tangempay_payment_account), - style = TangemTheme.typography.subtitle2, - color = TangemTheme.colors.text.primary1, - ) - Text( - text = state.lastFourDigits.resolveReference(), - style = TangemTheme.typography.caption2, - color = TangemTheme.colors.text.tertiary, - ) - } - Column( - modifier = Modifier.fillMaxHeight(), - verticalArrangement = Arrangement.spacedBy(2.dp), - horizontalAlignment = Alignment.End, - ) { - Text( - text = state.balanceText.resolveReference().orMaskWithStars(isBalanceHidden), - style = TangemTheme.typography.body2, - color = TangemTheme.colors.text.primary1, - textAlign = TextAlign.End, - ) - Text( - text = state.balanceSymbol.resolveReference(), - style = TangemTheme.typography.caption2, - color = TangemTheme.colors.text.tertiary, - textAlign = TextAlign.End, - ) - } - } - } -} - -@Preview(showBackground = true) -@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun TangemPayCardMainBlockPreview() { - TangemThemePreview { - TangemPayMainScreenBlock( - TangemPayState.Card( - lastFourDigits = TextReference.Str("*1234"), - balanceText = TextReference.Str("$ 0.00"), - balanceSymbol = TextReference.Str("USDC"), - onClick = {}, - ), - isBalanceHidden = false, - ) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayExposedDeviceState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayExposedDeviceState.kt deleted file mode 100644 index 6ba66da79f..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayExposedDeviceState.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.draw.clip -import com.tangem.core.ui.R -import com.tangem.core.ui.components.block.BlockCard -import com.tangem.core.ui.components.inputrow.InputRowImageBase -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.res.TangemTheme - -private const val DISABLED_ALPHA = 0.6F - -@Composable -internal fun TangemPayExposedDeviceState(modifier: Modifier = Modifier) { - BlockCard( - modifier = modifier - .clip(RoundedCornerShape(size = TangemTheme.dimens.radius14)) - .background(TangemTheme.colors.background.primary) - .alpha(DISABLED_ALPHA), - enabled = false, - onClick = {}, - ) { - InputRowImageBase( - modifier = Modifier - .padding( - all = TangemTheme.dimens.spacing12, - ), - subtitle = resourceReference(R.string.tangempay_payment_account), - caption = resourceReference(R.string.tangem_pay_rooted_device_subtitle), - subtitleColor = TangemTheme.colors.text.primary1, - captionColor = TangemTheme.colors.text.tertiary, - iconResWebp = R.drawable.img_visa_36, - endIconTint = TangemTheme.colors.icon.warning, - ) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayFailedIssueState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayFailedIssueState.kt deleted file mode 100644 index df4c7bfafd..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayFailedIssueState.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import com.tangem.core.ui.components.block.BlockCard -import com.tangem.core.ui.components.inputrow.InputRowImageBase -import com.tangem.core.ui.res.TangemTheme -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState - -@Composable -internal fun TangemPayFailedIssueState(state: TangemPayState.FailedIssue, modifier: Modifier = Modifier) { - BlockCard( - modifier = modifier - .clip(RoundedCornerShape(size = TangemTheme.dimens.radius14)) - .background(TangemTheme.colors.background.primary), - onClick = state.onButtonClick, - ) { - InputRowImageBase( - modifier = Modifier - .padding( - all = TangemTheme.dimens.spacing12, - ), - subtitle = state.title, - caption = state.description, - subtitleColor = TangemTheme.colors.text.primary1, - captionColor = TangemTheme.colors.text.tertiary, - iconResWebp = com.tangem.core.ui.R.drawable.img_visa_36, - iconEndRes = state.iconRes, - endIconTint = TangemTheme.colors.icon.warning, - ) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayLoadingScreenBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayLoadingScreenBlock.kt deleted file mode 100644 index a2dbe13375..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayLoadingScreenBlock.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.tangem.core.ui.components.CircleShimmer -import com.tangem.core.ui.components.RectangleShimmer -import com.tangem.core.ui.components.SpacerWMax -import com.tangem.core.ui.res.TangemTheme - -@Composable -internal fun TangemPayLoadingScreenBlock(modifier: Modifier = Modifier) { - Row( - modifier = modifier - .fillMaxWidth() - .background(color = TangemTheme.colors.background.primary, shape = TangemTheme.shapes.roundedCornersXMedium) - .padding(horizontal = 12.dp, vertical = 16.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - CircleShimmer(modifier = Modifier.size(36.dp)) - Column( - modifier = Modifier.padding(start = 12.dp), - verticalArrangement = Arrangement.spacedBy(2.dp), - ) { - RectangleShimmer(modifier = Modifier.padding(vertical = 4.dp).sizeIn(minWidth = 70.dp, minHeight = 12.dp)) - RectangleShimmer(modifier = Modifier.padding(vertical = 2.dp).sizeIn(minWidth = 52.dp, minHeight = 12.dp)) - } - SpacerWMax() - Column(verticalArrangement = Arrangement.spacedBy(2.dp)) { - RectangleShimmer(modifier = Modifier.padding(vertical = 4.dp).sizeIn(minWidth = 40.dp, minHeight = 12.dp)) - RectangleShimmer(modifier = Modifier.padding(vertical = 2.dp).sizeIn(minWidth = 40.dp, minHeight = 12.dp)) - } - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt deleted file mode 100644 index 862b6c770d..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt +++ /dev/null @@ -1,106 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import android.content.res.Configuration -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import com.tangem.common.ui.R -import com.tangem.core.ui.extensions.TextReference -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState.Progress -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification.Warning.TangemPayRefreshNeeded -import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.TangemPayCardMainBlock - -@Composable -internal fun TangemPayMainScreenBlock(state: TangemPayState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) { - when (state) { - is Progress -> TangemPayProgressState(state, modifier) - is TangemPayState.Card -> TangemPayCardMainBlock(state, isBalanceHidden, modifier) - is TangemPayState.Empty -> Unit - is TangemPayState.RefreshNeeded -> TangemPayRefreshBlock(state, modifier) - is TangemPayState.TemporaryUnavailable -> TangemPayUnavailableBlock(state, modifier) - is TangemPayState.FailedIssue -> TangemPayFailedIssueState(state, modifier) - is TangemPayState.OnboardingBanner -> TangemPayOnboardingBanner(state, modifier) - is TangemPayState.ExposedDevice -> TangemPayExposedDeviceState(modifier) - is TangemPayState.Loading -> TangemPayLoadingScreenBlock(modifier) - } -} - -@Preview(showBackground = true) -@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun TangemPayMainScreenBlockPreview() { - TangemThemePreview { - Column(verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8)) { - TangemPayMainScreenBlock(state = TangemPayState.Loading, isBalanceHidden = false) - TangemPayMainScreenBlock( - state = TangemPayState.RefreshNeeded( - TangemPayRefreshNeeded( - buttonText = resourceReference(id = R.string.home_button_scan), - onRefreshClick = {}, - shouldShowProgress = false, - ), - ), - isBalanceHidden = false, - ) - TangemPayMainScreenBlock( - state = TangemPayState.TemporaryUnavailable(WalletNotification.Warning.TangemPayUnreachable), - isBalanceHidden = false, - ) - TangemPayMainScreenBlock( - state = TangemPayState.OnboardingBanner(onClick = {}, closeOnClick = {}), - isBalanceHidden = false, - ) - - TangemPayMainScreenBlock(state = TangemPayState.ExposedDevice, isBalanceHidden = false) - TangemPayMainScreenBlock( - state = TangemPayState.FailedIssue( - title = TextReference.Res(R.string.tangempay_payment_account), - description = TextReference.Res(R.string.tangempay_failed_to_issue_card), - iconRes = R.drawable.ic_alert_24, - onButtonClick = { }, - ), - isBalanceHidden = false, - ) - - TangemPayMainScreenBlock( - Progress( - title = TextReference.Res(R.string.tangempay_payment_account), - description = TextReference.Res(R.string.tangempay_kyc_in_progress), - buttonText = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_button), - iconRes = R.drawable.ic_promo_kyc_36, - onButtonClick = {}, - ), - isBalanceHidden = false, - ) - - TangemPayMainScreenBlock( - Progress( - title = TextReference.Res(R.string.tangempay_payment_account), - description = TextReference.Res(R.string.tangempay_issuing_your_card), - buttonText = TextReference.EMPTY, - iconRes = R.drawable.ic_tangem_pay_promo_card_36, - onButtonClick = {}, - showProgress = true, - ), - isBalanceHidden = false, - ) - - TangemPayMainScreenBlock( - TangemPayState.Card( - lastFourDigits = TextReference.Str("*1234"), - balanceText = TextReference.Str("$ 0.00"), - balanceSymbol = TextReference.Str("USDC"), - onClick = {}, - ), - isBalanceHidden = false, - ) - } - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayOnboardingBanner.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayOnboardingBanner.kt deleted file mode 100644 index d345eede90..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayOnboardingBanner.kt +++ /dev/null @@ -1,120 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import android.content.res.Configuration -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.graphics.Brush -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.constraintlayout.compose.ConstraintLayout -import androidx.constraintlayout.compose.Dimension -import com.tangem.core.ui.components.SpacerH -import com.tangem.core.ui.extensions.stringResourceSafe -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.feature.wallet.impl.R -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState - -private const val GRADIENT_START_COLOR = 0xFF252934 -private const val GRADIENT_END_COLOR = 0xFF12141E -private const val GRADIENT_OFFSET_X = 0f -private const val GRADIENT_OFFSET_Y = 80F -private const val GRADIENT_RADIUS = 200F - -@Composable -internal fun TangemPayOnboardingBanner(state: TangemPayState.OnboardingBanner, modifier: Modifier = Modifier) { - Box( - modifier = modifier - .fillMaxWidth() - .clip(TangemTheme.shapes.roundedCornersXMedium) - .background( - brush = Brush.radialGradient( - colors = listOf(Color(GRADIENT_START_COLOR), Color(GRADIENT_END_COLOR)), - center = Offset(GRADIENT_OFFSET_X, GRADIENT_OFFSET_Y), - radius = GRADIENT_RADIUS, - ), - ) - .clickable(onClick = state.onClick), - ) { - ConstraintLayout( - modifier = Modifier.fillMaxWidth(), - ) { - val (image, text, close) = createRefs() - - Image( - painter = painterResource(R.drawable.ic_close_24), - contentDescription = null, - modifier = Modifier - .size(16.dp) - .clickable(onClick = state.closeOnClick) - .constrainAs(close) { - top.linkTo(parent.top, margin = 16.dp) - end.linkTo(parent.end, margin = 16.dp) - }, - colorFilter = ColorFilter.tint(TangemTheme.colors.icon.inactive), - ) - - Column( - modifier = Modifier - .constrainAs(text) { - top.linkTo(parent.top) - start.linkTo(image.end, margin = 12.dp) - end.linkTo(close.start, margin = 12.dp) - width = Dimension.fillToConstraints - } - .padding(top = 16.dp, bottom = 16.dp), - ) { - Text( - text = stringResourceSafe(R.string.tangempay_onboarding_banner_title), - style = TangemTheme.typography.subtitle2, - color = TangemTheme.colors.text.constantWhite, - ) - - SpacerH(6.dp) - - Text( - text = stringResourceSafe(R.string.tangempay_onboarding_banner_description), - style = TangemTheme.typography.caption2, - color = TangemTheme.colors.text.tertiary, - ) - } - - Image( - painter = painterResource(R.drawable.img_tangem_pay_onboarding_banner), - contentDescription = null, - modifier = Modifier - .padding(top = 8.dp, start = 24.dp) - .constrainAs(image) { - start.linkTo(parent.start) - top.linkTo(text.top) - bottom.linkTo(text.bottom) - height = Dimension.fillToConstraints - }, - ) - } - } -} - -@Preview(showBackground = true) -@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun PreviewTangemOnboardingBanner() { - TangemThemePreview { - TangemPayOnboardingBanner( - TangemPayState.OnboardingBanner( - onClick = {}, - closeOnClick = {}, - ), - ) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayProgressState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayProgressState.kt deleted file mode 100644 index a73e842c3b..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayProgressState.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import com.tangem.core.ui.R -import com.tangem.core.ui.components.block.BlockCard -import com.tangem.core.ui.components.inputrow.InputRowImageBase -import com.tangem.core.ui.res.TangemTheme -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState - -@Composable -internal fun TangemPayProgressState(state: TangemPayState.Progress, modifier: Modifier = Modifier) { - BlockCard( - modifier = modifier - .clip(RoundedCornerShape(size = TangemTheme.dimens.radius14)) - .background(TangemTheme.colors.background.primary), - onClick = state.onButtonClick, - ) { - InputRowImageBase( - modifier = Modifier - .padding( - all = TangemTheme.dimens.spacing12, - ), - subtitle = state.title, - caption = state.description, - subtitleColor = TangemTheme.colors.text.primary1, - captionColor = TangemTheme.colors.text.tertiary, - iconResWebp = R.drawable.img_visa_36, - ) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayRefreshBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayRefreshBlock.kt deleted file mode 100644 index 715a6168a2..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayRefreshBlock.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import android.content.res.Configuration -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.R -import com.tangem.core.ui.components.SpacerH12 -import com.tangem.core.ui.components.block.BlockCard -import com.tangem.core.ui.components.inputrow.InputRowImageBase -import com.tangem.core.ui.components.notifications.Notification -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification.Warning.TangemPayRefreshNeeded - -@Composable -internal fun TangemPayRefreshBlock(state: TangemPayState.RefreshNeeded, modifier: Modifier = Modifier) { - Column(modifier) { - Notification( - config = state.notification.config, - iconTint = when (state.notification) { - is WalletNotification.Critical -> TangemTheme.colors.icon.warning - is WalletNotification.Informational -> TangemTheme.colors.icon.accent - is WalletNotification.RateApp -> TangemTheme.colors.icon.attention - is WalletNotification.UnlockWallets -> TangemTheme.colors.icon.primary1 - is WalletNotification.UsedOutdatedData -> TangemTheme.colors.text.attention - else -> null - }, - ) - SpacerH12() - - BlockCard( - modifier = Modifier - .clip(RoundedCornerShape(size = TangemTheme.dimens.radius14)) - .background(TangemTheme.colors.background.primary), - enabled = false, - ) { - InputRowImageBase( - modifier = Modifier.padding( - all = TangemTheme.dimens.spacing12, - ), - subtitle = resourceReference(R.string.tangempay_payment_account), - caption = resourceReference(R.string.tangempay_payment_account_sync_needed), - subtitleColor = TangemTheme.colors.text.tertiary, - captionColor = TangemTheme.colors.text.tertiary, - iconResWebp = R.drawable.img_visa_36, - ) - } - } -} - -@Preview(showBackground = true) -@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun TangemPayRefreshBlockPreview() { - TangemThemePreview { - Column(verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8)) { - TangemPayRefreshBlock( - state = TangemPayState.RefreshNeeded( - TangemPayRefreshNeeded( - buttonText = resourceReference(id = R.string.tangempay_sync_needed_restore_access), - onRefreshClick = {}, - shouldShowProgress = true, - ), - ), - modifier = Modifier, - ) - } - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemUnavailableBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemUnavailableBlock.kt deleted file mode 100644 index a8628de815..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemUnavailableBlock.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.visa - -import android.content.res.Configuration -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.R -import com.tangem.core.ui.components.SpacerH12 -import com.tangem.core.ui.components.block.BlockCard -import com.tangem.core.ui.components.inputrow.InputRowImageBase -import com.tangem.core.ui.components.notifications.Notification -import com.tangem.core.ui.extensions.TextReference -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState -import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification -import com.tangem.utils.StringsSigns.DASH_SIGN - -@Composable -internal fun TangemPayUnavailableBlock(state: TangemPayState.TemporaryUnavailable, modifier: Modifier = Modifier) { - Column(modifier) { - Notification( - config = state.notification.config, - iconTint = when (state.notification) { - is WalletNotification.Critical -> TangemTheme.colors.icon.warning - is WalletNotification.Informational -> TangemTheme.colors.icon.accent - is WalletNotification.RateApp -> TangemTheme.colors.icon.attention - is WalletNotification.UnlockWallets -> TangemTheme.colors.icon.primary1 - is WalletNotification.UsedOutdatedData -> TangemTheme.colors.text.attention - else -> null - }, - ) - SpacerH12() - - BlockCard( - modifier = Modifier - .clip(RoundedCornerShape(size = TangemTheme.dimens.radius14)) - .background(TangemTheme.colors.background.primary), - enabled = false, - ) { - InputRowImageBase( - modifier = Modifier.padding( - all = TangemTheme.dimens.spacing12, - ), - subtitle = resourceReference(R.string.tangempay_payment_account), - caption = TextReference.Str(DASH_SIGN), - subtitleColor = TangemTheme.colors.text.tertiary, - captionColor = TangemTheme.colors.text.tertiary, - iconResWebp = R.drawable.img_visa_36, - ) - } - } -} - -@Preview(showBackground = true) -@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun TangemPayUnavailableBlockPreview() { - TangemThemePreview { - Column(verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8)) { - TangemPayUnavailableBlock( - state = TangemPayState.TemporaryUnavailable( - WalletNotification.Warning.TangemPayUnreachable, - ), - modifier = Modifier, - ) - } - } -} \ No newline at end of file