diff --git a/app/build.gradle.kts b/app/build.gradle.kts index efe2848d8c..df6d24b384 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,8 +26,11 @@ dependencies { implementation(project(":domain:models")) implementation(project(":domain:core")) implementation(project(":domain:card")) + implementation(project(":domain:wallets")) + implementation(project(":domain:wallets:models")) implementation(project(":common")) implementation(project(":core:analytics")) + implementation(project(":core:navigation")) implementation(project(":core:featuretoggles")) implementation(project(":core:res")) implementation(project(":core:ui")) @@ -52,6 +55,8 @@ dependencies { implementation(project(":features:tester:impl")) implementation(project(":features:wallet:api")) implementation(project(":features:wallet:impl")) + implementation(projects.features.tokendetails.api) + implementation(projects.features.tokendetails.impl) /** AndroidX libraries */ implementation(deps.androidx.core.ktx) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b115140383..53d4be3c7f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -141,7 +141,7 @@ + android:theme="@style/AppTheme" /> R.drawable.ic_terra2_no_color Blockchain.Cronos -> R.drawable.ic_cronos_no_color Blockchain.Telos, Blockchain.TelosTestnet -> R.drawable.ic_telos_no_color + Blockchain.AlephZero, Blockchain.AlephZeroTestnet -> R.drawable.ic_azero_no_color else -> R.drawable.ic_tangem_logo } } diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt b/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt index f45d14c864..9119734bfd 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt @@ -2,10 +2,10 @@ package com.tangem.tap.common.extensions import android.os.Bundle import androidx.fragment.app.* +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.FragmentShareTransition import com.tangem.feature.referral.ReferralFragment import com.tangem.feature.swap.presentation.SwapFragment -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.FragmentShareTransition import com.tangem.tap.features.customtoken.legacy.AddCustomTokenFragment import com.tangem.tap.features.details.ui.appsettings.AppSettingsFragment import com.tangem.tap.features.details.ui.cardsettings.CardSettingsFragment @@ -167,7 +167,18 @@ private fun fragmentFactory(screen: AppScreen): Fragment { } } - AppScreen.WalletDetails -> WalletDetailsFragment() + AppScreen.WalletDetails -> { + val featureToggles = store.state.daggerGraphState.get( + getDependency = DaggerGraphState::tokenDetailsFeatureToggles, + ) + if (featureToggles.isRedesignedScreenEnabled) { + store.state.daggerGraphState + .get(getDependency = DaggerGraphState::tokenDetailsRouter) + .getEntryFragment() + } else { + WalletDetailsFragment() + } + } AppScreen.WalletConnectSessions -> WalletConnectFragment() AppScreen.QrScan -> QrScanFragment() AppScreen.ReferralProgram -> ReferralFragment() diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Store.kt b/app/src/main/java/com/tangem/tap/common/extensions/Store.kt index 8b5eafb76f..8676043cd2 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Store.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Store.kt @@ -1,12 +1,12 @@ package com.tangem.tap.common.extensions +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.withMainContext +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.StateDialog import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.scope import com.tangem.tap.store import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/com/tangem/tap/common/redux/AppState.kt b/app/src/main/java/com/tangem/tap/common/redux/AppState.kt index 4ebc39d1d2..71be2aa020 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/AppState.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/AppState.kt @@ -1,11 +1,11 @@ package com.tangem.tap.common.redux +import com.tangem.core.navigation.NavigationState import com.tangem.domain.redux.DomainState import com.tangem.domain.redux.domainStore import com.tangem.domain.redux.global.NetworkServices import com.tangem.tap.common.redux.global.GlobalMiddleware import com.tangem.tap.common.redux.global.GlobalState -import com.tangem.tap.common.redux.navigation.NavigationState import com.tangem.tap.common.redux.navigation.navigationMiddleware import com.tangem.tap.features.details.redux.DetailsMiddleware import com.tangem.tap.features.details.redux.DetailsState diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt index d599f9c378..2d75cf1723 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt @@ -7,19 +7,15 @@ import com.tangem.common.core.TangemError import com.tangem.datasource.config.ConfigManager import com.tangem.datasource.config.models.ChatConfig import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.tap.common.analytics.topup.TopUpController import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.feedback.FeedbackData import com.tangem.tap.common.feedback.FeedbackManager -import com.tangem.tap.common.redux.DebugErrorAction -import com.tangem.tap.common.redux.ErrorAction -import com.tangem.tap.common.redux.NotificationAction -import com.tangem.tap.common.redux.StateDialog -import com.tangem.tap.common.redux.ToastNotificationAction +import com.tangem.tap.common.redux.* import com.tangem.tap.domain.TapError import com.tangem.tap.domain.configurable.warningMessage.WarningMessage import com.tangem.tap.domain.configurable.warningMessage.WarningMessagesManager -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.features.details.redux.SecurityOption import org.rekotlin.Action diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalState.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalState.kt index 91c1ae14b7..1e5a3cfce0 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalState.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalState.kt @@ -2,13 +2,13 @@ package com.tangem.tap.common.redux.global import com.tangem.datasource.config.ConfigManager import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.tap.common.analytics.topup.TopUpController import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.feedback.FeedbackManager import com.tangem.tap.common.redux.StateDialog import com.tangem.tap.domain.TapWalletManager import com.tangem.tap.domain.configurable.warningMessage.WarningMessagesManager -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.features.onboarding.OnboardingManager import com.tangem.tap.network.exchangeServices.CurrencyExchangeManager import org.rekotlin.StateType diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationMiddleware.kt b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationMiddleware.kt index bf5df6a9a9..6be8513880 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationMiddleware.kt @@ -4,6 +4,8 @@ import android.content.Intent import android.hardware.biometrics.BiometricManager import android.os.Build import android.provider.Settings +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.activityResultCaller import com.tangem.tap.common.CustomTabsManager import com.tangem.tap.common.extensions.dispatchOnMain diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationReducer.kt b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationReducer.kt index 7febcfa59c..ff53145651 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationReducer.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationReducer.kt @@ -1,5 +1,7 @@ package com.tangem.tap.common.redux.navigation +import com.tangem.core.navigation.NavigationAction +import com.tangem.core.navigation.NavigationState import com.tangem.tap.common.extensions.getPreviousScreen import com.tangem.tap.common.redux.AppState import org.rekotlin.Action diff --git a/app/src/main/java/com/tangem/tap/di/AppStateHolderModule.kt b/app/src/main/java/com/tangem/tap/di/AppStateHolderModule.kt new file mode 100644 index 0000000000..05cc610f95 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/di/AppStateHolderModule.kt @@ -0,0 +1,23 @@ +package com.tangem.tap.di + +import com.tangem.core.navigation.NavigationStateHolder +import com.tangem.domain.wallets.legacy.WalletsStateHolder +import com.tangem.tap.proxy.AppStateHolder +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal interface AppStateHolderModule { + + @Binds + @Singleton + fun bindsWalletsStateHolder(appStateHolder: AppStateHolder): WalletsStateHolder + + @Binds + @Singleton + fun bindsNavigationStateHolder(appStateHolder: AppStateHolder): NavigationStateHolder +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/TapWalletManager.kt b/app/src/main/java/com/tangem/tap/domain/TapWalletManager.kt index 4e39b73bbe..23ee5bb963 100644 --- a/app/src/main/java/com/tangem/tap/domain/TapWalletManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/TapWalletManager.kt @@ -11,6 +11,7 @@ import com.tangem.datasource.config.ConfigManager import com.tangem.domain.common.extensions.withMainContext import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.models.UserWallet import com.tangem.operations.attestation.Attestation import com.tangem.tap.* import com.tangem.tap.common.analytics.events.Basic @@ -18,7 +19,6 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchWithMain import com.tangem.tap.common.extensions.setContext import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.walletStores.WalletStoresError import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.features.disclaimer.createDisclaimer diff --git a/app/src/main/java/com/tangem/tap/domain/extensions/WalletManagerFactory.kt b/app/src/main/java/com/tangem/tap/domain/extensions/WalletManagerFactory.kt index 3d65b09b25..7253b1fccf 100644 --- a/app/src/main/java/com/tangem/tap/domain/extensions/WalletManagerFactory.kt +++ b/app/src/main/java/com/tangem/tap/domain/extensions/WalletManagerFactory.kt @@ -1,20 +1,16 @@ package com.tangem.tap.domain.extensions -import com.tangem.blockchain.common.Blockchain -import com.tangem.blockchain.common.DerivationParams -import com.tangem.blockchain.common.DerivationStyle -import com.tangem.blockchain.common.WalletManager -import com.tangem.blockchain.common.WalletManagerFactory +import com.tangem.blockchain.common.* import com.tangem.common.card.EllipticCurve import com.tangem.common.extensions.hexToBytes import com.tangem.common.extensions.toMapKey import com.tangem.crypto.hdWallet.DerivationPath +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.isTestCard import com.tangem.domain.common.TapWorkarounds.useOldStyleDerivation import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.models.Currency fun WalletManagerFactory.makeWalletManagerForApp( diff --git a/app/src/main/java/com/tangem/tap/domain/model/WalletStoreModel.kt b/app/src/main/java/com/tangem/tap/domain/model/WalletStoreModel.kt index 2dad9e1303..99282954dc 100644 --- a/app/src/main/java/com/tangem/tap/domain/model/WalletStoreModel.kt +++ b/app/src/main/java/com/tangem/tap/domain/model/WalletStoreModel.kt @@ -3,9 +3,9 @@ package com.tangem.tap.domain.model import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.WalletManager import com.tangem.crypto.hdWallet.DerivationPath -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.common.BlockchainNetwork +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel.WalletRent -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.models.Currency import java.math.BigDecimal diff --git a/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletBuilder.kt b/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletBuilder.kt index d4e6cbd1fc..7fa72a04fa 100644 --- a/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletBuilder.kt +++ b/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletBuilder.kt @@ -1,11 +1,11 @@ package com.tangem.tap.domain.model.builders +import com.tangem.domain.common.TapWorkarounds.isStart2Coin +import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ProductType import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.common.TapWorkarounds.isStart2Coin -import com.tangem.domain.common.util.cardTypesResolver -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.domain.userWalletList.GetCardImageUseCase class UserWalletBuilder( diff --git a/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletIdBuilder.kt b/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletIdBuilder.kt index 64f5f8156d..30b4ef4407 100644 --- a/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletIdBuilder.kt +++ b/app/src/main/java/com/tangem/tap/domain/model/builders/UserWalletIdBuilder.kt @@ -3,12 +3,12 @@ package com.tangem.tap.domain.model.builders import com.tangem.common.extensions.calculateSha256 import com.tangem.common.extensions.hexToBytes import com.tangem.crypto.Secp256k1 +import com.tangem.domain.common.TapWorkarounds.isTangemTwins +import com.tangem.domain.common.extensions.calculateHmacSha256 import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ProductType import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.common.TapWorkarounds.isTangemTwins -import com.tangem.domain.common.extensions.calculateHmacSha256 -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId class UserWalletIdBuilder private constructor( private val publicKey: ByteArray?, diff --git a/app/src/main/java/com/tangem/tap/domain/model/builders/WalletStoreBuilder.kt b/app/src/main/java/com/tangem/tap/domain/model/builders/WalletStoreBuilder.kt index e7d01ecdb6..81532e5bb9 100644 --- a/app/src/main/java/com/tangem/tap/domain/model/builders/WalletStoreBuilder.kt +++ b/app/src/main/java/com/tangem/tap/domain/model/builders/WalletStoreBuilder.kt @@ -1,18 +1,14 @@ package com.tangem.tap.domain.model.builders import com.tangem.blockchain.blockchains.polkadot.ExistentialDepositProvider -import com.tangem.blockchain.common.Blockchain -import com.tangem.blockchain.common.DerivationStyle -import com.tangem.blockchain.common.Token -import com.tangem.blockchain.common.Wallet -import com.tangem.blockchain.common.WalletManager +import com.tangem.blockchain.common.* import com.tangem.crypto.hdWallet.DerivationPath +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.domain.common.util.cardTypesResolver -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.domain.model.WalletStoreModel -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.redux.reducers.createAddressesData import java.math.BigDecimal diff --git a/app/src/main/java/com/tangem/tap/domain/scanCard/LegacyScanProcessor.kt b/app/src/main/java/com/tangem/tap/domain/scanCard/LegacyScanProcessor.kt index f885b4fa13..e83d2496ff 100644 --- a/app/src/main/java/com/tangem/tap/domain/scanCard/LegacyScanProcessor.kt +++ b/app/src/main/java/com/tangem/tap/domain/scanCard/LegacyScanProcessor.kt @@ -7,6 +7,8 @@ import com.tangem.common.doOnFailure import com.tangem.common.doOnSuccess import com.tangem.core.analytics.Analytics import com.tangem.core.analytics.AnalyticsEvent +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.withMainContext import com.tangem.domain.common.util.twinsIsTwinned import com.tangem.domain.models.scan.ScanResponse @@ -14,8 +16,6 @@ import com.tangem.tap.* import com.tangem.tap.common.analytics.paramsInterceptor.CardContextInterceptor import com.tangem.tap.common.extensions.* import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.disclaimer.createDisclaimer import com.tangem.tap.features.disclaimer.redux.DisclaimerAction import com.tangem.tap.features.disclaimer.redux.DisclaimerCallback diff --git a/app/src/main/java/com/tangem/tap/domain/scanCard/UseCaseScanProcessor.kt b/app/src/main/java/com/tangem/tap/domain/scanCard/UseCaseScanProcessor.kt index 45a463343a..ae4e286e5f 100644 --- a/app/src/main/java/com/tangem/tap/domain/scanCard/UseCaseScanProcessor.kt +++ b/app/src/main/java/com/tangem/tap/domain/scanCard/UseCaseScanProcessor.kt @@ -4,12 +4,12 @@ import arrow.fx.coroutines.resourceScope import com.tangem.common.CompletionResult import com.tangem.common.core.TangemError import com.tangem.core.analytics.AnalyticsEvent +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.card.ScanCardException import com.tangem.domain.models.scan.ScanResponse import com.tangem.tap.DELAY_SDK_DIALOG_CLOSE import com.tangem.tap.common.extensions.dispatchOnMain -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.scanCard.chains.* import com.tangem.tap.domain.scanCard.utils.ScanCardExceptionConverter import com.tangem.tap.preferencesStorage diff --git a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/CheckForOnboardingChain.kt b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/CheckForOnboardingChain.kt index ce46f2f527..baa5c93445 100644 --- a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/CheckForOnboardingChain.kt +++ b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/CheckForOnboardingChain.kt @@ -4,6 +4,7 @@ import arrow.core.Either import arrow.core.left import arrow.core.right import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen import com.tangem.data.source.preferences.PreferencesDataSource import com.tangem.domain.card.ScanCardException import com.tangem.domain.common.util.twinsIsTwinned @@ -15,7 +16,6 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.setContext import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.domain.TapWalletManager import com.tangem.tap.features.onboarding.OnboardingHelper import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsAction diff --git a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/DisclaimerChain.kt b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/DisclaimerChain.kt index b1addc1718..ccf4f495bd 100644 --- a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/DisclaimerChain.kt +++ b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/DisclaimerChain.kt @@ -3,12 +3,12 @@ package com.tangem.tap.domain.scanCard.chains import arrow.core.Either import arrow.core.left import arrow.core.right +import com.tangem.core.navigation.AppScreen import com.tangem.domain.card.ScanCardException import com.tangem.domain.core.chain.Chain import com.tangem.domain.models.scan.ScanResponse import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.features.disclaimer.Disclaimer import com.tangem.tap.features.disclaimer.createDisclaimer import com.tangem.tap.features.disclaimer.redux.DisclaimerAction diff --git a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/ScanChainException.kt b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/ScanChainException.kt index 6709cb8966..588dc809e2 100644 --- a/app/src/main/java/com/tangem/tap/domain/scanCard/chains/ScanChainException.kt +++ b/app/src/main/java/com/tangem/tap/domain/scanCard/chains/ScanChainException.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.scanCard.chains +import com.tangem.core.navigation.AppScreen import com.tangem.domain.card.ScanCardException -import com.tangem.tap.common.redux.navigation.AppScreen sealed class ScanChainException : ScanCardException.ChainException() { diff --git a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt index 69a78dfb46..663e931472 100644 --- a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt +++ b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt @@ -8,16 +8,12 @@ import com.tangem.common.core.CardSessionRunnable import com.tangem.common.core.TangemError import com.tangem.common.core.TangemSdkError import com.tangem.common.deserialization.WalletDataDeserializer -import com.tangem.common.extensions.ByteArrayKey -import com.tangem.common.extensions.guard -import com.tangem.common.extensions.hexToBytes -import com.tangem.common.extensions.toByteArray -import com.tangem.common.extensions.toHexString -import com.tangem.common.extensions.toMapKey +import com.tangem.common.extensions.* import com.tangem.common.tlv.Tlv import com.tangem.common.tlv.TlvDecoder import com.tangem.crypto.CryptoUtils import com.tangem.crypto.hdWallet.DerivationPath +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.isExcluded import com.tangem.domain.common.TapWorkarounds.isNotSupportedInThatRelease import com.tangem.domain.common.TapWorkarounds.isStart2Coin @@ -36,10 +32,10 @@ import com.tangem.operations.issuerAndUserData.ReadIssuerDataCommand import com.tangem.tap.domain.TapSdkError import com.tangem.tap.domain.extensions.getPrimaryCurve import com.tangem.tap.domain.tokens.UserTokensRepository -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.preferencesStorage import com.tangem.tap.scope import kotlinx.coroutines.launch +import kotlin.collections.set class ScanProductTask( val card: Card? = null, diff --git a/app/src/main/java/com/tangem/tap/domain/tokens/UserTokensRepository.kt b/app/src/main/java/com/tangem/tap/domain/tokens/UserTokensRepository.kt index ff7517ff1a..c4c01684bf 100644 --- a/app/src/main/java/com/tangem/tap/domain/tokens/UserTokensRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/tokens/UserTokensRepository.kt @@ -8,10 +8,10 @@ import com.tangem.datasource.api.tangemTech.TangemTechService import com.tangem.datasource.api.tangemTech.models.UserTokensResponse import com.tangem.datasource.connection.NetworkConnectionManager import com.tangem.datasource.files.AndroidFileReader +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.models.scan.CardDTO import com.tangem.tap.domain.model.builders.UserWalletIdBuilder import com.tangem.tap.domain.tokens.converters.CurrencyConverter -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.models.toBlockchainNetworks diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManagerExtensions.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManagerExtensions.kt index b795c7df78..8086bded7c 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManagerExtensions.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManagerExtensions.kt @@ -1,7 +1,8 @@ package com.tangem.tap.domain.userWalletList import com.tangem.common.CompletionResult -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import com.tangem.domain.wallets.models.UserWallet import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerProvider.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerProvider.kt index 71255de6a0..5f02cd1258 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerProvider.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerProvider.kt @@ -5,22 +5,17 @@ import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import com.tangem.common.json.TangemSdkAdapter import com.tangem.common.services.secure.SecureStorage +import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.sdk.storage.AndroidSecureStorage import com.tangem.sdk.storage.createEncryptedSharedPreferences import com.tangem.tap.domain.TangemSdkManager -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.domain.userWalletList.implementation.BiometricUserWalletsListManager import com.tangem.tap.domain.userWalletList.implementation.RuntimeUserWalletsListManager import com.tangem.tap.domain.userWalletList.repository.implementation.BiometricUserWalletsKeysRepository import com.tangem.tap.domain.userWalletList.repository.implementation.DefaultSelectedUserWalletRepository import com.tangem.tap.domain.userWalletList.repository.implementation.DefaultUserWalletsPublicInformationRepository import com.tangem.tap.domain.userWalletList.repository.implementation.DefaultUserWalletsSensitiveInformationRepository -import com.tangem.tap.domain.userWalletList.utils.json.ByteArrayKeyAdapter -import com.tangem.tap.domain.userWalletList.utils.json.CardBackupStatusAdapter -import com.tangem.tap.domain.userWalletList.utils.json.DerivationPathAdapterWithMigration -import com.tangem.tap.domain.userWalletList.utils.json.ExtendedPublicKeysMapAdapter -import com.tangem.tap.domain.userWalletList.utils.json.ScanResponseDerivedKeysMapAdapter -import com.tangem.tap.domain.userWalletList.utils.json.WalletDerivedKeysMapAdapter +import com.tangem.tap.domain.userWalletList.utils.json.* private const val USER_WALLETS_STORAGE_NAME = "user_wallets_storage" diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt index 568d16fc28..18ec89cb9c 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt @@ -2,10 +2,10 @@ package com.tangem.tap.domain.userWalletList.implementation import com.tangem.common.* import com.tangem.common.extensions.guard -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.UserWalletsListError -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey import com.tangem.tap.domain.userWalletList.repository.SelectedUserWalletRepository import com.tangem.tap.domain.userWalletList.repository.UserWalletsKeysRepository diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt index cfcd68bc57..d1cd26b6ff 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt @@ -2,10 +2,10 @@ package com.tangem.tap.domain.userWalletList.implementation import com.tangem.common.CompletionResult import com.tangem.common.catching -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.UserWalletsListError -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.* diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletEncryptionKey.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletEncryptionKey.kt index df0f473bae..d17ee7c4a3 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletEncryptionKey.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletEncryptionKey.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.userWalletList.model import com.squareup.moshi.JsonClass -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId @JsonClass(generateAdapter = true) internal data class UserWalletEncryptionKey( diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt index d81f8ebafc..fe064832d6 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt @@ -3,7 +3,7 @@ package com.tangem.tap.domain.userWalletList.model import com.squareup.moshi.JsonClass import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId @JsonClass(generateAdapter = true) internal data class UserWalletSensitiveInformation( diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/SelectedUserWalletRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/SelectedUserWalletRepository.kt index aee7766d49..61c2a2eec4 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/SelectedUserWalletRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/SelectedUserWalletRepository.kt @@ -1,6 +1,6 @@ package com.tangem.tap.domain.userWalletList.repository -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId internal interface SelectedUserWalletRepository { fun get(): UserWalletId? diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt index 99b62dc99d..08c509a16c 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.userWalletList.repository import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey internal interface UserWalletsKeysRepository { diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsPublicInformationRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsPublicInformationRepository.kt index 8765a6b804..6b40cf721e 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsPublicInformationRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsPublicInformationRepository.kt @@ -1,8 +1,8 @@ package com.tangem.tap.domain.userWalletList.repository import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.model.UserWalletPublicInformation internal interface UserWalletsPublicInformationRepository { diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsSensitiveInformationRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsSensitiveInformationRepository.kt index fdae3e64a0..15d9abbee4 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsSensitiveInformationRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsSensitiveInformationRepository.kt @@ -1,8 +1,8 @@ package com.tangem.tap.domain.userWalletList.repository import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey import com.tangem.tap.domain.userWalletList.model.UserWalletSensitiveInformation diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt index affeeeef57..b8c9ce2bc5 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/BiometricUserWalletsKeysRepository.kt @@ -3,17 +3,12 @@ package com.tangem.tap.domain.userWalletList.repository.implementation import com.squareup.moshi.JsonAdapter import com.squareup.moshi.Moshi import com.squareup.moshi.Types -import com.tangem.common.CompletionResult +import com.tangem.common.* import com.tangem.common.biometric.BiometricManager import com.tangem.common.biometric.BiometricStorage import com.tangem.common.core.TangemSdkError -import com.tangem.common.doOnFailure -import com.tangem.common.flatMapOnFailure -import com.tangem.common.fold -import com.tangem.common.map -import com.tangem.common.mapFailure import com.tangem.common.services.secure.SecureStorage -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.UserWalletsListError import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey import com.tangem.tap.domain.userWalletList.repository.UserWalletsKeysRepository diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultSelectedUserWalletRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultSelectedUserWalletRepository.kt index 6efa84fc70..e30816c98c 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultSelectedUserWalletRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultSelectedUserWalletRepository.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.userWalletList.repository.implementation import com.tangem.common.services.secure.SecureStorage -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.repository.SelectedUserWalletRepository internal class DefaultSelectedUserWalletRepository( diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsPublicInformationRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsPublicInformationRepository.kt index ab64d4a5fb..cadd73b606 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsPublicInformationRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsPublicInformationRepository.kt @@ -7,9 +7,9 @@ import com.tangem.common.CompletionResult import com.tangem.common.catching import com.tangem.common.flatMap import com.tangem.common.services.secure.SecureStorage -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.extensions.replaceByOrAdd -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.userWalletList.model.UserWalletPublicInformation import com.tangem.tap.domain.userWalletList.repository.UserWalletsPublicInformationRepository import com.tangem.tap.domain.userWalletList.utils.publicInformation diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsSensitiveInformationRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsSensitiveInformationRepository.kt index 631d8d13c6..8c67c90889 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsSensitiveInformationRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/implementation/DefaultUserWalletsSensitiveInformationRepository.kt @@ -7,9 +7,9 @@ import com.squareup.moshi.Types import com.tangem.common.CompletionResult import com.tangem.common.catching import com.tangem.common.services.secure.SecureStorage -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.extensions.filterNotNull -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey import com.tangem.tap.domain.userWalletList.model.UserWalletSensitiveInformation import com.tangem.tap.domain.userWalletList.repository.UserWalletsSensitiveInformationRepository diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/utils/Mapper.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/utils/Mapper.kt index 4c7784a50a..4116cde096 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/utils/Mapper.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/utils/Mapper.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.userWalletList.utils -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.userWalletList.model.UserWalletPublicInformation import com.tangem.tap.domain.userWalletList.model.UserWalletSensitiveInformation diff --git a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt index f56949a1be..413550b22e 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.walletCurrencies import com.tangem.common.CompletionResult -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.features.wallet.models.Currency interface WalletCurrenciesManager { diff --git a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/di/WalletCurrenciesManagerProvider.kt b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/di/WalletCurrenciesManagerProvider.kt index 0c6bfccf02..bf2d47611e 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/di/WalletCurrenciesManagerProvider.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/di/WalletCurrenciesManagerProvider.kt @@ -1,11 +1,11 @@ package com.tangem.tap.domain.walletCurrencies.di +import com.tangem.domain.wallets.legacy.WalletManagersRepository import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.domain.tokens.UserTokensRepository import com.tangem.tap.domain.walletCurrencies.WalletCurrenciesManager import com.tangem.tap.domain.walletCurrencies.implementation.DefaultWalletCurrenciesManager import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository fun WalletCurrenciesManager.Companion.provideDefaultImplementation( diff --git a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/implementation/DefaultWalletCurrenciesManager.kt b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/implementation/DefaultWalletCurrenciesManager.kt index 0bbd76b7bc..07e8b8ccf6 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/implementation/DefaultWalletCurrenciesManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/implementation/DefaultWalletCurrenciesManager.kt @@ -2,17 +2,17 @@ package com.tangem.tap.domain.walletCurrencies.implementation import com.tangem.blockchain.common.DerivationStyle import com.tangem.common.* +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.derivationStyle -import com.tangem.domain.common.util.UserWalletId import com.tangem.domain.models.scan.CardDTO +import com.tangem.domain.wallets.legacy.WalletManagersRepository +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.entities.FiatCurrency -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.builders.WalletStoreBuilder import com.tangem.tap.domain.tokens.UserTokensRepository -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.domain.walletCurrencies.WalletCurrenciesManager import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.models.toBlockchainNetworks diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt index 867e75e174..10d89c17eb 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt @@ -2,8 +2,8 @@ package com.tangem.tap.domain.walletStores import com.tangem.blockchain.common.address.AddressType import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.features.wallet.models.Currency import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/di/WalletsStoresManagerProvider.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/di/WalletsStoresManagerProvider.kt index d2a4789fb0..d913969cac 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/di/WalletsStoresManagerProvider.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/di/WalletsStoresManagerProvider.kt @@ -1,12 +1,12 @@ package com.tangem.tap.domain.walletStores.di -import com.tangem.tap.domain.walletStores.WalletStoresManager -import com.tangem.tap.domain.walletStores.implementation.DummyWalletStoresManager +import com.tangem.domain.wallets.legacy.WalletManagersRepository import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.domain.tokens.UserTokensRepository +import com.tangem.tap.domain.walletStores.WalletStoresManager import com.tangem.tap.domain.walletStores.implementation.DefaultWalletStoresManager +import com.tangem.tap.domain.walletStores.implementation.DummyWalletStoresManager import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository fun WalletStoresManager.Companion.provideDummyImplementation(): WalletStoresManager { diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DefaultWalletStoresManager.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DefaultWalletStoresManager.kt index 6081a25788..f2af46b082 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DefaultWalletStoresManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DefaultWalletStoresManager.kt @@ -2,22 +2,17 @@ package com.tangem.tap.domain.walletStores.implementation import com.tangem.blockchain.common.WalletManager import com.tangem.blockchain.common.address.AddressType -import com.tangem.common.CompletionResult -import com.tangem.common.doOnSuccess -import com.tangem.common.flatMap -import com.tangem.common.flatMapOnFailure -import com.tangem.common.fold -import com.tangem.common.map -import com.tangem.domain.common.util.UserWalletId +import com.tangem.common.* +import com.tangem.domain.wallets.legacy.WalletManagersRepository +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.entities.FiatCurrency -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.domain.model.builders.WalletStoreBuilder import com.tangem.tap.domain.tokens.UserTokensRepository import com.tangem.tap.domain.walletStores.WalletStoresError import com.tangem.tap.domain.walletStores.WalletStoresManager import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository import com.tangem.tap.domain.walletStores.repository.implementation.utils.updateSelectedAddress import com.tangem.tap.features.wallet.models.Currency diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DummyWalletStoresManager.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DummyWalletStoresManager.kt index 98fa34d296..9b6ab8abbb 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DummyWalletStoresManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/implementation/DummyWalletStoresManager.kt @@ -2,8 +2,8 @@ package com.tangem.tap.domain.walletStores.implementation import com.tangem.blockchain.common.address.AddressType import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.domain.walletStores.WalletStoresManager import com.tangem.tap.features.wallet.models.Currency diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletAmountsRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletAmountsRepository.kt index 924bbb5191..c25635dd50 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletAmountsRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletAmountsRepository.kt @@ -1,8 +1,8 @@ package com.tangem.tap.domain.walletStores.repository import com.tangem.common.CompletionResult +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.common.entities.FiatCurrency -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletStoreModel interface WalletAmountsRepository { diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletStoresRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletStoresRepository.kt index ad80694e1e..6007fcb2c3 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletStoresRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletStoresRepository.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.walletStores.repository import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.features.wallet.models.Currency import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/di/RepositoryProvider.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/di/RepositoryProvider.kt index d89d4ea6aa..769a1e0219 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/di/RepositoryProvider.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/di/RepositoryProvider.kt @@ -2,8 +2,8 @@ package com.tangem.tap.domain.walletStores.repository.di import com.tangem.blockchain.common.WalletManagerFactory import com.tangem.datasource.api.tangemTech.TangemTechService +import com.tangem.domain.wallets.legacy.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository import com.tangem.tap.domain.walletStores.repository.implementation.DefaultWalletAmountsRepository import com.tangem.tap.domain.walletStores.repository.implementation.DefaultWalletManagersRepository diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletAmountsRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletAmountsRepository.kt index 22dd64bff1..b89be4b97f 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletAmountsRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletAmountsRepository.kt @@ -10,13 +10,13 @@ import com.tangem.blockchain.extensions.Result.Success import com.tangem.common.* import com.tangem.common.core.TangemError import com.tangem.datasource.api.tangemTech.TangemTechApi -import com.tangem.domain.common.util.UserWalletId import com.tangem.domain.common.util.hasDerivation import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.TestActions import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.extensions.replaceByOrAdd -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.domain.walletStores.WalletStoresError import com.tangem.tap.domain.walletStores.repository.WalletAmountsRepository @@ -169,7 +169,7 @@ internal class DefaultWalletAmountsRepository( walletStores.map { walletStore -> async { - // TODO: Find wallet manager via [com.tangem.tap.domain.walletStores.repository.WalletManagersRepository] + // TODO: Find wallet manager via [com.tangem.domain.wallets.legacy.WalletManagersRepository] val walletManager = walletStore.walletManager fetchAmountsForWalletStore(userWalletId, scanResponse, walletStore, walletManager) } diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletManagersRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletManagersRepository.kt index b2d8167a7e..7a51a18e10 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletManagersRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletManagersRepository.kt @@ -1,27 +1,22 @@ package com.tangem.tap.domain.walletStores.repository.implementation -import com.tangem.blockchain.common.Amount -import com.tangem.blockchain.common.Blockchain -import com.tangem.blockchain.common.DerivationParams -import com.tangem.blockchain.common.DerivationStyle -import com.tangem.blockchain.common.WalletManager -import com.tangem.blockchain.common.WalletManagerFactory +import com.tangem.blockchain.common.* import com.tangem.common.CompletionResult import com.tangem.common.catching import com.tangem.common.doOnSuccess import com.tangem.common.mapFailure import com.tangem.crypto.hdWallet.DerivationPath +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.isTestCard import com.tangem.domain.common.TapWorkarounds.useOldStyleDerivation import com.tangem.domain.common.util.cardTypesResolver -import com.tangem.domain.common.util.UserWalletId import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.legacy.WalletManagersRepository +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.extensions.makeWalletManagerForApp -import com.tangem.tap.domain.model.UserWallet -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.domain.walletStores.WalletStoresError -import com.tangem.tap.domain.walletStores.repository.WalletManagersRepository import com.tangem.tap.domain.walletStores.storage.WalletManagerStorage import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.firstOrNull diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletStoresRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletStoresRepository.kt index 89997208ba..fb78960bb1 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletStoresRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/DefaultWalletStoresRepository.kt @@ -2,7 +2,7 @@ package com.tangem.tap.domain.walletStores.repository.implementation import com.tangem.common.CompletionResult import com.tangem.common.catching -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.domain.walletStores.repository.WalletStoresRepository import com.tangem.tap.domain.walletStores.repository.implementation.utils.isSameWalletStore diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/utils/WalletStoreOperations.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/utils/WalletStoreOperations.kt index 069f77fe4b..bc6c07563d 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/utils/WalletStoreOperations.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/repository/implementation/utils/WalletStoreOperations.kt @@ -3,7 +3,7 @@ package com.tangem.tap.domain.walletStores.repository.implementation.utils import com.tangem.blockchain.common.Wallet import com.tangem.blockchain.common.address.AddressType import com.tangem.common.core.TangemError -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.features.wallet.models.Currency import timber.log.Timber diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletManagerStorage.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletManagerStorage.kt index 866711e543..3d492d01da 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletManagerStorage.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletManagerStorage.kt @@ -1,7 +1,7 @@ package com.tangem.tap.domain.walletStores.storage import com.tangem.blockchain.common.WalletManager -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletStoresStorage.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletStoresStorage.kt index 932abce88b..883783db86 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletStoresStorage.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/storage/WalletStoresStorage.kt @@ -1,6 +1,6 @@ package com.tangem.tap.domain.walletStores.storage -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.WalletStoreModel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt index 7b80ce1039..4ba9c2f058 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt @@ -394,7 +394,7 @@ class WalletConnectManager { ), ) } - Analytics.send(WalletConnect.NewSessionEstablished()) + Analytics.send(WalletConnect.NewSessionEstablished("")) } } } diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt index 877594d86e..36314a2e25 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt @@ -17,6 +17,7 @@ import com.tangem.common.extensions.hexToBytes import com.tangem.common.extensions.toDecompressedPublicKey import com.tangem.common.extensions.toHexString import com.tangem.core.analytics.Analytics +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.operations.sign.SignHashCommand import com.tangem.tap.common.analytics.events.AnalyticsParam @@ -25,7 +26,6 @@ import com.tangem.tap.common.analytics.events.Basic.TransactionSent.MemoType import com.tangem.tap.common.analytics.events.WalletConnect import com.tangem.tap.common.extensions.safeUpdate import com.tangem.tap.common.extensions.toFormattedString -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.domain.walletconnect.BnbHelper.toWCBinanceTradeOrder import com.tangem.tap.domain.walletconnect.BnbHelper.toWCBinanceTransferOrder import com.tangem.tap.domain.walletconnect2.domain.WcEthereumSignMessage diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/WalletConnectRepositoryImpl.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/WalletConnectRepositoryImpl.kt index 01e3803798..dcd79b0985 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/WalletConnectRepositoryImpl.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/WalletConnectRepositoryImpl.kt @@ -1,6 +1,9 @@ package com.tangem.tap.domain.walletconnect2.data import android.app.Application +import arrow.core.flatten +import com.tangem.core.analytics.Analytics +import com.tangem.tap.common.analytics.events.WalletConnect import com.tangem.tap.domain.walletconnect2.domain.WalletConnectRepository import com.tangem.tap.domain.walletconnect2.domain.WcJrpcRequestsDeserializer import com.tangem.tap.domain.walletconnect2.domain.models.* @@ -97,6 +100,7 @@ class WalletConnectRepositoryImpl @Inject constructor( sessionProposal.url, sessionProposal.icons, sessionProposal.requiredNamespaces.values.flatMap { it.chains ?: emptyList() }, + sessionProposal.optionalNamespaces.values.flatMap { it.chains ?: emptyList() }, ), ) } @@ -187,6 +191,7 @@ class WalletConnectRepositoryImpl @Inject constructor( namespaces = sessionProposal.requiredNamespaces, userNamespaces = userNamespaces, ) + if (missingNetworks.isNotEmpty()) { Timber.e("Not added blockchains: $missingNetworks") scope.launch { @@ -204,17 +209,29 @@ class WalletConnectRepositoryImpl @Inject constructor( }.groupBy { pair -> pair.first } .mapValues { entry -> entry.value.map { pair -> pair.second }.toSet() } - val preparedNamespaces = sessionProposal.requiredNamespaces.map { requiredNamespace -> - val accounts = requiredNamespace.value.chains?.mapNotNull { userChains[it] }?.flatten() ?: emptyList() + val preparedNamespaces = sessionProposal.requiredNamespaces + .map { requiredNamespace -> + val accountsRequired = requiredNamespace.value.chains + ?.mapNotNull { chain -> userChains[chain] } + ?.flatten() ?: emptyList() + val optionalNamespace = sessionProposal.optionalNamespaces[requiredNamespace.key] + val accountsOptional = optionalNamespace?.chains + ?.mapNotNull { chain -> userChains[chain] } + ?.flatten() ?: emptyList() - requiredNamespace.key to Wallet.Model.Namespace.Session( - accounts = accounts, - methods = requiredNamespace.value.methods, - events = requiredNamespace.value.events, - ) - }.toMap() + val methods = (requiredNamespace.value.methods + (optionalNamespace?.methods ?: emptyList())) + .distinct() + requiredNamespace.key to Wallet.Model.Namespace.Session( + accounts = (accountsRequired + accountsOptional).distinct(), + methods = methods, + events = requiredNamespace.value.events, + ) + }.toMap() - val sessionApproval = Wallet.Params.SessionApprove(sessionProposal.proposerPublicKey, preparedNamespaces) + val sessionApproval = Wallet.Params.SessionApprove( + proposerPublicKey = sessionProposal.proposerPublicKey, + namespaces = preparedNamespaces, + ) Timber.d("Session approval is prepared for sending: $sessionApproval") @@ -222,6 +239,7 @@ class WalletConnectRepositoryImpl @Inject constructor( params = sessionApproval, onSuccess = { Timber.d("Approved successfully: $it") + Analytics.send(WalletConnect.NewSessionEstablished(sessionProposal.name)) }, onError = { Timber.d("Error while approving: $it") @@ -246,7 +264,9 @@ class WalletConnectRepositoryImpl @Inject constructor( ), ), onSuccess = {}, - onError = {}, + onError = { + Analytics.send(WalletConnect.TransactionError(it.throwable)) + }, ) } @@ -284,6 +304,7 @@ class WalletConnectRepositoryImpl @Inject constructor( Web3Wallet.disconnectSession( params = Wallet.Params.SessionDisconnect(topic), onSuccess = { + Analytics.send(WalletConnect.SessionDisconnected()) updateSessions() Timber.d("Disconnected successfully: $it") }, diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt index ef202cd085..5bd6d8f0a1 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt @@ -1,5 +1,7 @@ package com.tangem.tap.domain.walletconnect2.domain +import com.tangem.core.analytics.Analytics +import com.tangem.tap.common.analytics.events.WalletConnect import com.tangem.tap.common.extensions.filterNotNull import com.tangem.tap.domain.walletconnect.WalletConnectSdkHelper import com.tangem.tap.domain.walletconnect2.domain.models.* @@ -50,15 +52,15 @@ class WalletConnectInteractor( when (wcEvent) { is WalletConnectEvents.SessionProposal -> { Timber.d("WC session proposal event received") - val unsupportedNetworks = wcEvent.chainIds + val unsupportedNetworks = wcEvent.requiredChainIds .filter { blockchainHelper.chainIdToNetworkIdOrNull(it) == null } if (unsupportedNetworks.isNotEmpty()) { val error = WalletConnectError.ApprovalErrorUnsupportedNetwork(unsupportedNetworks) handler.onSessionRejected(error) return@onEach } - - val networksFormatted = wcEvent.chainIds + val networksFormatted = (wcEvent.requiredChainIds + wcEvent.optionalChainIds) + .distinct() .mapNotNull { blockchainHelper.chainIdToFullNameOrNull(it) } .toString() handler.onProposalReceived(proposal = wcEvent, networksFormatted = networksFormatted) @@ -216,6 +218,7 @@ class WalletConnectInteractor( id = request.requestId, ) } else { + Analytics.send(WalletConnect.RequestSigned()) walletConnectRepository.sendRequest( topic = request.topic, id = request.requestId, diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/WalletConnectEvents.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/WalletConnectEvents.kt index bec06dd554..e481daa22d 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/WalletConnectEvents.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/WalletConnectEvents.kt @@ -9,7 +9,8 @@ sealed interface WalletConnectEvents { val description: String, val url: String, val icons: List, - val chainIds: List, + val requiredChainIds: List, + val optionalChainIds: List, ) : WalletConnectEvents data class SessionApprovalError(val error: WalletConnectError) : WalletConnectEvents diff --git a/app/src/main/java/com/tangem/tap/features/BaseFragment.kt b/app/src/main/java/com/tangem/tap/features/BaseFragment.kt index cf8be74484..cddf55cc07 100644 --- a/app/src/main/java/com/tangem/tap/features/BaseFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/BaseFragment.kt @@ -14,7 +14,7 @@ import androidx.lifecycle.Lifecycle import androidx.transition.TransitionInflater import com.google.android.material.snackbar.Snackbar import com.tangem.common.extensions.VoidCallback -import com.tangem.tap.common.redux.navigation.NavigationAction +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.store import com.tangem.wallet.R diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/routers/DefaultCustomTokenRouter.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/routers/DefaultCustomTokenRouter.kt index 25eb163e9b..7afec7d5a5 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/routers/DefaultCustomTokenRouter.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/routers/DefaultCustomTokenRouter.kt @@ -1,7 +1,7 @@ package com.tangem.tap.features.customtoken.impl.presentation.routers -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.store /** Default implementation of custom token feature router */ diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt index acc0130ea9..a992489911 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt @@ -7,9 +7,12 @@ import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.common.flatMap import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.TapWorkarounds.isTangemTwins import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.tap.* import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.Settings @@ -20,12 +23,9 @@ import com.tangem.tap.common.extensions.onUserWalletSelected import com.tangem.tap.common.redux.AppDialog import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.builders.UserWalletBuilder import com.tangem.tap.domain.model.builders.UserWalletIdBuilder import com.tangem.tap.domain.scanCard.ScanCardProcessor -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.domain.userWalletList.di.provideBiometricImplementation import com.tangem.tap.domain.userWalletList.di.provideRuntimeImplementation import com.tangem.tap.domain.userWalletList.isLockedSync @@ -33,13 +33,7 @@ import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.onboarding.products.twins.redux.CreateTwinWalletMode import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsAction import com.tangem.tap.features.wallet.redux.WalletAction -import com.tangem.tap.foregroundActivityObserver -import com.tangem.tap.preferencesStorage -import com.tangem.tap.scope -import com.tangem.tap.store import com.tangem.tap.tangemSdkManager -import com.tangem.tap.userWalletsListManager -import com.tangem.tap.walletStoresManager import com.tangem.wallet.R import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt index b69de63a66..802ad1b140 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt @@ -4,6 +4,9 @@ import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.DerivationStyle import com.tangem.blockchain.common.WalletManager import com.tangem.common.extensions.guard +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.common.extensions.toNetworkId @@ -14,9 +17,6 @@ import com.tangem.domain.models.scan.ScanResponse import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.domain.walletconnect.BnbHelper import com.tangem.tap.domain.walletconnect.WalletConnectManager import com.tangem.tap.domain.walletconnect.WalletConnectNetworkUtils diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsFragment.kt index 5ced6c832e..0f0e3de308 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsFragment.kt index e67d9b5adf..90c489ab41 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/coderecovery/AccessCodeRecoveryFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/coderecovery/AccessCodeRecoveryFragment.kt index 370d333d31..cb50141a2c 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/coderecovery/AccessCodeRecoveryFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/coderecovery/AccessCodeRecoveryFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store import com.tangem.wallet.R diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsFragment.kt index 3c37bacd20..371b571cdd 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsFragment.kt @@ -8,11 +8,12 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.common.analytics.events.Settings -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store +import com.tangem.wallet.R import org.rekotlin.StoreSubscriber class DetailsFragment : Fragment(), StoreSubscriber { @@ -23,8 +24,8 @@ class DetailsFragment : Fragment(), StoreSubscriber { super.onCreate(savedInstanceState) Analytics.send(Settings.ScreenOpened()) val inflater = TransitionInflater.from(requireContext()) - enterTransition = inflater.inflateTransition(android.R.transition.fade) - exitTransition = inflater.inflateTransition(android.R.transition.fade) + enterTransition = inflater.inflateTransition(R.transition.fade) + exitTransition = inflater.inflateTransition(R.transition.fade) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt index e9766c6147..8301791338 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsViewModel.kt @@ -3,14 +3,14 @@ package com.tangem.tap.features.details.ui.details import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.util.cardTypesResolver import com.tangem.tap.common.analytics.events.Settings import com.tangem.tap.common.feedback.FeedbackEmail import com.tangem.tap.common.feedback.SupportInfo import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.features.disclaimer.redux.DisclaimerAction import com.tangem.tap.features.home.LocaleRegionProvider diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardFragment.kt index df48063920..7a7c723779 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store import org.rekotlin.StoreSubscriber diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/securitymode/SecurityModeFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/securitymode/SecurityModeFragment.kt index 77eb446ad1..c3b2015297 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/securitymode/SecurityModeFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/securitymode/SecurityModeFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.DetailsState import com.tangem.tap.store import org.rekotlin.StoreSubscriber diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt index 91a8e803b3..d67c7a262d 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt @@ -13,7 +13,7 @@ import androidx.core.view.WindowCompat import androidx.fragment.app.Fragment import com.google.zxing.Result import com.otaliastudios.cameraview.CameraView -import com.tangem.tap.common.redux.navigation.NavigationAction +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.store import me.dm7.barcodescanner.zxing.ZXingScannerView diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectFragment.kt index 4d5354e3f4..2c7ebdea6e 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectFragment.kt @@ -10,9 +10,9 @@ import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.transition.TransitionInflater import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.common.analytics.events.WalletConnect -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.features.details.redux.walletconnect.WalletConnectState import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt index d1962be5e4..a3f94a3cd9 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt @@ -2,9 +2,9 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs import android.content.Context import androidx.appcompat.app.AlertDialog +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.store import com.tangem.wallet.R diff --git a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerAction.kt b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerAction.kt index 1a712e1c49..ded89f039b 100644 --- a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerAction.kt +++ b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerAction.kt @@ -1,6 +1,6 @@ package com.tangem.tap.features.disclaimer.redux -import com.tangem.tap.common.redux.navigation.AppScreen +import com.tangem.core.navigation.AppScreen import com.tangem.tap.features.disclaimer.Disclaimer import com.tangem.tap.features.wallet.redux.ProgressState import org.rekotlin.Action diff --git a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerMiddleware.kt b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerMiddleware.kt index ca71193f2a..e71184aff2 100644 --- a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerMiddleware.kt @@ -1,8 +1,8 @@ package com.tangem.tap.features.disclaimer.redux +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.store import org.rekotlin.Action import org.rekotlin.Middleware diff --git a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerState.kt b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerState.kt index b610475974..ff9ab50f31 100644 --- a/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerState.kt +++ b/app/src/main/java/com/tangem/tap/features/disclaimer/redux/DisclaimerState.kt @@ -1,7 +1,7 @@ package com.tangem.tap.features.disclaimer.redux import com.tangem.common.extensions.VoidCallback -import com.tangem.tap.common.redux.navigation.AppScreen +import com.tangem.core.navigation.AppScreen import com.tangem.tap.features.disclaimer.Disclaimer import com.tangem.tap.features.disclaimer.DummyDisclaimer import com.tangem.tap.features.wallet.redux.ProgressState diff --git a/app/src/main/java/com/tangem/tap/features/disclaimer/ui/DisclaimerFragment.kt b/app/src/main/java/com/tangem/tap/features/disclaimer/ui/DisclaimerFragment.kt index c54f4ff005..ab1ec2715d 100644 --- a/app/src/main/java/com/tangem/tap/features/disclaimer/ui/DisclaimerFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/disclaimer/ui/DisclaimerFragment.kt @@ -6,12 +6,12 @@ import android.view.View.OVER_SCROLL_NEVER import android.webkit.WebView import androidx.transition.TransitionInflater import by.kirich1409.viewbindingdelegate.viewBinding +import com.tangem.core.navigation.AppScreen import com.tangem.core.ui.fragments.setStatusBarColor import com.tangem.tap.common.extensions.beginDelayedTransition import com.tangem.tap.common.extensions.hide import com.tangem.tap.common.extensions.show import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.features.BaseFragment import com.tangem.tap.features.addBackPressHandler import com.tangem.tap.features.disclaimer.Disclaimer diff --git a/app/src/main/java/com/tangem/tap/features/home/HomeFragment.kt b/app/src/main/java/com/tangem/tap/features/home/HomeFragment.kt index 57598aa099..e4885e7314 100644 --- a/app/src/main/java/com/tangem/tap/features/home/HomeFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/home/HomeFragment.kt @@ -14,11 +14,11 @@ import androidx.core.view.WindowInsetsControllerCompat import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.learn2earn.presentation.Learn2earnViewModel import com.tangem.tap.common.analytics.events.IntroductionProcess -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.home.compose.StoriesScreen import com.tangem.tap.features.home.redux.HomeAction import com.tangem.tap.features.home.redux.HomeState diff --git a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt index 9d7d775e1d..7a77fcaa60 100644 --- a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt @@ -6,6 +6,8 @@ import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics import com.tangem.core.analytics.AnalyticsEvent +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.models.scan.ScanResponse import com.tangem.tap.* import com.tangem.tap.common.analytics.events.Basic @@ -18,8 +20,6 @@ import com.tangem.tap.common.extensions.eraseContext import com.tangem.tap.common.extensions.onUserWalletSelected import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.builders.UserWalletBuilder import com.tangem.tap.domain.scanCard.ScanCardProcessor import com.tangem.tap.features.home.BELARUS_COUNTRY_CODE diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/OnboardingHelper.kt b/app/src/main/java/com/tangem/tap/features/onboarding/OnboardingHelper.kt index 6079110e39..477ab679c6 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/OnboardingHelper.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/OnboardingHelper.kt @@ -4,23 +4,19 @@ import com.tangem.common.doOnFailure import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.common.util.twinsIsTwinned import com.tangem.domain.models.scan.ProductType import com.tangem.domain.models.scan.ScanResponse +import com.tangem.tap.* import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.onUserWalletSelected import com.tangem.tap.common.extensions.removeContext import com.tangem.tap.common.extensions.setContext -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.builders.UserWalletBuilder import com.tangem.tap.features.saveWallet.redux.SaveWalletAction -import com.tangem.tap.preferencesStorage -import com.tangem.tap.scope -import com.tangem.tap.store -import com.tangem.tap.tangemSdkManager -import com.tangem.tap.userWalletsListManager import kotlinx.coroutines.delay import kotlinx.coroutines.launch import timber.log.Timber diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/note/OnboardingNoteFragment.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/note/OnboardingNoteFragment.kt index 39fea7dbfd..cf68e35486 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/note/OnboardingNoteFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/note/OnboardingNoteFragment.kt @@ -10,10 +10,10 @@ import androidx.transition.TransitionManager import coil.load import com.tangem.blockchain.common.Blockchain import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.ShareElement import com.tangem.tap.common.analytics.events.Onboarding import com.tangem.tap.common.extensions.getDrawableCompat import com.tangem.tap.common.extensions.stripZeroPlainString -import com.tangem.tap.common.redux.navigation.ShareElement import com.tangem.tap.common.toggleWidget.RefreshBalanceWidget import com.tangem.tap.common.transitions.InternalNoteLayoutTransition import com.tangem.tap.features.addBackPressHandler diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/note/redux/OnboardingNoteMiddleware.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/note/redux/OnboardingNoteMiddleware.kt index fddc46b3a8..0006840098 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/note/redux/OnboardingNoteMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/note/redux/OnboardingNoteMiddleware.kt @@ -3,22 +3,16 @@ package com.tangem.tap.features.onboarding.products.note.redux import com.tangem.common.CompletionResult import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.withMainContext import com.tangem.tap.DELAY_SDK_DIALOG_CLOSE import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.Onboarding -import com.tangem.tap.common.extensions.dispatchDebugErrorNotification -import com.tangem.tap.common.extensions.dispatchDialogShow -import com.tangem.tap.common.extensions.dispatchErrorNotification -import com.tangem.tap.common.extensions.dispatchOnMain -import com.tangem.tap.common.extensions.dispatchOpenUrl -import com.tangem.tap.common.extensions.getAddressData -import com.tangem.tap.common.extensions.getTopUpUrl +import com.tangem.tap.common.extensions.* import com.tangem.tap.common.postUi import com.tangem.tap.common.redux.AppDialog import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError import com.tangem.tap.domain.extensions.makePrimaryWalletManager import com.tangem.tap.features.demo.DemoHelper diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/OnboardingOtherCardsFragment.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/OnboardingOtherCardsFragment.kt index 5080265552..83674d9227 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/OnboardingOtherCardsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/OnboardingOtherCardsFragment.kt @@ -9,9 +9,9 @@ import androidx.core.view.isVisible import androidx.transition.TransitionManager import coil.load import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.ShareElement import com.tangem.tap.common.analytics.events.Onboarding import com.tangem.tap.common.extensions.getDrawableCompat -import com.tangem.tap.common.redux.navigation.ShareElement import com.tangem.tap.common.transitions.InternalNoteLayoutTransition import com.tangem.tap.features.addBackPressHandler import com.tangem.tap.features.onboarding.products.BaseOnboardingFragment diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/redux/OnboardingOtherCardsMiddleware.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/redux/OnboardingOtherCardsMiddleware.kt index ba7983eaa5..00a9d94af5 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/redux/OnboardingOtherCardsMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/otherCards/redux/OnboardingOtherCardsMiddleware.kt @@ -3,20 +3,16 @@ package com.tangem.tap.features.onboarding.products.otherCards.redux import com.tangem.blockchain.common.Blockchain import com.tangem.common.CompletionResult import com.tangem.core.analytics.Analytics -import com.tangem.domain.common.util.cardTypesResolver +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.withMainContext -import com.tangem.tap.DELAY_SDK_DIALOG_CLOSE +import com.tangem.domain.common.util.cardTypesResolver +import com.tangem.tap.* import com.tangem.tap.common.analytics.events.Onboarding import com.tangem.tap.common.postUi import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.onboarding.OnboardingHelper import com.tangem.tap.features.wallet.models.toCurrencies -import com.tangem.tap.scope -import com.tangem.tap.store -import com.tangem.tap.tangemSdkManager -import com.tangem.tap.userTokensRepository import kotlinx.coroutines.delay import kotlinx.coroutines.launch import org.rekotlin.Action diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/redux/TwinCardsMiddleware.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/redux/TwinCardsMiddleware.kt index 036482c623..af0338bb49 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/redux/TwinCardsMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/redux/TwinCardsMiddleware.kt @@ -4,6 +4,8 @@ import com.tangem.blockchain.extensions.Result import com.tangem.common.CompletionResult import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.withMainContext import com.tangem.domain.common.util.twinsIsTwinned import com.tangem.domain.models.scan.ScanResponse @@ -15,8 +17,6 @@ import com.tangem.tap.common.postUi import com.tangem.tap.common.redux.AppDialog import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError import com.tangem.tap.domain.extensions.makePrimaryWalletManager import com.tangem.tap.domain.model.builders.UserWalletIdBuilder diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/ui/TwinsCardsFragment.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/ui/TwinsCardsFragment.kt index 1ef2872944..77bc7f7310 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/ui/TwinsCardsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/twins/ui/TwinsCardsFragment.kt @@ -14,6 +14,7 @@ import com.tangem.Message import com.tangem.blockchain.common.Blockchain import com.tangem.common.extensions.VoidCallback import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.ShareElement import com.tangem.core.ui.fragments.setStatusBarColor import com.tangem.datasource.asset.AssetReader import com.tangem.domain.models.scan.ScanResponse @@ -25,7 +26,6 @@ import com.tangem.tap.common.extensions.getDrawableCompat import com.tangem.tap.common.extensions.hide import com.tangem.tap.common.extensions.show import com.tangem.tap.common.extensions.stripZeroPlainString -import com.tangem.tap.common.redux.navigation.ShareElement import com.tangem.tap.common.toggleWidget.RefreshBalanceWidget import com.tangem.tap.common.transitions.InternalNoteLayoutTransition import com.tangem.tap.domain.twins.TwinsCardWidget diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/redux/OnboardingWalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/redux/OnboardingWalletMiddleware.kt index 2f4be5416d..67921cce64 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/redux/OnboardingWalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/redux/OnboardingWalletMiddleware.kt @@ -6,6 +6,9 @@ import com.tangem.common.CompletionResult import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.ifNotNull import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.withMainContext import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.CardDTO @@ -20,10 +23,7 @@ import com.tangem.tap.common.extensions.dispatchDialogShow import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.home.redux.HomeAction import com.tangem.tap.features.onboarding.OnboardingDialog diff --git a/app/src/main/java/com/tangem/tap/features/saveWallet/redux/SaveWalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/saveWallet/redux/SaveWalletMiddleware.kt index ec2223b2bd..945fc90afd 100644 --- a/app/src/main/java/com/tangem/tap/features/saveWallet/redux/SaveWalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/saveWallet/redux/SaveWalletMiddleware.kt @@ -7,6 +7,10 @@ import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.common.flatMap import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import com.tangem.tap.* import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.MainScreen import com.tangem.tap.common.analytics.events.Onboarding @@ -14,19 +18,10 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchWithMain import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.builders.UserWalletBuilder -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.domain.userWalletList.di.provideBiometricImplementation import com.tangem.tap.domain.userWalletList.isLockable import com.tangem.tap.features.wallet.redux.WalletAction -import com.tangem.tap.foregroundActivityObserver -import com.tangem.tap.preferencesStorage -import com.tangem.tap.scope -import com.tangem.tap.store -import com.tangem.tap.tangemSdkManager -import com.tangem.tap.userWalletsListManager import kotlinx.coroutines.launch import org.rekotlin.Middleware import timber.log.Timber diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt index f48eec112c..69891195d6 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt @@ -7,6 +7,7 @@ import com.tangem.blockchain.blockchains.polkadot.ExistentialDepositProvider import com.tangem.blockchain.blockchains.stellar.StellarTransactionExtras import com.tangem.blockchain.blockchains.ton.TonTransactionExtras import com.tangem.blockchain.blockchains.xrp.XrpTransactionBuilder.XrpTransactionExtras +import com.tangem.core.navigation.NavigationAction import com.tangem.blockchain.common.* import com.tangem.blockchain.common.transaction.Fee import com.tangem.blockchain.extensions.SimpleResult @@ -27,7 +28,6 @@ import com.tangem.tap.common.extensions.* import com.tangem.tap.common.redux.AppDialog import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TangemSigner import com.tangem.tap.domain.TapError import com.tangem.tap.domain.configurable.warningMessage.WarningMessage diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt index fec34d9996..748ecacb4b 100644 --- a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt @@ -17,6 +17,7 @@ import by.kirich1409.viewbindingdelegate.viewBinding import com.google.android.material.textfield.TextInputEditText import com.tangem.Message import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.sdk.extensions.hideSoftKeyboard import com.tangem.tap.common.KeyboardObserver import com.tangem.tap.common.analytics.events.Token @@ -25,7 +26,6 @@ import com.tangem.tap.common.extensions.getFromClipboard import com.tangem.tap.common.extensions.setOnImeActionListener import com.tangem.tap.common.qrCodeScan.ScanQrCodeActivity import com.tangem.tap.common.recyclerView.SpaceItemDecoration -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.common.snackBar.MaxAmountSnackbar import com.tangem.tap.common.text.truncateMiddleWith import com.tangem.tap.common.toggleWidget.IndeterminateProgressButtonWidget diff --git a/app/src/main/java/com/tangem/tap/features/shop/redux/ShopMiddleware.kt b/app/src/main/java/com/tangem/tap/features/shop/redux/ShopMiddleware.kt index 3af546cab6..f049ef01b6 100644 --- a/app/src/main/java/com/tangem/tap/features/shop/redux/ShopMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/shop/redux/ShopMiddleware.kt @@ -1,12 +1,12 @@ package com.tangem.tap.features.shop.redux import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.analytics.events.Shop import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchOpenUrl import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.scope import com.tangem.tap.shopService import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/shop/ui/ShopFragment.kt b/app/src/main/java/com/tangem/tap/features/shop/ui/ShopFragment.kt index 56ffe54b0f..4af0db0285 100644 --- a/app/src/main/java/com/tangem/tap/features/shop/ui/ShopFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/shop/ui/ShopFragment.kt @@ -11,12 +11,12 @@ import android.view.inputmethod.InputMethodManager import androidx.activity.OnBackPressedCallback import androidx.fragment.app.viewModels import by.kirich1409.viewbindingdelegate.viewBinding +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.GlobalLayoutStateHandler import com.tangem.tap.common.KeyboardObserver import com.tangem.tap.common.extensions.getQuantityString import com.tangem.tap.common.extensions.hide import com.tangem.tap.common.extensions.show -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.common.shop.data.ProductType import com.tangem.tap.features.BaseStoreFragment import com.tangem.tap.features.shop.presentation.ShopViewModel diff --git a/app/src/main/java/com/tangem/tap/features/sprinklr/ui/SprinklrViewModel.kt b/app/src/main/java/com/tangem/tap/features/sprinklr/ui/SprinklrViewModel.kt index 87c033582a..a6cf3abe13 100644 --- a/app/src/main/java/com/tangem/tap/features/sprinklr/ui/SprinklrViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/sprinklr/ui/SprinklrViewModel.kt @@ -2,8 +2,8 @@ package com.tangem.tap.features.sprinklr.ui import androidx.lifecycle.ViewModel import com.google.accompanist.web.WebContent +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.extensions.dispatchOnMain -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.sprinklr.redux.SprinklrState import com.tangem.tap.store import kotlinx.coroutines.flow.MutableStateFlow diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/router/DefaultTokensListRouter.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/router/DefaultTokensListRouter.kt index cbfe64e505..4c390f27d6 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/router/DefaultTokensListRouter.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/router/DefaultTokensListRouter.kt @@ -1,10 +1,10 @@ package com.tangem.tap.features.tokens.impl.presentation.router +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.extensions.dispatchDialogShow import com.tangem.tap.common.extensions.dispatchNotification import com.tangem.tap.common.redux.AppDialog -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.customtoken.api.featuretoggles.CustomTokenFeatureToggles import com.tangem.tap.features.tokens.legacy.redux.TokensAction import com.tangem.tap.features.wallet.redux.models.WalletDialog diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt index 44e620b8ac..6896480058 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt @@ -25,9 +25,6 @@ import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp @@ -155,18 +152,8 @@ private fun DifferentAddressesWarning() { contentAlignment = Alignment.Center, ) { val text = stringResource(id = R.string.alert_manage_tokens_addresses_message) - val firstSpaceIndex = text.indexOf(" ") Text( - text = AnnotatedString( - text = text, - spanStyles = listOf( - AnnotatedString.Range( - SpanStyle(fontWeight = FontWeight.Bold), - start = 0, - end = firstSpaceIndex, - ), - ), - ), + text = text, modifier = Modifier.padding( horizontal = TangemTheme.dimens.spacing16, vertical = TangemTheme.dimens.spacing8, diff --git a/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt b/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt index 70a7e1b2cd..c62a8053d9 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt @@ -9,6 +9,8 @@ import com.tangem.common.extensions.guard import com.tangem.common.extensions.toMapKey import com.tangem.common.flatMap import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.crypto.hdWallet.DerivationPath import com.tangem.domain.DomainWrapped import com.tangem.domain.common.TapWorkarounds.derivationStyle @@ -25,8 +27,6 @@ import com.tangem.tap.common.extensions.dispatchDebugErrorNotification import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.features.wallet.models.Currency diff --git a/app/src/main/java/com/tangem/tap/features/wallet/models/Currency.kt b/app/src/main/java/com/tangem/tap/features/wallet/models/Currency.kt index 71cef96432..4b82889e22 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/models/Currency.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/models/Currency.kt @@ -2,11 +2,11 @@ package com.tangem.tap.features.wallet.models import com.tangem.blockchain.common.DerivationStyle import com.tangem.datasource.api.tangemTech.models.UserTokensResponse +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.features.addCustomToken.CustomCurrency import com.tangem.tap.common.redux.global.CryptoCurrencyName -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.blockchain.common.Blockchain as SdkBlockchain import com.tangem.blockchain.common.Token as SdkToken diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt index 8db98a4ee0..3f73a94c11 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt @@ -4,17 +4,17 @@ import android.content.Context import com.tangem.blockchain.common.Amount import com.tangem.blockchain.common.address.AddressType import com.tangem.core.analytics.AnalyticsEvent -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.models.scan.CardDTO +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.redux.NotificationAction import com.tangem.tap.domain.TapError import com.tangem.tap.domain.configurable.warningMessage.WarningMessage import com.tangem.tap.domain.model.TotalFiatBalance -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.domain.model.WalletStoreModel -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.redux.models.WalletDialog import com.tangem.wallet.R diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt index 9c1feed6b4..2135a4ab7d 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt @@ -4,6 +4,7 @@ import android.graphics.Bitmap import com.tangem.blockchain.common.AmountType import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.WalletManager +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.util.cardTypesResolver import com.tangem.tap.common.entities.Button import com.tangem.tap.common.redux.global.CryptoCurrencyName @@ -12,7 +13,6 @@ import com.tangem.tap.domain.configurable.warningMessage.WarningMessage import com.tangem.tap.domain.model.TotalFiatBalance import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.domain.model.WalletStoreModel -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsState import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt index d86a41c389..d008d1b2e0 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt @@ -4,6 +4,9 @@ import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.common.flatMap import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.Token.ButtonRemoveToken import com.tangem.tap.common.extensions.addContext @@ -11,10 +14,7 @@ import com.tangem.tap.common.extensions.dispatchDialogShow import com.tangem.tap.common.extensions.dispatchErrorNotification import com.tangem.tap.common.extensions.dispatchWithMain import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.scanCard.ScanCardProcessor import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.features.wallet.redux.WalletState diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt index 0c56d30f51..fbb76f391a 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt @@ -6,6 +6,8 @@ import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager import com.tangem.blockchain.common.AmountType import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.extensions.toNetworkId import com.tangem.feature.swap.presentation.SwapFragment @@ -15,8 +17,6 @@ import com.tangem.tap.common.extensions.dispatchDebugErrorNotification import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchOpenUrl import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.tokens.getIconUrl import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.home.RUSSIA_COUNTRY_CODE diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt index d7a0da7703..2bdd72972f 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt @@ -9,6 +9,8 @@ import com.tangem.common.CompletionResult import com.tangem.common.doOnSuccess import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.datasource.connection.NetworkConnectionManager import com.tangem.tap.* import com.tangem.tap.common.analytics.events.AnalyticsParam @@ -18,8 +20,6 @@ import com.tangem.tap.common.analytics.events.Token import com.tangem.tap.common.extensions.* import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.domain.model.WalletStoreModel diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt index b8f1e06942..c6cad8e1bc 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt @@ -22,6 +22,7 @@ import com.badoo.mvicore.modelWatcher import com.tangem.common.doOnResult import com.tangem.common.extensions.guard import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.domain.common.extensions.withMainContext import com.tangem.feature.swap.api.SwapFeatureToggleManager @@ -41,7 +42,6 @@ import com.tangem.tap.common.extensions.show import com.tangem.tap.common.extensions.toQrCode import com.tangem.tap.common.recyclerView.SpaceItemDecoration import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.common.utils.SafeStoreSubscriber import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.features.wallet.models.Currency diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt index 6540470882..af1d2100aa 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt @@ -23,6 +23,8 @@ import coil.load import coil.size.Scale import com.badoo.mvicore.modelWatcher import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.core.ui.fragments.setStatusBarColor import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.OneTouchClickListener @@ -37,8 +39,6 @@ import com.tangem.tap.common.extensions.beginDelayedTransition import com.tangem.tap.common.extensions.show import com.tangem.tap.common.recyclerView.SpaceItemDecoration import com.tangem.tap.common.redux.global.GlobalAction -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.common.utils.SafeStoreSubscriber import com.tangem.tap.domain.configurable.warningMessage.WarningMessage import com.tangem.tap.domain.statePrinter.printScanResponseState @@ -268,6 +268,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber) { diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt index 95f80ebca8..b94cc9de26 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt @@ -6,12 +6,12 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.domain.common.util.cardTypesResolver +import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.tap.common.analytics.converters.ParamCardCurrencyConverter import com.tangem.tap.common.analytics.events.Basic import com.tangem.tap.common.analytics.events.MainScreen import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.domain.model.TotalFiatBalance -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.features.wallet.ui.analytics.WalletAnalyticsEventsMapper import com.tangem.tap.store diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/dialogs/RussianCardholdersWarningBottomSheetDialog.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/dialogs/RussianCardholdersWarningBottomSheetDialog.kt index 9c8d5997b9..b7ec4ee4a1 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/dialogs/RussianCardholdersWarningBottomSheetDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/dialogs/RussianCardholdersWarningBottomSheetDialog.kt @@ -5,10 +5,10 @@ import android.os.Bundle import android.view.LayoutInflater import com.google.android.material.bottomsheet.BottomSheetDialog import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.NavigationAction import com.tangem.tap.common.analytics.events.Token import com.tangem.tap.common.extensions.dispatchDialogHide import com.tangem.tap.common.extensions.dispatchOpenUrl -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.features.wallet.redux.models.WalletDialog import com.tangem.tap.store @@ -17,8 +17,7 @@ import com.tangem.wallet.databinding.DialogRussiansCardholdersWarningBinding class RussianCardholdersWarningBottomSheetDialog( context: Context, private val dialogData: WalletDialog.RussianCardholdersWarningDialog.Data?, -) : BottomSheetDialog -(context) { +) : BottomSheetDialog(context) { private var binding: DialogRussiansCardholdersWarningBinding? = null diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/test/TestWallet.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/test/TestWallet.kt index 5b3dab3e8b..188cf35d91 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/test/TestWallet.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/test/TestWallet.kt @@ -5,10 +5,10 @@ import com.tangem.blockchain.common.AmountType import com.tangem.blockchain.common.Token import com.tangem.blockchain.common.WalletManager import com.tangem.common.extensions.guard +import com.tangem.domain.common.BlockchainNetwork import com.tangem.tap.common.TestAction import com.tangem.tap.common.TestActions import com.tangem.tap.common.extensions.dispatchDebugErrorNotification -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.store import java.math.BigDecimal diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt index 3f72a34acb..4f9f9d5453 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt @@ -12,7 +12,6 @@ import com.tangem.tap.common.extensions.toFormattedCurrencyString import com.tangem.tap.common.extensions.toFormattedFiatValue import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.domain.model.WalletStoreModel -import com.tangem.tap.features.wallet.models.PendingTransactionType import com.tangem.tap.features.wallet.models.WalletWarning import com.tangem.tap.features.wallet.redux.WalletMainButton import com.tangem.tap.features.wallet.redux.utils.UNKNOWN_AMOUNT_SIGN @@ -27,14 +26,15 @@ internal fun WalletDataModel.mainButton(blockchainAmount: BigDecimal): WalletMai internal fun WalletDataModel.hasPendingTransactions(): Boolean { // for now check pending ongoing only just for BTC, later test and add other utxo networks - val isBitcoinBlockchain = - currency.blockchain == Blockchain.Bitcoin || currency.blockchain == Blockchain.BitcoinTestnet - if (currency.isBlockchain() && isBitcoinBlockchain) { - val outgoingTransactions = status.pendingTransactions.filter { - it.type == PendingTransactionType.Outgoing - } - return outgoingTransactions.isEmpty() - } + // disabled for release 4.8, test and enable in 4.9 + // val isBitcoinBlockchain = + // currency.blockchain == Blockchain.Bitcoin || currency.blockchain == Blockchain.BitcoinTestnet + // if (currency.isBlockchain() && isBitcoinBlockchain) { + // val outgoingTransactions = status.pendingTransactions.filter { + // it.type == PendingTransactionType.Outgoing + // } + // return outgoingTransactions.isEmpty() + // } return status.pendingTransactions.isEmpty() } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/view/TotalBalanceCard.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/view/TotalBalanceCard.kt index d89d245766..fdfadc43e1 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/view/TotalBalanceCard.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/view/TotalBalanceCard.kt @@ -27,6 +27,7 @@ import com.tangem.tap.domain.model.TotalFiatBalance import com.tangem.tap.features.wallet.redux.utils.UNKNOWN_AMOUNT_SIGN import com.tangem.wallet.R import com.valentinilk.shimmer.shimmer +import timber.log.Timber import java.math.BigDecimal import java.math.RoundingMode import java.text.DecimalFormat @@ -227,14 +228,21 @@ private fun buildAmountString(amount: BigDecimal?, fiatCurrency: FiatCurrency): ?: return AnnotatedString("${amount.toPlainString()} ${fiatCurrency.symbol}") val currencyToShow = "${fiatCurrency.symbol} " - val scaledAmount = Currency.getInstance(fiatCurrency.code)?.let { currency -> - formatter.currency = currency - formatter.maximumFractionDigits = fractionDigits - formatter.minimumFractionDigits = fractionDigits - formatter.isGroupingUsed = true - formatter.roundingMode = RoundingMode.HALF_UP - formatter.format(amount).replace(currency.symbol, currencyToShow) - } ?: formatter.format(amount) + val scaledAmount = try { + Currency.getInstance(fiatCurrency.code)?.let { currency -> + formatter.currency = currency + formatter.maximumFractionDigits = fractionDigits + formatter.minimumFractionDigits = fractionDigits + formatter.isGroupingUsed = true + formatter.roundingMode = RoundingMode.HALF_UP + formatter.format(amount).replace(currency.symbol, currencyToShow) + } ?: formatter.format(amount) + } catch (e: IllegalArgumentException) { + Timber.e("TotalBalanceCard buildAmountString currencyCode is not a supported ISO 4217 code: $e") + formatter.currency?.let { + formatter.format(amount).replace(it.symbol, currencyToShow) + } ?: formatter.format(amount) + } val integer = scaledAmount.substringBefore(formatter.decimalFormatSymbols.decimalSeparator) var reminder = scaledAmount.substringAfter(formatter.decimalFormatSymbols.decimalSeparator) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt index 421393fcb5..6dec677865 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt @@ -4,6 +4,8 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import com.badoo.mvicore.modelWatcher import com.tangem.core.analytics.Analytics +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.tap.common.analytics.events.MainScreen import com.tangem.tap.common.analytics.events.Portfolio @@ -11,8 +13,6 @@ import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.extensions.getQuantityString import com.tangem.tap.common.extensions.hide import com.tangem.tap.common.extensions.show -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.TotalFiatBalance import com.tangem.tap.features.tokens.legacy.redux.TokensAction import com.tangem.tap.features.wallet.redux.ErrorType diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/UserWalletModel.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/UserWalletModel.kt index b381b423c3..d1300ffa43 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/UserWalletModel.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/UserWalletModel.kt @@ -1,6 +1,6 @@ package com.tangem.tap.features.walletSelector.redux -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.domain.model.TotalFiatBalance data class UserWalletModel( diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt index e997860d4e..9acb28b1d6 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt @@ -1,9 +1,9 @@ package com.tangem.tap.features.walletSelector.redux import com.tangem.common.core.TangemError -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.entities.FiatCurrency -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletStoreModel import org.rekotlin.Action diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt index 3528a61c7a..00d1e687bb 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt @@ -3,8 +3,11 @@ package com.tangem.tap.features.walletSelector.redux import com.tangem.common.* import com.tangem.common.core.TangemSdkError import com.tangem.core.analytics.Analytics -import com.tangem.domain.common.util.UserWalletId +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.* import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.Basic @@ -13,10 +16,7 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchWithMain import com.tangem.tap.common.extensions.onUserWalletSelected import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.TotalFiatBalance -import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.model.WalletStoreModel import com.tangem.tap.domain.model.builders.UserWalletBuilder import com.tangem.tap.domain.model.builders.UserWalletIdBuilder diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt index 2a8ace7ad3..13daba6567 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt @@ -2,9 +2,9 @@ package com.tangem.tap.features.walletSelector.redux import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.models.scan.CardDTO +import com.tangem.domain.wallets.models.UserWallet import com.tangem.tap.common.redux.AppState import com.tangem.tap.domain.model.TotalFiatBalance -import com.tangem.tap.domain.model.UserWallet import org.rekotlin.Action internal object WalletSelectorReducer { diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorState.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorState.kt index 797cc04593..49e1f753a3 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorState.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorState.kt @@ -1,7 +1,7 @@ package com.tangem.tap.features.walletSelector.redux import com.tangem.common.core.TangemError -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.entities.FiatCurrency import org.rekotlin.StateType diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorScreenState.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorScreenState.kt index b2da2e5b5f..796c2eac3f 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorScreenState.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorScreenState.kt @@ -1,7 +1,7 @@ package com.tangem.tap.features.walletSelector.ui import androidx.compose.runtime.Immutable -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.features.details.ui.cardsettings.TextReference import com.tangem.tap.features.walletSelector.ui.model.DialogModel import com.tangem.tap.features.walletSelector.ui.model.MultiCurrencyUserWalletItem diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt index c6339f9cd8..6fb9347118 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/WalletSelectorViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.tangem.common.core.TangemError import com.tangem.core.analytics.Analytics -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.analytics.events.MyWallets import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.domain.userWalletList.UserWalletsListError diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/MockData.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/MockData.kt index c404c8890a..0099f47c84 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/MockData.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/MockData.kt @@ -1,6 +1,6 @@ package com.tangem.tap.features.walletSelector.ui.components -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.features.walletSelector.ui.WalletSelectorScreenState import com.tangem.tap.features.walletSelector.ui.model.MultiCurrencyUserWalletItem import com.tangem.tap.features.walletSelector.ui.model.SingleCurrencyUserWalletItem diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WallectSelectorScreenContent.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WallectSelectorScreenContent.kt index f0dd6b139b..472a4322ec 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WallectSelectorScreenContent.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WallectSelectorScreenContent.kt @@ -25,7 +25,7 @@ import com.tangem.core.ui.components.SecondaryButtonIconEnd import com.tangem.core.ui.components.SpacerWMax import com.tangem.core.ui.components.atoms.Hand import com.tangem.core.ui.res.TangemTheme -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.features.walletSelector.ui.WalletSelectorScreenState import com.tangem.wallet.R diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WalletItem.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WalletItem.kt index 03d505e048..305cfa6545 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WalletItem.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/components/WalletItem.kt @@ -4,16 +4,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.heightIn -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Divider import androidx.compose.material.Icon @@ -39,7 +30,7 @@ import com.tangem.core.ui.components.SpacerH2 import com.tangem.core.ui.components.SpacerW6 import com.tangem.core.ui.components.SpacerW8 import com.tangem.core.ui.res.TangemTheme -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.common.extensions.cardImageData import com.tangem.tap.features.walletSelector.ui.model.MultiCurrencyUserWalletItem import com.tangem.tap.features.walletSelector.ui.model.SingleCurrencyUserWalletItem diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/UserWalletItem.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/UserWalletItem.kt index 7013362085..e5e3033115 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/UserWalletItem.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/ui/model/UserWalletItem.kt @@ -1,6 +1,6 @@ package com.tangem.tap.features.walletSelector.ui.model -import com.tangem.domain.common.util.UserWalletId +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.tap.features.wallet.redux.utils.UNKNOWN_AMOUNT_SIGN internal sealed interface UserWalletItem { diff --git a/app/src/main/java/com/tangem/tap/features/welcome/redux/WelcomeMiddleware.kt b/app/src/main/java/com/tangem/tap/features/welcome/redux/WelcomeMiddleware.kt index 005bcca0a4..8a96417455 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/redux/WelcomeMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/redux/WelcomeMiddleware.kt @@ -5,6 +5,8 @@ import com.tangem.common.doOnFailure import com.tangem.common.doOnResult import com.tangem.common.doOnSuccess import com.tangem.common.flatMap +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction import com.tangem.domain.models.scan.ScanResponse import com.tangem.tap.* import com.tangem.tap.common.analytics.events.AnalyticsParam @@ -13,8 +15,6 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.dispatchWithMain import com.tangem.tap.common.extensions.onUserWalletSelected import com.tangem.tap.common.redux.AppState -import com.tangem.tap.common.redux.navigation.AppScreen -import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.model.builders.UserWalletBuilder import com.tangem.tap.domain.scanCard.ScanCardProcessor import com.tangem.tap.domain.userWalletList.unlockIfLockable diff --git a/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt b/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt index 35c2d83718..cf6015d446 100644 --- a/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt +++ b/app/src/main/java/com/tangem/tap/proxy/AppStateHolder.kt @@ -1,23 +1,28 @@ package com.tangem.tap.proxy import com.tangem.TangemSdk +import com.tangem.core.navigation.NavigationAction +import com.tangem.core.navigation.NavigationStateHolder import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import com.tangem.domain.wallets.legacy.WalletsStateHolder import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.common.redux.AppState import com.tangem.tap.domain.TangemSdkManager import com.tangem.tap.domain.tokens.UserTokensRepository -import com.tangem.tap.domain.userWalletList.UserWalletsListManager import com.tangem.tap.domain.walletStores.WalletStoresManager import com.tangem.tap.features.wallet.redux.WalletState import org.rekotlin.Store import javax.inject.Inject /** - * Holds objects from old modules, that missing in DI graph - * Object sets manually to use in new modules and [AppStateHolder] proxies its to DI + * Holds objects from old modules, that missing in DI graph. + * Object sets manually to use in new modules and [AppStateHolder] proxies its to DI. */ -class AppStateHolder @Inject constructor() { +class AppStateHolder @Inject constructor() : WalletsStateHolder, NavigationStateHolder { + + override var userWalletsListManager: UserWalletsListManager? = null @Deprecated("Use scan response from selected user wallet") var scanResponse: ScanResponse? = null @@ -27,10 +32,13 @@ class AppStateHolder @Inject constructor() { var tangemSdkManager: TangemSdkManager? = null var tangemSdk: TangemSdk? = null var walletStoresManager: WalletStoresManager? = null - var userWalletsListManager: UserWalletsListManager? = null var appFiatCurrency: FiatCurrency = FiatCurrency.Default fun getActualCard(): CardDTO? { return scanResponse?.card } + + override fun navigate(action: NavigationAction) { + mainStore?.dispatch(action) + } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt b/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt index c673ac8577..e24eae21c2 100644 --- a/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt +++ b/app/src/main/java/com/tangem/tap/proxy/DerivationManagerImpl.kt @@ -9,6 +9,7 @@ import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.ByteArrayKey import com.tangem.common.extensions.toMapKey import com.tangem.crypto.hdWallet.DerivationPath +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.common.util.hasDerivation @@ -23,7 +24,6 @@ import com.tangem.tap.common.extensions.dispatchDebugErrorNotification import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.domain.TapError -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.scope import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt b/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt index 96430194c1..63664407ff 100644 --- a/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt +++ b/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt @@ -14,6 +14,7 @@ import com.tangem.blockchain.extensions.isNetworkError import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.hexToBytes import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.lib.crypto.TransactionManager import com.tangem.lib.crypto.models.* @@ -23,7 +24,6 @@ import com.tangem.tap.common.analytics.events.Basic import com.tangem.tap.common.analytics.events.Basic.TransactionSent.MemoType import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.domain.TangemSigner -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.tangemSdk import java.math.BigDecimal import java.math.BigInteger diff --git a/app/src/main/java/com/tangem/tap/proxy/UserWalletManagerImpl.kt b/app/src/main/java/com/tangem/tap/proxy/UserWalletManagerImpl.kt index fba11b855a..1938886ede 100644 --- a/app/src/main/java/com/tangem/tap/proxy/UserWalletManagerImpl.kt +++ b/app/src/main/java/com/tangem/tap/proxy/UserWalletManagerImpl.kt @@ -6,6 +6,7 @@ import com.tangem.blockchain.common.Token import com.tangem.blockchain.common.WalletManager import com.tangem.common.doOnFailure import com.tangem.common.extensions.guard +import com.tangem.domain.common.BlockchainNetwork import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.extensions.toNetworkId @@ -17,7 +18,6 @@ import com.tangem.lib.crypto.models.ProxyAmount import com.tangem.lib.crypto.models.ProxyFiatCurrency import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.domain.model.builders.UserWalletIdBuilder -import com.tangem.tap.domain.tokens.models.BlockchainNetwork import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.userWalletsListManager import com.tangem.tap.walletCurrenciesManager diff --git a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphAction.kt b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphAction.kt index 5fab5032f5..e83ed33f3a 100644 --- a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphAction.kt +++ b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphAction.kt @@ -2,6 +2,7 @@ package com.tangem.tap.proxy.redux import com.tangem.domain.card.ScanCardUseCase import com.tangem.features.tester.api.TesterRouter +import com.tangem.features.tokendetails.navigation.TokenDetailsRouter import com.tangem.features.wallet.navigation.WalletRouter import com.tangem.tap.domain.walletconnect2.domain.WalletConnectInteractor import org.rekotlin.Action @@ -13,5 +14,6 @@ sealed interface DaggerGraphAction : Action { val scanCardUseCase: ScanCardUseCase, val walletRouter: WalletRouter, val walletConnectInteractor: WalletConnectInteractor, + val tokenDetailsRouter: TokenDetailsRouter, ) : DaggerGraphAction } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphReducer.kt b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphReducer.kt index bdc38a631c..bdd590be4d 100644 --- a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphReducer.kt +++ b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphReducer.kt @@ -17,6 +17,7 @@ object DaggerGraphReducer { scanCardUseCase = action.scanCardUseCase, walletRouter = action.walletRouter, walletConnectInteractor = action.walletConnectInteractor, + tokenDetailsRouter = action.tokenDetailsRouter, ) } } diff --git a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphState.kt b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphState.kt index a741e4dfd4..84409d4e36 100644 --- a/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphState.kt +++ b/app/src/main/java/com/tangem/tap/proxy/redux/DaggerGraphState.kt @@ -4,6 +4,8 @@ import com.tangem.datasource.asset.AssetReader import com.tangem.datasource.connection.NetworkConnectionManager import com.tangem.domain.card.ScanCardUseCase import com.tangem.features.tester.api.TesterRouter +import com.tangem.features.tokendetails.featuretoggles.TokenDetailsFeatureToggles +import com.tangem.features.tokendetails.navigation.TokenDetailsRouter import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles import com.tangem.features.wallet.navigation.WalletRouter import com.tangem.tap.domain.walletconnect2.domain.WalletConnectInteractor @@ -23,6 +25,8 @@ data class DaggerGraphState( val walletConnectRepository: WalletConnectRepository? = null, val walletConnectSessionsRepository: WalletConnectSessionsRepository? = null, val walletConnectInteractor: WalletConnectInteractor? = null, + val tokenDetailsFeatureToggles: TokenDetailsFeatureToggles? = null, + val tokenDetailsRouter: TokenDetailsRouter? = null, ) : StateType { inline fun get(getDependency: DaggerGraphState.() -> T?): T { diff --git a/app/src/main/res/drawable/ic_azero_no_color.xml b/app/src/main/res/drawable/ic_azero_no_color.xml new file mode 100644 index 0000000000..da712895b3 --- /dev/null +++ b/app/src/main/res/drawable/ic_azero_no_color.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/values-v24/bool.xml b/app/src/main/res/values-v24/bool.xml index 093ecf3bc6..d5677354f0 100644 --- a/app/src/main/res/values-v24/bool.xml +++ b/app/src/main/res/values-v24/bool.xml @@ -1,5 +1,5 @@ - false + true diff --git a/common/src/main/java/com/tangem/common/Provider.kt b/common/src/main/java/com/tangem/common/Provider.kt new file mode 100644 index 0000000000..7275695e98 --- /dev/null +++ b/common/src/main/java/com/tangem/common/Provider.kt @@ -0,0 +1,10 @@ +package com.tangem.common + +/** + * Provider for lazy initialization + * + * @param action initialization action + * +[REDACTED_AUTHOR] + */ +class Provider(action: () -> T) : () -> T by action \ No newline at end of file diff --git a/core/featuretoggles/src/main/assets/configs/feature_toggles_config.json b/core/featuretoggles/src/main/assets/configs/feature_toggles_config.json index dec9b4f24f..ddc2033b7b 100644 --- a/core/featuretoggles/src/main/assets/configs/feature_toggles_config.json +++ b/core/featuretoggles/src/main/assets/configs/feature_toggles_config.json @@ -14,5 +14,13 @@ { "name": "REDESIGNED_WALLET_SCREEN_ENABLED", "version": "undefined" + }, + { + "name": "1INCH_LEARN_2_EARN_ENABLED", + "version": "undefined" + }, + { + "name": "REDESIGNED_TOKEN_DETAIL_SCREEN_ENABLED", + "version": "undefined" } -] \ No newline at end of file +] diff --git a/core/navigation/.gitignore b/core/navigation/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/core/navigation/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/navigation/build.gradle.kts b/core/navigation/build.gradle.kts new file mode 100644 index 0000000000..bb00481f67 --- /dev/null +++ b/core/navigation/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} + +android { + namespace = "com.tangem.core.navigation" +} + +dependencies { + implementation(deps.material) + implementation(deps.reKotlin) +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/FragmentShareTransition.kt b/core/navigation/src/main/java/com/tangem/core/navigation/FragmentShareTransition.kt similarity index 94% rename from app/src/main/java/com/tangem/tap/common/redux/navigation/FragmentShareTransition.kt rename to core/navigation/src/main/java/com/tangem/core/navigation/FragmentShareTransition.kt index ab7aa07259..2cb2132eec 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/FragmentShareTransition.kt +++ b/core/navigation/src/main/java/com/tangem/core/navigation/FragmentShareTransition.kt @@ -1,4 +1,4 @@ -package com.tangem.tap.common.redux.navigation +package com.tangem.core.navigation import android.view.View import androidx.transition.TransitionSet diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationAction.kt b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationAction.kt similarity index 83% rename from app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationAction.kt rename to core/navigation/src/main/java/com/tangem/core/navigation/NavigationAction.kt index 71f3274e4c..082ada57ae 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationAction.kt +++ b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationAction.kt @@ -1,4 +1,4 @@ -package com.tangem.tap.common.redux.navigation +package com.tangem.core.navigation import android.net.Uri import android.os.Bundle @@ -7,6 +7,7 @@ import org.rekotlin.Action import java.lang.ref.WeakReference sealed class NavigationAction : Action { + data class NavigateTo( val screen: AppScreen, val fragmentShareTransition: FragmentShareTransition? = null, @@ -14,10 +15,7 @@ sealed class NavigationAction : Action { val bundle: Bundle? = null, ) : NavigationAction() - data class PopBackTo( - val screen: AppScreen? = null, - val inclusive: Boolean = false, - ) : NavigationAction() + data class PopBackTo(val screen: AppScreen? = null, val inclusive: Boolean = false) : NavigationAction() data class OpenUrl(val url: String) : NavigationAction() @@ -28,5 +26,6 @@ sealed class NavigationAction : Action { data class Share(val data: String) : NavigationAction() data class ActivityCreated(val activity: WeakReference) : NavigationAction() + data class ActivityDestroyed(val activity: WeakReference) : NavigationAction() } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationState.kt similarity index 57% rename from app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt rename to core/navigation/src/main/java/com/tangem/core/navigation/NavigationState.kt index 861a0a0fb9..db33dd330d 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt +++ b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationState.kt @@ -1,4 +1,4 @@ -package com.tangem.tap.common.redux.navigation +package com.tangem.core.navigation import androidx.appcompat.app.AppCompatActivity import org.rekotlin.StateType @@ -9,17 +9,25 @@ data class NavigationState( val activity: WeakReference? = null, ) : StateType -enum class AppScreen( - val isDialogFragment: Boolean = false, -) { +enum class AppScreen(val isDialogFragment: Boolean = false) { Home, Shop, Disclaimer, - OnboardingNote, OnboardingWallet, OnboardingTwins, OnboardingOther, - Wallet, WalletDetails, + OnboardingNote, + OnboardingWallet, + OnboardingTwins, + OnboardingOther, + Wallet, + WalletDetails, Send, - Details, DetailsSecurity, CardSettings, AppSettings, ResetToFactory, AccessCodeRecovery, - AddTokens, AddCustomToken, + Details, + DetailsSecurity, + CardSettings, + AppSettings, + ResetToFactory, + AccessCodeRecovery, + AddTokens, + AddCustomToken, WalletConnectSessions, QrScan, ReferralProgram, diff --git a/core/navigation/src/main/java/com/tangem/core/navigation/NavigationStateHolder.kt b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationStateHolder.kt new file mode 100644 index 0000000000..7504b75656 --- /dev/null +++ b/core/navigation/src/main/java/com/tangem/core/navigation/NavigationStateHolder.kt @@ -0,0 +1,12 @@ +package com.tangem.core.navigation + +/** + * Navigation state holder + * +[REDACTED_AUTHOR] + */ +interface NavigationStateHolder { + + /** Navigate by [action] */ + fun navigate(action: NavigationAction) +} \ No newline at end of file diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index fb5043c0be..797b9dea53 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -68,6 +68,7 @@ Обменять Посмотреть историю транзакций Обозреватель + Учись и получай бонусы! Нравится Основная сеть Нет @@ -160,21 +161,19 @@ Приложите карту Внутренняя ошибка: не удается найти менеджер кошельков Вы обновили данные биометрии, отсканируйте свою карту для входа - Вы завершили обучение и можете получить свои токены 1inch - Получите бонус + Вы успешно прошли все уроки и теперь можете получить 1INCH токены - Пройдите обучение и получите %d токен 1inch на свой кошелек - Пройдите обучение и получите %d токена 1inch на свой кошелек - Пройдите обучение и получите %d токена 1inch на свой кошелек - Пройдите обучение и получите %d токенов 1inch на свой кошелек + Пройдите 3 урока и получите %d 1INCH токен на свой кошелек + Пройдите 3 урока и получите %d 1INCH токена на свой кошелек + Пройдите 3 урока и получите %d 1INCH токена на свой кошелек + Пройдите 3 урока и получите %d 1INCH токенов на свой кошелек - Бонус за обучение Управление токенами Чтобы защитить свои активы, мы советуем вам выполнить эту процедуру Бэкап кошелька не был произведен Баланс В сумме учтены не все монеты - Токены 1inch будут зачислены на адрес вашего кошелька в течение 2 дней + 1INCH токены будут зачислены на адрес вашего кошелька в сети %s в течение 24 часов По вашему промокоду не было покупки кошелька, а значит вы не можете получить бонус. Купите кошелек Tangem, отсканируйте его в приложении и получите бонус. Чтобы получить доступ ко всем сетям, вам необходимо отсканировать карту Отсканируйте карту @@ -355,9 +354,8 @@ Тысячи криптовалют Используйте его на ходу, в любом месте, в любое время. Без проводов и батареек. Как только понадобится крипта, просто приложите карту к телефону. Кошелек для каждого - Пройдите обучение и получите возможность купить кошелек Tangem со скидкой и токены 1inch в качестве бонуса + Пройдите 3 урока, получите скидку на покупку Tangem Wallet и 1INCH токены Пройти обучение - Получите свой бонус Занимайте Покупайте Обменивайте @@ -493,6 +491,8 @@ Аккаунт не создан Эта карта не поддерживается Ваша карта Tangem предназначена для работы с другим приложением. Пожалуйста, ознакомьтесь с названием и инструкциями на вашей карте и установите правильное приложение. + Рыночная цена %s + за 24 часа Сеть %s Адрес скопирован в буфер обмена Нет соединения с интернетом diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 3c95aa8a19..cd659ff14e 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -66,6 +66,7 @@ Exchange Explore transaction history Explorer + Learn & Earn Like Main network No @@ -158,19 +159,17 @@ Tap the card Internal error: wallet manager not found You have updated biometrics, scan your card to enter - You have completed the training and can get your 1inch tokens - Get a bonus + You have completed all of the lessons, and are now eligible to receive your 1INCH tokens - Complete the training and get %d 1inch token on your wallet - Complete the training and get %d 1inch tokens on your wallet + Complete three lessons and receive %d 1INCH token to your wallet + Complete three lessons and receive %d 1INCH tokens to your wallet - Learn & Earn Manage tokens To protect your assets, we advise you to carry out this procedure Your wallet has not been backed up Total balance The amount does not include some of your funds - 1inch tokens will be credited to your wallet address within 2 days + 1INCH tokens will be credited to your %s wallet address within 24 hours There was no purchase of a wallet using your promo code, which means you cannot receive a bonus. Buy Tangem wallet, scan it in the app, and get the bonus. To access all the networks you need to scan the card Scan your card @@ -351,9 +350,8 @@ Thousands of Currencies Use it on the go, anywhere, anytime. No wires or batteries. Just tap the card to your phone when you need your crypto. The Wallet for Everyone - Complete the training, get the opportunity to buy Tangem wallet with a discount and receive 1inch tokens on your wallet + Take three lessons, get a discount on your Tangem Wallet, and receive 1INCH tokens to your wallet Learn - Learn and get a bonus Borrow Buy Exchange @@ -485,6 +483,8 @@ Account is not created This card is not supported Your Tangem card was made to work with a different application. Please see the name and instructions on your card, and install the correct app + %s Market Price + last 24h %s network Address was copied to clipboard No internet connection diff --git a/core/ui/src/main/java/com/tangem/core/ui/extensions/BlockchainIcons.kt b/core/ui/src/main/java/com/tangem/core/ui/extensions/BlockchainIcons.kt index e0dcf1e7c8..c4eeba732a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/extensions/BlockchainIcons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/extensions/BlockchainIcons.kt @@ -41,6 +41,7 @@ fun getActiveIconRes(blockchainId: String): Int { "terra-2", "terra-luna-2" -> R.drawable.img_terra2_22 "cronos" -> R.drawable.img_cronos_22 "TELOS", "TELOS/test" -> R.drawable.img_telos_22 + "aleph-zero", "aleph-zero/test" -> R.drawable.img_azero_22 else -> R.drawable.ic_alert_24 } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt index 27a26b7c76..c3f075ffb0 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt @@ -28,6 +28,7 @@ data class TangemDimens internal constructor( val radius8: Dp = 8.dp, val radius10: Dp = 10.dp, val radius12: Dp = 12.dp, + val radius14: Dp = 14.dp, val radius16: Dp = 16.dp, val radius18: Dp = 18.dp, val radius24: Dp = 24.dp, @@ -74,6 +75,7 @@ data class TangemDimens internal constructor( val size116: Dp = 116.dp, val size120: Dp = 120.dp, val size142: Dp = 142.dp, + val size158: Dp = 158.dp, val size164: Dp = 164.dp, val size200: Dp = 200.dp, // endregion Size diff --git a/core/ui/src/main/res/drawable/img_azero_22.xml b/core/ui/src/main/res/drawable/img_azero_22.xml new file mode 100644 index 0000000000..9a9fd4a2f1 --- /dev/null +++ b/core/ui/src/main/res/drawable/img_azero_22.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/java/com/tangem/tap/domain/tokens/models/BlockchainNetwork.kt b/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt similarity index 97% rename from app/src/main/java/com/tangem/tap/domain/tokens/models/BlockchainNetwork.kt rename to domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt index 32cfbc4bec..212bd764be 100644 --- a/app/src/main/java/com/tangem/tap/domain/tokens/models/BlockchainNetwork.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt @@ -1,12 +1,12 @@ -package com.tangem.tap.domain.tokens.models +package com.tangem.domain.common import com.squareup.moshi.JsonClass import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token import com.tangem.blockchain.common.WalletManager import com.tangem.common.extensions.calculateHashCode -import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.common.TapWorkarounds.derivationStyle +import com.tangem.domain.models.scan.CardDTO @JsonClass(generateAdapter = true) data class BlockchainNetwork( diff --git a/domain/legacy/src/main/java/com/tangem/domain/common/CardTypesResolver.kt b/domain/legacy/src/main/java/com/tangem/domain/common/CardTypesResolver.kt index 72e1bfb243..ed40b0b3b6 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/common/CardTypesResolver.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/common/CardTypesResolver.kt @@ -4,14 +4,26 @@ import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token interface CardTypesResolver { + fun isTangemNote(): Boolean + fun isTangemWallet(): Boolean + + fun isWhiteWallet(): Boolean + fun isWallet2(): Boolean + fun isTangemTwins(): Boolean + fun isStart2Coin(): Boolean + fun isDev(): Boolean + fun isMultiwalletAllowed(): Boolean fun getBlockchain(): Blockchain + fun getPrimaryToken(): Token? + + fun getBackupCardsCount(): Int } \ No newline at end of file diff --git a/domain/legacy/src/main/java/com/tangem/domain/common/TangemCardTypesResolver.kt b/domain/legacy/src/main/java/com/tangem/domain/common/TangemCardTypesResolver.kt index 79f908088a..39991063b5 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/common/TangemCardTypesResolver.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/common/TangemCardTypesResolver.kt @@ -11,27 +11,37 @@ import com.tangem.domain.common.TapWorkarounds.isTestCard import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ProductType -class TangemCardTypesResolver( +internal class TangemCardTypesResolver( private val card: CardDTO, private val productType: ProductType, private val walletData: WalletData?, ) : CardTypesResolver { override fun isTangemNote(): Boolean = productType == ProductType.Note - override fun isTangemWallet(): Boolean = card.settings.isBackupAllowed && - card.settings.isHDWalletAllowed && - card.firmwareVersion >= FirmwareVersion.MultiWalletAvailable - override fun isWallet2(): Boolean = - card.firmwareVersion >= FirmwareVersion.KeysImportAvailable && card.settings.isKeysImportAllowed + override fun isTangemWallet(): Boolean { + return card.settings.isBackupAllowed && card.settings.isHDWalletAllowed && + card.firmwareVersion >= FirmwareVersion.MultiWalletAvailable + } + + override fun isWhiteWallet(): Boolean { + return walletData == null && card.firmwareVersion >= FirmwareVersion.HDWalletAvailable + } + + override fun isWallet2(): Boolean { + return card.firmwareVersion >= FirmwareVersion.KeysImportAvailable && card.settings.isKeysImportAllowed + } override fun isTangemTwins(): Boolean = productType == ProductType.Twins + override fun isStart2Coin(): Boolean = card.isStart2Coin - override fun isMultiwalletAllowed(): Boolean = !isTangemTwins() && - !card.isStart2Coin && - !isTangemNote() && - (multiWalletAvailable() || card.wallets.firstOrNull()?.curve == EllipticCurve.Secp256k1) + override fun isDev(): Boolean = card.isTestCard + + override fun isMultiwalletAllowed(): Boolean { + return !isTangemTwins() && !card.isStart2Coin && !isTangemNote() && + (multiWalletAvailable() || card.wallets.firstOrNull()?.curve == EllipticCurve.Secp256k1) + } private fun multiWalletAvailable() = card.firmwareVersion >= FirmwareVersion.MultiWalletAvailable @@ -59,19 +69,21 @@ class TangemCardTypesResolver( cardToken.decimals, ) } -} -private fun Blockchain.Companion.fromBlockchainName(blockchainName: String): Blockchain { - // workaround for BSC (BNB) notes cards - return when (blockchainName) { - "BINANCE" -> { - Blockchain.BSC - } - "BINANCE/test" -> { - Blockchain.BSCTestnet - } - else -> { - Blockchain.fromId(blockchainName) + override fun getBackupCardsCount(): Int = card.wallets.size + + private fun Blockchain.Companion.fromBlockchainName(blockchainName: String): Blockchain { + // workaround for BSC (BNB) notes cards + return when (blockchainName) { + "BINANCE" -> { + Blockchain.BSC + } + "BINANCE/test" -> { + Blockchain.BSCTestnet + } + else -> { + Blockchain.fromId(blockchainName) + } } } } \ No newline at end of file diff --git a/domain/legacy/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt b/domain/legacy/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt index 1b5e32c734..f4084f38df 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt @@ -61,8 +61,8 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? { "cronos" -> Blockchain.Cronos "telos" -> Blockchain.Telos "telos/test" -> Blockchain.TelosTestnet - "azero" -> Blockchain.AlephZero - "azero/test" -> Blockchain.AlephZeroTestnet + "aleph-zero" -> Blockchain.AlephZero + "aleph-zero/test" -> Blockchain.AlephZeroTestnet else -> null } } @@ -128,8 +128,8 @@ fun Blockchain.toNetworkId(): String { Blockchain.Cronos -> "cronos" Blockchain.Telos -> "telos" Blockchain.TelosTestnet -> "telos/test" - Blockchain.AlephZero -> "azero" - Blockchain.AlephZeroTestnet -> "azero/test" + Blockchain.AlephZero -> "aleph-zero" + Blockchain.AlephZeroTestnet -> "aleph-zero/test" } } @@ -171,7 +171,7 @@ fun Blockchain.toCoinId(): String { Blockchain.TerraV2 -> "terra-luna-2" Blockchain.Cronos -> "crypto-com-chain" Blockchain.Telos, Blockchain.TelosTestnet -> "telos" - Blockchain.AlephZero, Blockchain.AlephZeroTestnet -> "azero" + Blockchain.AlephZero, Blockchain.AlephZeroTestnet -> "aleph-zero" } } diff --git a/domain/legacy/src/main/java/com/tangem/domain/common/util/UserWalletId.kt b/domain/legacy/src/main/java/com/tangem/domain/common/util/UserWalletId.kt deleted file mode 100644 index 17c22839fd..0000000000 --- a/domain/legacy/src/main/java/com/tangem/domain/common/util/UserWalletId.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.tangem.domain.common.util - -import com.tangem.common.extensions.hexToBytes -import com.tangem.common.extensions.toHexString - -class UserWalletId( - val stringValue: String, -) { - val value = stringValue.hexToBytes() - - constructor(value: ByteArray?) : this( - stringValue = value?.toHexString() ?: "", - ) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is UserWalletId) return false - - if (stringValue != other.stringValue) return false - - return true - } - - override fun hashCode(): Int { - return stringValue.hashCode() - } - - @Suppress("MagicNumber") - override fun toString(): String { - return with(stringValue) { - "UserWalletId(${take(3)}...${takeLast(3)})" - } - } -} \ No newline at end of file diff --git a/domain/wallets/.gitignore b/domain/wallets/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/domain/wallets/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/wallets/build.gradle.kts b/domain/wallets/build.gradle.kts new file mode 100644 index 0000000000..a9a1449956 --- /dev/null +++ b/domain/wallets/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} + +android { + namespace = "com.tangem.domain.wallets" +} + +dependencies { + + // region Domain modules + implementation(project(":domain:legacy")) + implementation(project(":domain:models")) + implementation(project(":domain:wallets:models")) + // endregion + + // region Tangem libraries + implementation(deps.tangem.blockchain) // android-library + implementation(deps.tangem.card.core) + // endregion + + // region Other libraries + implementation(deps.kotlin.coroutines) + // endregion +} \ No newline at end of file diff --git a/domain/wallets/models/.gitignore b/domain/wallets/models/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/domain/wallets/models/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/wallets/models/build.gradle.kts b/domain/wallets/models/build.gradle.kts new file mode 100644 index 0000000000..537d724d84 --- /dev/null +++ b/domain/wallets/models/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + alias(deps.plugins.kotlin.jvm) + id("configuration") +} + +dependencies { + // region Tangem libraries + implementation(deps.tangem.card.core) + // endregion + + // region Domain modules + implementation(project(":domain:models")) + // endregion +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/model/UserWallet.kt b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt similarity index 93% rename from app/src/main/java/com/tangem/tap/domain/model/UserWallet.kt rename to domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt index d58a3e7122..af407822fb 100644 --- a/app/src/main/java/com/tangem/tap/domain/model/UserWallet.kt +++ b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt @@ -1,7 +1,6 @@ -package com.tangem.tap.domain.model +package com.tangem.domain.wallets.models import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.common.util.UserWalletId /** * Represents user's wallet which stored in app persistence diff --git a/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt new file mode 100644 index 0000000000..791c3a1059 --- /dev/null +++ b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt @@ -0,0 +1,13 @@ +package com.tangem.domain.wallets.models + +import com.tangem.common.extensions.hexToBytes +import com.tangem.common.extensions.toHexString + +data class UserWalletId(val stringValue: String) { + + val value = stringValue.hexToBytes() + + constructor(value: ByteArray?) : this(stringValue = value?.toHexString() ?: "") + + override fun toString() = "UserWalletId(${stringValue.take(n = 3)}...${stringValue.takeLast(n = 3)})" +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/UserWalletsListManager.kt similarity index 67% rename from app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt rename to domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/UserWalletsListManager.kt index 249ac0d0f4..ff4e805ad1 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/UserWalletsListManager.kt @@ -1,34 +1,25 @@ -package com.tangem.tap.domain.userWalletList +package com.tangem.domain.wallets.legacy import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.flow.Flow interface UserWalletsListManager { - /** - * [Flow] with all saved [UserWallet]s updates - * */ + + /** [Flow] with all saved [UserWallet]s updates */ val userWallets: Flow> - /** - * [Flow] with selected [UserWallet] updates - * */ + /** [Flow] with selected [UserWallet] updates */ val selectedUserWallet: Flow - /** - * Selected [UserWallet] - * */ + /** Selected [UserWallet] */ val selectedUserWalletSync: UserWallet? - /** - * Indicates that the [UserWalletsListManager] contains at least one saved [UserWallet] - * */ + /** Indicates that the [UserWalletsListManager] contains at least one saved [UserWallet] */ val hasUserWallets: Boolean - /** - * Count of saved user wallets - */ + /** Count of saved user wallets */ val walletsCount: Int /** @@ -36,78 +27,79 @@ interface UserWalletsListManager { * * @param userWalletId [UserWalletId] of [UserWallet] which must be selected * - * @return [CompletionResult.Success] with selected [UserWallet] - * or [CompletionResult.Failure] with [NoSuchElementException] if [UserWallet] with [userWalletId] not found - * */ + * @return [CompletionResult.Success] with selected [UserWallet] or [CompletionResult.Failure] with + * [NoSuchElementException] if [UserWallet] with [userWalletId] not found + */ suspend fun select(userWalletId: UserWalletId): CompletionResult /** * Save provided user wallet and set it as selected + * * @param userWallet [UserWallet] to save * @param canOverride If false, then terminate with [UserWalletsListError.WalletAlreadySaved] when user tries * to save an already saved card + * * @return [CompletionResult] of operation */ suspend fun save(userWallet: UserWallet, canOverride: Boolean = false): CompletionResult /** - * Same as [save] but not change selected user wallet ID - * and not terminate with [UserWalletsListError.WalletAlreadySaved] if [UserWallet] already saved + * Same as [save] but not change selected user wallet ID and not terminate with + * [UserWalletsListError.WalletAlreadySaved] if [UserWallet] already saved. + * Can terminate with [NoSuchElementException] if unable to find [UserWallet] with provided [UserWalletId]. * - * Can terminate with [NoSuchElementException] if unable to find [UserWallet] with provided [UserWalletId] * @param userWalletId update [UserWallet] with that [UserWalletId] * @param update lambda that receives stored [UserWallet] and returns updated [UserWallet] - * @return [CompletionResult.Success] with updated [UserWallet] - * or [CompletionResult.Failure] with [NoSuchElementException] if [UserWallet] with [userWalletId] not found - * */ + * + * @return [CompletionResult.Success] with updated [UserWallet] or [CompletionResult.Failure] with + * [NoSuchElementException] if [UserWallet] with [userWalletId] not found + */ suspend fun update( userWalletId: UserWalletId, update: suspend (UserWallet) -> UserWallet, ): CompletionResult /** - * Delete saved [UserWallet]s with provided [UserWalletId]s - * - * Sets [isLocked] as true if [userWallets] is empty or if all [userWallets] are locked + * Delete saved [UserWallet]s with provided [UserWalletId]s. + * Sets [isLocked] as true if [userWallets] is empty or if all [userWallets] are locked. * * @param userWalletIds [UserWalletId]s of [UserWallet]s which must be deleted * * @return [CompletionResult] of operation - * */ + */ suspend fun delete(userWalletIds: List): CompletionResult /** * Clear all saved [UserWallet]s and set [isLocked] as true * * @return [CompletionResult] of operation - * */ + */ suspend fun clear(): CompletionResult /** * Get [UserWallet] with provided [UserWalletId] * - * @return [CompletionResult.Success] with found [UserWallet] - * or [CompletionResult.Failure] with [NoSuchElementException] if [UserWallet] with [userWalletId] not found - * */ + * @return [CompletionResult.Success] with found [UserWallet] or [CompletionResult.Failure] with + * [NoSuchElementException] if [UserWallet] with [userWalletId] not found + */ suspend fun get(userWalletId: UserWalletId): CompletionResult interface Lockable : UserWalletsListManager { + /** * Indicates that all [UserWallet]s is locked * * @see [isLockedSync] * @see [UserWallet.isLocked] - * */ + */ val isLocked: Flow /** - * Indicates that all [UserWallet]s is locked - * - * Sync version + * Indicates that all [UserWallet]s is locked. Sync version. * * @see [isLocked] * @see [UserWallet.isLocked] - * */ + */ val isLockedSync: Boolean /** @@ -115,12 +107,10 @@ interface UserWalletsListManager { * * @return [CompletionResult] of operation, with selected [UserWallet] * or null if there is no selected [UserWallet] - * */ + */ suspend fun unlock(): CompletionResult - /** - * Remove [UserWallet]s from [userWallets] and set [isLocked] as true - * */ + /** Remove [UserWallet]s from [userWallets] and set [isLocked] as true */ fun lock() } diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletManagersRepository.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletManagersRepository.kt similarity index 75% rename from app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletManagersRepository.kt rename to domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletManagersRepository.kt index c49f863277..10eb7a6669 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/repository/WalletManagersRepository.kt +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletManagersRepository.kt @@ -1,13 +1,14 @@ -package com.tangem.tap.domain.walletStores.repository +package com.tangem.domain.wallets.legacy import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.WalletManager import com.tangem.common.CompletionResult -import com.tangem.domain.common.util.UserWalletId -import com.tangem.tap.domain.model.UserWallet -import com.tangem.tap.domain.tokens.models.BlockchainNetwork +import com.tangem.domain.common.BlockchainNetwork +import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.models.UserWalletId interface WalletManagersRepository { + suspend fun findOrMakeMultiCurrencyWalletManager( userWallet: UserWallet, blockchainNetwork: BlockchainNetwork, diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletsStateHolder.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletsStateHolder.kt new file mode 100644 index 0000000000..3c7b38bbbe --- /dev/null +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/legacy/WalletsStateHolder.kt @@ -0,0 +1,6 @@ +package com.tangem.domain.wallets.legacy + +interface WalletsStateHolder { + + val userWalletsListManager: UserWalletsListManager? +} \ No newline at end of file diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetWalletsUseCase.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetWalletsUseCase.kt new file mode 100644 index 0000000000..3c589f1bcd --- /dev/null +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetWalletsUseCase.kt @@ -0,0 +1,20 @@ +package com.tangem.domain.wallets.usecase + +import com.tangem.domain.wallets.legacy.WalletsStateHolder +import com.tangem.domain.wallets.models.UserWallet +import kotlinx.coroutines.flow.Flow + +/** + * Use case for getting list of user wallets + * + * @property walletsStateHolder state holder for getting static initialized 'userWalletsListManager' + * +[REDACTED_AUTHOR] + */ +class GetWalletsUseCase(private val walletsStateHolder: WalletsStateHolder) { + + @Throws(IllegalArgumentException::class) + operator fun invoke(): Flow> { + return requireNotNull(walletsStateHolder.userWalletsListManager).userWallets + } +} \ No newline at end of file diff --git a/features/learn2earn/impl/build.gradle.kts b/features/learn2earn/impl/build.gradle.kts index b1c4ef9a5a..26d0179187 100644 --- a/features/learn2earn/impl/build.gradle.kts +++ b/features/learn2earn/impl/build.gradle.kts @@ -10,6 +10,7 @@ plugins { dependencies { /** Core modules */ implementation(project(":common")) + implementation(project(":core:analytics")) implementation(project(":core:featuretoggles")) implementation(project(":core:datasource")) implementation(project(":core:utils")) diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/analytics/Learn2earnEvents.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/analytics/Learn2earnEvents.kt new file mode 100644 index 0000000000..164fa4e793 --- /dev/null +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/analytics/Learn2earnEvents.kt @@ -0,0 +1,70 @@ +package com.tangem.feature.learn2earn.analytics + +import com.tangem.core.analytics.AnalyticsEvent + +internal sealed class Learn2earnEvents( + category: String, + event: String, + params: Map = mapOf(), +) : AnalyticsEvent( + category = category, + event = event, + params = params + mapOf( + "Program Name" to "1inch", + ), +) { + + sealed class IntroductionProcess( + event: String, + params: Map = mapOf(), + ) : Learn2earnEvents( + category = "Introduction Process", + event = event, + params = params, + ) { + class ButtonLearn : IntroductionProcess("Button - Learn") + } + + sealed class MainScreen( + event: String, + params: Map = mapOf(), + ) : Learn2earnEvents( + category = "Main Screen", + event = event, + params = params, + ) { + class NoticeLear2earn(clientType: AnalyticsParam.ClientType) : MainScreen( + event = "Notice - Learn&Earn", + params = mapOf(AnalyticsParam.CLIENT_TYPE to clientType.value), + ) + + class NoticeClaimSuccess : MainScreen("Notice - Claim Successed") + } + + sealed class PromoScreen( + event: String, + params: Map = mapOf(), + ) : Learn2earnEvents( + category = "Promo Screen", + event = event, + params = params, + ) { + class ButtonBuy : PromoScreen("Button - Buy") + + class SuccessScreenOpened(clientType: AnalyticsParam.ClientType) : PromoScreen( + event = "Success Screen Opened", + params = mapOf(AnalyticsParam.CLIENT_TYPE to clientType.value), + ) + } +} + +internal sealed class AnalyticsParam { + sealed class ClientType(val value: String) { + class New : ClientType("New") + class Old : ClientType("Old") + } + + companion object Key { + const val CLIENT_TYPE = "Client type" + } +} \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/di/Learn2earnDataModule.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/di/Learn2earnDataModule.kt index 98cb9f1b9c..186b3c8458 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/di/Learn2earnDataModule.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/di/Learn2earnDataModule.kt @@ -19,7 +19,7 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) -class Learn2earnDataModule { +internal class Learn2earnDataModule { @Provides @Singleton diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/DefaultLearn2earnFeatureToggleManager.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/DefaultLearn2earnFeatureToggleManager.kt new file mode 100644 index 0000000000..19306c2aed --- /dev/null +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/DefaultLearn2earnFeatureToggleManager.kt @@ -0,0 +1,14 @@ +package com.tangem.feature.learn2earn.data.toggles + +import com.tangem.core.featuretoggle.manager.FeatureTogglesManager + +/** +[REDACTED_AUTHOR] + */ +internal class DefaultLearn2earnFeatureToggleManager( + private val featureTogglesManager: FeatureTogglesManager, +) : Learn2earnFeatureToggleManager { + + override val isLearn2earnEnabled: Boolean + get() = featureTogglesManager.isFeatureEnabled(name = "1INCH_LEARN_2_EARN_ENABLED") +} \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/Learn2earnFeatureToggleManager.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/Learn2earnFeatureToggleManager.kt new file mode 100644 index 0000000000..64f5c4abfc --- /dev/null +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/data/toggles/Learn2earnFeatureToggleManager.kt @@ -0,0 +1,11 @@ +package com.tangem.feature.learn2earn.data.toggles + +/** + * Feature toggles manager implementation of "learn2earn" feature + * +[REDACTED_AUTHOR] + */ +interface Learn2earnFeatureToggleManager { + + val isLearn2earnEnabled: Boolean +} \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/DefaultLearn2earnInteractor.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/DefaultLearn2earnInteractor.kt index 6ed2706253..402f88ee82 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/DefaultLearn2earnInteractor.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/DefaultLearn2earnInteractor.kt @@ -1,10 +1,12 @@ package com.tangem.feature.learn2earn.domain import android.net.Uri +import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.datasource.api.promotion.models.AbstractPromotionResponse import com.tangem.datasource.api.promotion.models.PromotionInfoResponse import com.tangem.feature.learn2earn.data.api.Learn2earnRepository import com.tangem.feature.learn2earn.data.models.PromoUserData +import com.tangem.feature.learn2earn.data.toggles.Learn2earnFeatureToggleManager import com.tangem.feature.learn2earn.domain.api.* import com.tangem.feature.learn2earn.domain.models.Promotion import com.tangem.feature.learn2earn.domain.models.PromotionError @@ -16,10 +18,12 @@ import com.tangem.lib.crypto.models.Currency /** [REDACTED_AUTHOR] */ -class DefaultLearn2earnInteractor( +internal class DefaultLearn2earnInteractor( + private val featureToggleManager: Learn2earnFeatureToggleManager, private val repository: Learn2earnRepository, private val userWalletManager: UserWalletManager, private val derivationManager: DerivationManager, + private val analyticsEventHandler: AnalyticsEventHandler, dependencyProvider: Learn2earnDependencyProvider, ) : Learn2earnInteractor { @@ -27,11 +31,17 @@ class DefaultLearn2earnInteractor( private lateinit var promotion: Promotion - private val webViewUriBuilder: WebViewUriBuilder = WebViewUriBuilder( - authCredentialsProvider = dependencyProvider.getWebViewAuthCredentialsProvider(), - userCountryCodeProvider = dependencyProvider.getUserCountryCodeProvider(), - promoCodeProvider = { repository.getUserData().promoCode }, - ) + private val webViewUriBuilder: WebViewUriBuilder by lazy { + WebViewUriBuilder( + authCredentialsProvider = dependencyProvider.getWebViewAuthCredentialsProvider(), + userCountryCodeProvider = dependencyProvider.getUserCountryCodeProvider(), + promoCodeProvider = { repository.getUserData().promoCode }, + ) + } + + private val webViewUriParser: WebViewUriParser by lazy { + WebViewUriParser { repository.getProgramName() } + } override suspend fun init() { initPromotionInfo() @@ -48,8 +58,18 @@ class DefaultLearn2earnInteractor( override suspend fun isNeedToShowViewOnMainScreen(): Boolean { if (!promotionIsActive()) return false - val response = repository.validate(userWalletManager.getWalletId()) - return response.valid == true + val promoCode = repository.getUserData().promoCode + val userWalletId = userWalletManager.getWalletId() + return if (promoCode == null) { + val response = repository.validate(userWalletId) + response.valid == true + } else { + val response = repository.validateCode(userWalletId, promoCode) + when (val error = response.error?.toDomainError()) { + null -> response.valid == true + else -> error !is PromotionError.CodeWasNotAppliedInShop + } + } } override fun isUserRegisteredInPromotion(): Boolean { @@ -63,6 +83,11 @@ class DefaultLearn2earnInteractor( return awardAmount } + override fun getAwardNetworkName(): String { + val networkId = promotion.getPromotionInfo().awardPaymentToken.networkId + return userWalletManager.getNativeTokenForNetwork(networkId).name + } + @Throws(IllegalArgumentException::class) override suspend fun requestAward(): Result { val awardCurrency = getCurrencyForAward() @@ -166,32 +191,34 @@ class DefaultLearn2earnInteractor( return HeadersConverter().convert(webViewUriBuilder.getBasicAuthHeaders()) } - override fun handleRedirect(uri: Uri): RedirectConsequences { - if (webViewUriBuilder.isReadyForExistedCardAwardRedirect(uri)) { - updateUserData { it.copy(isRegisteredInPromotion = true) } - webViewResultHandler?.handleResult(WebViewResult.ReadyForAward) - return RedirectConsequences.FINISH_SESSION - } - - return if (webViewUriBuilder.isPromoCodeRedirect(uri)) { - webViewUriBuilder.extractPromoCode(uri)?.let { code -> + override fun handleRedirect(uri: Uri): WebViewAction { + val result = webViewUriParser.parse(uri) + when (result) { + is WebViewResult.PromoCode -> { updateUserData { it.copy( - promoCode = code, + promoCode = result.promoCode, isRegisteredInPromotion = true, ) } - webViewResultHandler?.handleResult(WebViewResult.PromoCodeReceived) } - RedirectConsequences.NOTHING - } else { - RedirectConsequences.PROCEED + WebViewResult.ReadyForAward -> { + updateUserData { it.copy(isRegisteredInPromotion = true) } + } + is WebViewResult.Learn2earnAnalyticsEvent -> { + analyticsEventHandler.send(result.event) + } + WebViewResult.Empty -> Unit } + webViewResultHandler?.handleResult(result) + + return result.toWebViewAction() } private fun promotionIsActive(): Boolean { val userData = repository.getUserData() val isActive = when { + !featureToggleManager.isLearn2earnEnabled -> false userData.isAlreadyReceivedAward -> false promotion.isError() -> false else -> { @@ -204,34 +231,41 @@ class DefaultLearn2earnInteractor( } private suspend fun initPromotionInfo() { - promotion = repository.getPromotionInfo() - .fold( - onSuccess = { response -> - val responseError = response.error - if (responseError == null) { - val npeMessage = { "Shouldn't be null" } - Promotion( - info = Promotion.PromotionInfo( - newCard = requireNotNull(response.newCard, npeMessage), - oldCard = requireNotNull(response.oldCard, npeMessage), - awardPaymentToken = requireNotNull(response.awardPaymentToken, npeMessage), - ), - error = null, - ) - } else { + promotion = if (featureToggleManager.isLearn2earnEnabled) { + repository.getPromotionInfo() + .fold( + onSuccess = { response -> + val responseError = response.error + if (responseError == null) { + val npeMessage = { "Shouldn't be null" } + Promotion( + info = Promotion.PromotionInfo( + newCard = requireNotNull(response.newCard, npeMessage), + oldCard = requireNotNull(response.oldCard, npeMessage), + awardPaymentToken = requireNotNull(response.awardPaymentToken, npeMessage), + ), + error = null, + ) + } else { + Promotion( + info = null, + error = responseError.toDomainError(), + ) + } + }, + onFailure = { Promotion( info = null, - error = responseError.toDomainError(), + error = PromotionError.NetworkUnreachable, ) - } - }, - onFailure = { - Promotion( - info = null, - error = PromotionError.NetworkUnreachable, - ) - }, + }, + ) + } else { + Promotion( + info = null, + error = null, ) + } } private fun getCurrencyForAward(): Currency? { @@ -252,12 +286,21 @@ class DefaultLearn2earnInteractor( repository.updateUserData(this) } } -} -private fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data { - return if (promoCode == null) { - newCard - } else { - oldCard + private fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data { + return if (promoCode == null) { + newCard + } else { + oldCard + } + } + + private fun WebViewResult.toWebViewAction(): WebViewAction { + return when (this) { + WebViewResult.Empty -> WebViewAction.PROCEED + WebViewResult.ReadyForAward -> WebViewAction.FINISH_SESSION + is WebViewResult.Learn2earnAnalyticsEvent -> WebViewAction.NOTHING + is WebViewResult.PromoCode -> WebViewAction.NOTHING + } } } \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriBuilder.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriBuilder.kt index 5af98601aa..0b2f6f6450 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriBuilder.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriBuilder.kt @@ -39,41 +39,15 @@ internal class WebViewUriBuilder( } } - fun isPromoCodeRedirect(uri: Uri): Boolean { - return uri.toString().contains(SUFFIX_CODE_CREATED) - } - - fun isReadyForExistedCardAwardRedirect(uri: Uri): Boolean { - return uri.toString().endsWith(SUFFIX_READY_FOR_AWARD) - } - - fun extractPromoCode(uri: Uri): String? { - val url = uri.toString() - - return if (isPromoCodeRedirect(uri)) { - val replaceString = makeWebViewUriBuilder().build().toString() + SUFFIX_CODE_CREATED - val code = url.replace(replaceString, "") - code - } else { - null - } - } - - private fun makeWebViewUriBuilder(): Uri.Builder { - val builder = Uri.Builder() - builder.scheme(SCHEME) - + private fun makeWebViewUriBuilder(): Uri.Builder = Uri.Builder().apply { + scheme(SCHEME) if (BuildConfig.DEBUG) { - builder.authority(DEV_BASE_URL) - builder.appendPath(userCountryCodeProvider.invoke()) - builder.appendPath(DEV_PATH_PROMOTION) + authority(DEV_BASE_URL) } else { - builder.authority(BASE_URL) - builder.appendPath(userCountryCodeProvider.invoke()) - builder.appendPath(PATH_PROMOTION) + authority(BASE_URL) } - - return builder + appendPath(userCountryCodeProvider.invoke()) + appendPath(PATH_PROMOTION) } private companion object { @@ -86,9 +60,5 @@ internal class WebViewUriBuilder( const val QUERY_EXISTED_CARD = "existed-card" const val DEV_BASE_URL = "devweb.tangem.com" - const val DEV_PATH_PROMOTION = "promotion-test" - - const val SUFFIX_CODE_CREATED = "/code-created?code=" - const val SUFFIX_READY_FOR_AWARD = "/ready-for-existed-card-award" } } \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriParser.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriParser.kt new file mode 100644 index 0000000000..f8d1d18e22 --- /dev/null +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/WebViewUriParser.kt @@ -0,0 +1,91 @@ +package com.tangem.feature.learn2earn.domain + +import android.net.Uri +import com.tangem.feature.learn2earn.analytics.AnalyticsParam +import com.tangem.feature.learn2earn.analytics.Learn2earnEvents +import com.tangem.feature.learn2earn.analytics.Learn2earnEvents.PromoScreen +import com.tangem.feature.learn2earn.domain.api.WebViewResult + +/** +[REDACTED_AUTHOR] + */ +internal class WebViewUriParser( + private val programNameProvider: () -> String, +) { + + fun parse(uri: Uri): WebViewResult = when { + isAnalyticsRedirect(uri) -> { + val event = extractAnalyticsEvent(uri) + if (event == null) { + WebViewResult.Empty + } else { + WebViewResult.Learn2earnAnalyticsEvent(event) + } + } + isPromoCodeRedirect(uri) -> { + val promoCode = extractPromoCode(uri) + if (promoCode == null) { + WebViewResult.Empty + } else { + WebViewResult.PromoCode(promoCode) + } + } + isReadyForAwardRedirect(uri) -> { + WebViewResult.ReadyForAward + } + else -> WebViewResult.Empty + } + + private fun isReadyForAwardRedirect(uri: Uri): Boolean { + return uri.lastPathSegment == PATH_READY_FOR_AWARD + } + + private fun isPromoCodeRedirect(uri: Uri): Boolean { + return uri.lastPathSegment == PATH_PROMO_CODE_CREATED && + uri.queryParameterNames.contains(QUERY_PROMO_CODE) + } + + private fun extractPromoCode(uri: Uri): String? { + return if (isPromoCodeRedirect(uri)) { + uri.getQueryParameter(QUERY_PROMO_CODE) + } else { + null + } + } + + private fun isAnalyticsRedirect(uri: Uri): Boolean { + return uri.lastPathSegment == PATH_ANALYTICS && + uri.queryParameterNames.contains(QUERY_ANALYTICS_EVENT) + } + + private fun extractAnalyticsEvent(uri: Uri): Learn2earnEvents? { + if (!isAnalyticsRedirect(uri)) return null + + val programName = uri.getQueryParameter(QUERY_PROGRAM_NAME) ?: return null + if (programName != programNameProvider.invoke()) return null + + val event = uri.getQueryParameter(QUERY_ANALYTICS_EVENT) ?: return null + + val analyticsEvent = when (event) { + EVENT_PROMO_BUY -> PromoScreen.ButtonBuy() + EVENT_PROMO_SUCCESS_NEW_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.New()) + EVENT_PROMO_SUCCESS_OLD_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.Old()) + else -> null + } + return analyticsEvent + } + + private companion object { + const val PATH_PROMO_CODE_CREATED = "code-created" + const val PATH_READY_FOR_AWARD = "ready-for-existed-card-award" + const val PATH_ANALYTICS = "analytics" + + const val QUERY_PROMO_CODE = "code" + const val QUERY_ANALYTICS_EVENT = "event" + const val QUERY_PROGRAM_NAME = "programName" + + const val EVENT_PROMO_BUY = "promotion-buy" + const val EVENT_PROMO_SUCCESS_NEW_USER = "promotion-success-new-user" + const val EVENT_PROMO_SUCCESS_OLD_USER = "promotion-success-old-user" + } +} \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/Learn2earnInteractor.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/Learn2earnInteractor.kt index 2cdadbb236..95bb9d7ad9 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/Learn2earnInteractor.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/Learn2earnInteractor.kt @@ -21,6 +21,8 @@ interface Learn2earnInteractor : WebViewRedirectHandler { fun getAwardAmount(): Int + fun getAwardNetworkName(): String + @Throws(IllegalArgumentException::class) suspend fun requestAward(): Result diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewRedirectHandler.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewRedirectHandler.kt index efca9c182a..6f2fe55945 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewRedirectHandler.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewRedirectHandler.kt @@ -9,10 +9,10 @@ import android.net.Uri [REDACTED_AUTHOR] */ interface WebViewRedirectHandler { - fun handleRedirect(uri: Uri): RedirectConsequences + fun handleRedirect(uri: Uri): WebViewAction } -enum class RedirectConsequences { +enum class WebViewAction { NOTHING, PROCEED, FINISH_SESSION, diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewResultHandler.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewResultHandler.kt index 08a749f327..6b7c851a69 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewResultHandler.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/api/WebViewResultHandler.kt @@ -1,5 +1,7 @@ package com.tangem.feature.learn2earn.domain.api +import com.tangem.core.analytics.AnalyticsEvent + /** * Handler that helps determine a result of the Learn2earnWebViewActivity webView actions. * @@ -10,6 +12,8 @@ interface WebViewResultHandler { } sealed class WebViewResult { - object PromoCodeReceived : WebViewResult() + object Empty : WebViewResult() + data class PromoCode(val promoCode: String) : WebViewResult() object ReadyForAward : WebViewResult() + data class Learn2earnAnalyticsEvent(val event: AnalyticsEvent) : WebViewResult() } \ No newline at end of file diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/di/Learn2earnDomainModule.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/di/Learn2earnDomainModule.kt index 7ae76d3a19..72c05a6953 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/di/Learn2earnDomainModule.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/di/Learn2earnDomainModule.kt @@ -1,7 +1,11 @@ package com.tangem.feature.learn2earn.domain.di import android.content.Context +import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.core.featuretoggle.manager.FeatureTogglesManager import com.tangem.feature.learn2earn.data.api.Learn2earnRepository +import com.tangem.feature.learn2earn.data.toggles.DefaultLearn2earnFeatureToggleManager +import com.tangem.feature.learn2earn.data.toggles.Learn2earnFeatureToggleManager import com.tangem.feature.learn2earn.domain.DefaultLearn2earnInteractor import com.tangem.feature.learn2earn.domain.api.Learn2earnDependencyProvider import com.tangem.feature.learn2earn.domain.api.Learn2earnInteractor @@ -18,7 +22,7 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) -class Learn2earnDomainModule { +internal class Learn2earnDomainModule { @Provides @Singleton @@ -26,18 +30,28 @@ class Learn2earnDomainModule { return Learn2earnRouter(context) } + @Provides + @Singleton + fun provideFeatureToggle(featureToggleManager: FeatureTogglesManager): Learn2earnFeatureToggleManager { + return DefaultLearn2earnFeatureToggleManager(featureToggleManager) + } + @Provides @Singleton fun provideInteractor( + featureToggleManager: Learn2earnFeatureToggleManager, repository: Learn2earnRepository, dependencyProvider: Learn2earnDependencyProvider, userWalletManager: UserWalletManager, + analyticsEventHandler: AnalyticsEventHandler, derivationManager: DerivationManager, ): Learn2earnInteractor { return DefaultLearn2earnInteractor( + featureToggleManager = featureToggleManager, repository = repository, userWalletManager = userWalletManager, derivationManager = derivationManager, + analyticsEventHandler = analyticsEventHandler, dependencyProvider = dependencyProvider, ) } diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/models/Promotion.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/models/Promotion.kt index 5fc46b4e11..463001cb21 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/models/Promotion.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/domain/models/Promotion.kt @@ -5,7 +5,7 @@ import com.tangem.datasource.api.promotion.models.PromotionInfoResponse /** [REDACTED_AUTHOR] */ -data class Promotion( +internal data class Promotion( val info: PromotionInfo?, val error: PromotionError?, ) { diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/Learn2earnViewModel.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/Learn2earnViewModel.kt index cb99ddef44..8c3cbfb221 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/Learn2earnViewModel.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/Learn2earnViewModel.kt @@ -5,6 +5,9 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.feature.learn2earn.analytics.AnalyticsParam +import com.tangem.feature.learn2earn.analytics.Learn2earnEvents import com.tangem.feature.learn2earn.domain.api.Learn2earnInteractor import com.tangem.feature.learn2earn.domain.api.WebViewResult import com.tangem.feature.learn2earn.domain.api.WebViewResultHandler @@ -25,6 +28,7 @@ class Learn2earnViewModel @Inject constructor( private val interactor: Learn2earnInteractor, private val router: Learn2earnRouter, private val dispatchers: AppCoroutineDispatcherProvider, + private val analytics: AnalyticsEventHandler, ) : ViewModel() { var uiState: Learn2earnState by mutableStateOf( @@ -45,6 +49,10 @@ class Learn2earnViewModel @Inject constructor( updateMainScreenViews() } + fun onMainScreenRefreshed() { + updateMainScreenViews() + } + private fun updateMainScreenViews() { viewModelScope.launch(dispatchers.io) { if (interactor.isNeedToShowViewOnMainScreen()) { @@ -59,16 +67,19 @@ class Learn2earnViewModel @Inject constructor( } private fun onButtonStoryClick() { + analytics.send(Learn2earnEvents.IntroductionProcess.ButtonLearn()) router.openWebView(interactor.buildUriForNewUser(), interactor.getBasicAuthHeaders()) } private fun onButtonMainClick() { if (!interactor.isUserHadPromoCode() && !interactor.isUserRegisteredInPromotion()) { + analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.New())) subscribeToWebViewResultEvents() router.openWebView(interactor.buildUriForOldUser(), interactor.getBasicAuthHeaders()) return } + analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.Old())) viewModelScope.launch(dispatchers.io) { updateUi { uiState.updateProgress(showProgress = true) } @@ -76,11 +87,13 @@ class Learn2earnViewModel @Inject constructor( .onSuccess { requestAwardResult -> requestAwardResult.fold( onSuccess = { + analytics.send(Learn2earnEvents.MainScreen.NoticeClaimSuccess()) val onHideDialog = { uiState = uiState.updateGetBonusVisibility(isVisible = false) .hideDialog() } val successDialog = MainScreenState.Dialog.Claimed( + networkFullName = interactor.getAwardNetworkName(), onOk = onHideDialog, onDismissRequest = onHideDialog, ) @@ -159,9 +172,8 @@ class Learn2earnViewModel @Inject constructor( interactor.webViewResultHandler = object : WebViewResultHandler { override fun handleResult(result: WebViewResult) { interactor.webViewResultHandler = null - when (result) { - WebViewResult.ReadyForAward -> updateMainScreenViews() - WebViewResult.PromoCodeReceived -> Unit + if (result is WebViewResult.ReadyForAward) { + updateMainScreenViews() } } } diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnDialogs.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnDialogs.kt index 2f752ea0fd..9a21f29231 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnDialogs.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnDialogs.kt @@ -28,7 +28,7 @@ private fun ClaimedDialog(dialog: MainScreenState.Dialog.Claimed) { Text(text = stringResource(id = R.string.common_success)) }, text = { - Text(text = stringResource(id = R.string.main_promotion_credited)) + Text(text = stringResource(id = R.string.main_promotion_credited, dialog.networkFullName)) }, confirmButton = { TextButton( diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnStoriesScreen.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnStoriesScreen.kt index 4793bcfbc4..b91ffaf2f5 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnStoriesScreen.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/Learn2earnStoriesScreen.kt @@ -32,26 +32,34 @@ fun Learn2earnStoriesScreen(onLearnClick: () -> Unit, modifier: Modifier = Modif .fillMaxSize() .align(Alignment.Center), ) - StoryDescription( - modifier = Modifier - .padding(horizontal = TangemTheme.dimens.size40) - .fillMaxSize(), - headerText = stringResource(id = R.string.story_learn_title), - bodyText = stringResource(id = R.string.story_learn_description), - ) - Image( - modifier = Modifier - .padding(bottom = TangemTheme.dimens.size68) - .align(Alignment.BottomCenter), - painter = painterResource(id = R.drawable.img_1inch_logo_401_378), - contentDescription = null, - ) + Column( + modifier = Modifier.fillMaxSize(), + ) { + StoryDescription( + modifier = Modifier + .padding(horizontal = TangemTheme.dimens.size40) + .weight(weight = 1f), + headerText = stringResource(id = R.string.common_learn_and_earn), + bodyText = stringResource(id = R.string.story_learn_description), + ) + Image( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = TangemTheme.dimens.size16) + .navigationBarsPadding() + .weight(weight = 1.2f), + painter = painterResource(id = R.drawable.img_1inch_logo_401_378), + contentDescription = null, + ) + } + SecondaryButton( modifier = Modifier .padding(horizontal = TangemTheme.dimens.size16) - .padding(bottom = TangemTheme.dimens.size84) + .padding(bottom = TangemTheme.dimens.size36) .fillMaxWidth() - .align(Alignment.BottomCenter), + .align(Alignment.BottomCenter) + .navigationBarsPadding(), text = stringResource(id = R.string.story_learn_learn), onClick = onLearnClick, ) diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/state/Learn2earnState.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/state/Learn2earnState.kt index 7c1ba34c55..4ba08f14bb 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/state/Learn2earnState.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/ui/state/Learn2earnState.kt @@ -37,12 +37,12 @@ data class MainScreenState( sealed class Description(val title: TextReference, val subtitle: TextReference) { class Learn(award: Int) : Description( - TextReference.Res(R.string.main_learn_title), + TextReference.Res(R.string.common_learn_and_earn), TextReference.PluralRes(R.plurals.main_learn_subtitle, award, WrappedList(listOf(award))), ) object GetBonus : Description( - TextReference.Res(R.string.main_get_bonus_title), + TextReference.Res(R.string.common_learn_and_earn), TextReference.Res(R.string.main_get_bonus_subtitle), ) } @@ -50,6 +50,7 @@ data class MainScreenState( sealed class Dialog { data class Claimed( + val networkFullName: String, val onOk: () -> Unit, val onDismissRequest: () -> Unit, ) : Dialog() diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewActivity.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewActivity.kt index cea693607e..7300fcdb06 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewActivity.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewActivity.kt @@ -38,7 +38,7 @@ class Learn2earnWebViewActivity : AppCompatActivity() { webView.settings.loadsImagesAutomatically = true webView.webViewClient = Learn2earnWebViewClient( - helper = viewModel, + redirectHandler = viewModel, headers = webViewData.headers, finishSessionHandler = { finish() }, ) diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewClient.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewClient.kt index 5957d80a32..7a96dbc90b 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewClient.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/Learn2earnWebViewClient.kt @@ -3,28 +3,28 @@ package com.tangem.feature.learn2earn.presentation.webView import android.webkit.WebResourceRequest import android.webkit.WebView import android.webkit.WebViewClient -import com.tangem.feature.learn2earn.domain.api.RedirectConsequences +import com.tangem.feature.learn2earn.domain.api.WebViewAction import com.tangem.feature.learn2earn.domain.api.WebViewRedirectHandler import timber.log.Timber internal class Learn2earnWebViewClient( - private val helper: WebViewRedirectHandler, + private val redirectHandler: WebViewRedirectHandler, private val headers: Map, private val finishSessionHandler: () -> Unit, ) : WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { Timber.d("url: ${request.url}") - when (helper.handleRedirect(request.url)) { - RedirectConsequences.PROCEED -> { + when (redirectHandler.handleRedirect(request.url)) { + WebViewAction.NOTHING -> Unit + WebViewAction.PROCEED -> { val mergedHeaders = headers.toMutableMap() request.requestHeaders?.let { mergedHeaders.putAll(it) } view.loadUrl(request.url.toString(), mergedHeaders) } - RedirectConsequences.FINISH_SESSION -> { + WebViewAction.FINISH_SESSION -> { finishSessionHandler.invoke() } - else -> Unit } return true } diff --git a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/WebViewViewModel.kt b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/WebViewViewModel.kt index 3b25e78a58..f6daa6c3ef 100644 --- a/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/WebViewViewModel.kt +++ b/features/learn2earn/impl/src/main/java/com/tangem/feature/learn2earn/presentation/webView/WebViewViewModel.kt @@ -4,7 +4,6 @@ import android.content.Intent import android.net.Uri import androidx.lifecycle.ViewModel import com.tangem.feature.learn2earn.domain.HeadersConverter -import com.tangem.feature.learn2earn.domain.api.RedirectConsequences import com.tangem.feature.learn2earn.domain.api.WebViewRedirectHandler import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -14,12 +13,8 @@ import javax.inject.Inject */ @HiltViewModel internal class WebViewViewModel @Inject constructor( - private val handler: WebViewRedirectHandler, -) : ViewModel(), WebViewRedirectHandler { - - override fun handleRedirect(uri: Uri): RedirectConsequences { - return handler.handleRedirect(uri) - } + handler: WebViewRedirectHandler, +) : ViewModel(), WebViewRedirectHandler by handler { fun extractData(intent: Intent): WebViewData { val uriString = requireNotNull(intent.getStringExtra(Learn2earnWebViewActivity.EXTRA_WEB_URI)) { diff --git a/features/learn2earn/impl/src/main/res/layout/activity_web_view.xml b/features/learn2earn/impl/src/main/res/layout/activity_web_view.xml index d4020201c8..8737917c56 100644 --- a/features/learn2earn/impl/src/main/res/layout/activity_web_view.xml +++ b/features/learn2earn/impl/src/main/res/layout/activity_web_view.xml @@ -1,7 +1,7 @@ @@ -10,21 +10,29 @@ android:id="@+id/app_bar" style="@style/Widget.MaterialComponents.Toolbar.Surface" android:layout_width="match_parent" - app:liftOnScroll="true" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + app:elevation="0dp"> - + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + + + \ No newline at end of file diff --git a/features/tokendetails/api/.gitignore b/features/tokendetails/api/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/features/tokendetails/api/.gitignore @@ -0,0 +1 @@ +/build diff --git a/features/tokendetails/api/build.gradle.kts b/features/tokendetails/api/build.gradle.kts new file mode 100644 index 0000000000..b7c1f22eeb --- /dev/null +++ b/features/tokendetails/api/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} + +android { + namespace = "com.tangem.features.tokendetails.api" +} + +dependencies { + /** AndroidX */ + implementation(deps.androidx.fragment.ktx) +} \ No newline at end of file diff --git a/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/featuretoggles/TokenDetailsFeatureToggles.kt b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/featuretoggles/TokenDetailsFeatureToggles.kt new file mode 100644 index 0000000000..751dabea32 --- /dev/null +++ b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/featuretoggles/TokenDetailsFeatureToggles.kt @@ -0,0 +1,5 @@ +package com.tangem.features.tokendetails.featuretoggles + +interface TokenDetailsFeatureToggles { + val isRedesignedScreenEnabled: Boolean +} \ No newline at end of file diff --git a/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsRouter.kt b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsRouter.kt new file mode 100644 index 0000000000..a361d75438 --- /dev/null +++ b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsRouter.kt @@ -0,0 +1,8 @@ +package com.tangem.features.tokendetails.navigation + +import androidx.fragment.app.Fragment + +interface TokenDetailsRouter { + + fun getEntryFragment(): Fragment +} \ No newline at end of file diff --git a/features/tokendetails/impl/.gitignore b/features/tokendetails/impl/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/features/tokendetails/impl/.gitignore @@ -0,0 +1 @@ +/build diff --git a/features/tokendetails/impl/build.gradle.kts b/features/tokendetails/impl/build.gradle.kts new file mode 100644 index 0000000000..aa624c46ac --- /dev/null +++ b/features/tokendetails/impl/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.hilt.android) + id("configuration") +} + +android { + namespace = "com.tangem.features.tokendetails.impl" +} + + +dependencies { + /** AndroidX */ + implementation(deps.androidx.activity.compose) + + /** Compose */ + implementation(deps.compose.material) + implementation(deps.compose.foundation) + implementation(deps.compose.material3) + implementation(deps.compose.navigation) + implementation(deps.compose.navigation.hilt) + implementation(deps.compose.ui) + implementation(deps.compose.ui.tooling) + implementation(deps.compose.accompanist.systemUiController) + + /** DI */ + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) + + /** Core modules */ + implementation(projects.core.featuretoggles) + implementation(projects.core.ui) + + /** Feature Apis */ + implementation(projects.features.tokendetails.api) +} \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsFeatureTogglesModule.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsFeatureTogglesModule.kt new file mode 100644 index 0000000000..767b02d8a6 --- /dev/null +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsFeatureTogglesModule.kt @@ -0,0 +1,21 @@ +package com.tangem.feature.tokendetails.di + +import com.tangem.core.featuretoggle.manager.FeatureTogglesManager +import com.tangem.feature.tokendetails.featuretoggles.DefaultTokenDetailsFeatureToggles +import com.tangem.features.tokendetails.featuretoggles.TokenDetailsFeatureToggles +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object TokenDetailsFeatureTogglesModule { + + @Provides + @Singleton + fun provideTokenDetailsFeatureToggles(featureTogglesManager: FeatureTogglesManager): TokenDetailsFeatureToggles { + return DefaultTokenDetailsFeatureToggles(featureTogglesManager = featureTogglesManager) + } +} \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsRouterModule.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsRouterModule.kt new file mode 100644 index 0000000000..47a8b90f2e --- /dev/null +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/di/TokenDetailsRouterModule.kt @@ -0,0 +1,18 @@ +package com.tangem.feature.tokendetails.di + +import com.tangem.feature.tokendetails.presentation.router.DefaultTokenDetailsRouter +import com.tangem.features.tokendetails.navigation.TokenDetailsRouter +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ActivityComponent +import dagger.hilt.android.scopes.ActivityScoped + +@Module +@InstallIn(ActivityComponent::class) +internal object TokenDetailsRouterModule { + + @Provides + @ActivityScoped + fun provideTokenDetailsRouter(): TokenDetailsRouter = DefaultTokenDetailsRouter() +} \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/featuretoggles/DefaultTokenDetailsFeatureToggles.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/featuretoggles/DefaultTokenDetailsFeatureToggles.kt new file mode 100644 index 0000000000..2ac8bd5fde --- /dev/null +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/featuretoggles/DefaultTokenDetailsFeatureToggles.kt @@ -0,0 +1,14 @@ +package com.tangem.feature.tokendetails.featuretoggles + +import com.tangem.core.featuretoggle.manager.FeatureTogglesManager +import com.tangem.features.tokendetails.featuretoggles.TokenDetailsFeatureToggles + +private const val REDESIGNED_TOKEN_DETAIL_SCREEN_ENABLED_KEY = "REDESIGNED_TOKEN_DETAIL_SCREEN_ENABLED" + +internal class DefaultTokenDetailsFeatureToggles( + private val featureTogglesManager: FeatureTogglesManager, +) : TokenDetailsFeatureToggles { + + override val isRedesignedScreenEnabled: Boolean + get() = featureTogglesManager.isFeatureEnabled(name = REDESIGNED_TOKEN_DETAIL_SCREEN_ENABLED_KEY) +} \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt new file mode 100644 index 0000000000..6bfaf4dcaa --- /dev/null +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt @@ -0,0 +1,10 @@ +package com.tangem.feature.tokendetails.presentation.router + +import androidx.fragment.app.Fragment +import com.tangem.features.tokendetails.navigation.TokenDetailsRouter + +internal class DefaultTokenDetailsRouter : TokenDetailsRouter { + + // TODO: Doston fix it in next PRs + override fun getEntryFragment(): Fragment = Fragment() +} \ No newline at end of file diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index b8bbf291ab..2e5651a89c 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -9,6 +9,7 @@ plugins { dependencies { /** AndroidX */ implementation(deps.androidx.activity.compose) + implementation(deps.material) /** Compose */ implementation(deps.compose.coil) @@ -26,6 +27,7 @@ dependencies { /** Other libraries */ implementation(deps.kotlin.immutable.collections) + implementation(deps.tangem.blockchain) /** DI */ implementation(deps.hilt.android) @@ -33,8 +35,16 @@ dependencies { /** Core modules */ implementation(project(":core:featuretoggles")) + implementation(project(":core:navigation")) implementation(project(":core:ui")) /** Feature Apis */ implementation(project(":features:wallet:api")) + + /** Domain modules */ + implementation(project(":common")) + implementation(project(":domain:legacy")) + implementation(project(":domain:models")) + implementation(project(":domain:wallets")) + implementation(project(":domain:wallets:models")) } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/di/WalletRouterModule.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/di/WalletRouterModule.kt index d981abb47b..721bffead3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/di/WalletRouterModule.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/di/WalletRouterModule.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.di +import com.tangem.core.navigation.NavigationStateHolder import com.tangem.feature.wallet.presentation.router.DefaultWalletRouter import com.tangem.features.wallet.navigation.WalletRouter import dagger.Module @@ -14,5 +15,7 @@ internal object WalletRouterModule { @Provides @ActivityScoped - fun provideWalletRouter(): WalletRouter = DefaultWalletRouter() + fun provideWalletRouter(navigationStateHolder: NavigationStateHolder): WalletRouter { + return DefaultWalletRouter(navigationStateHolder = navigationStateHolder) + } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/WalletFragment.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/WalletFragment.kt index 954467d0fe..f33c221c8d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/WalletFragment.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/WalletFragment.kt @@ -1,12 +1,12 @@ package com.tangem.feature.wallet.presentation import android.os.Bundle -import android.transition.TransitionInflater import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment +import androidx.transition.TransitionInflater import com.tangem.core.ui.components.SystemBarsEffect import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.impl.R @@ -47,7 +47,7 @@ internal class WalletFragment : Fragment() { } isTransitionGroup = true - _walletRouter.Initialize() + _walletRouter.Initialize(fragmentManager = requireActivity().supportFragmentManager) } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index fb462feaa9..6f6b726f82 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -2,6 +2,7 @@ package com.tangem.feature.wallet.presentation.common import com.tangem.core.ui.R import com.tangem.core.ui.components.transactions.TransactionState +import com.tangem.feature.wallet.presentation.common.state.PriceChangeConfig import com.tangem.feature.wallet.presentation.common.state.TokenItemState import com.tangem.feature.wallet.presentation.common.state.TokenItemState.TokenOptionsState import com.tangem.feature.wallet.presentation.organizetokens.DraggableItem @@ -70,9 +71,9 @@ internal object WalletPreviewData { hasPending = true, tokenOptions = TokenOptionsState.Visible( fiatAmount = "321 $", - priceChange = TokenOptionsState.PriceChange( - valuePercent = "2%", - type = TokenOptionsState.PriceChange.Type.UP, + priceChange = PriceChangeConfig( + valueInPercent = "2%", + type = PriceChangeConfig.Type.UP, ), ), ) @@ -86,9 +87,9 @@ internal object WalletPreviewData { amount = "5,412 MATIC", hasPending = true, tokenOptions = TokenOptionsState.Hidden( - priceChange = TokenOptionsState.PriceChange( - valuePercent = "2%", - type = TokenOptionsState.PriceChange.Type.UP, + priceChange = PriceChangeConfig( + valueInPercent = "2%", + type = PriceChangeConfig.Type.UP, ), ), ) @@ -110,7 +111,7 @@ internal object WalletPreviewData { name = "Polygon", ) - val loadingTokenItemState = TokenItemState.Loading(id = UUID.randomUUID().toString()) + val loadingTokenItemState = TokenItemState.Loading private const val networksSize = 10 private const val tokensSize = 3 @@ -203,6 +204,15 @@ internal object WalletPreviewData { WalletManageButton.CopyAddress(onClick = {}), ) + val marketplaceBlockContent = WalletMarketplaceBlockState.Content( + currencyName = "BTC", + price = "0.11$", + priceChangeConfig = PriceChangeConfig( + valueInPercent = "5.16%", + type = PriceChangeConfig.Type.UP, + ), + ) + val multicurrencyWalletScreenState = WalletStateHolder.MultiCurrencyContent( onBackClick = {}, topBarConfig = walletTopBarConfig, @@ -271,7 +281,7 @@ internal object WalletPreviewData { walletsListConfig = walletListConfig, contentItems = persistentListOf( WalletContentItemState.SingleCurrencyItem.Title(onExploreClick = {}), - WalletContentItemState.SingleCurrencyItem.TransactionGroupTitle("Today"), + WalletContentItemState.SingleCurrencyItem.GroupTitle("Today"), WalletContentItemState.SingleCurrencyItem.Transaction( TransactionState.Sending( address = "33BddS...ga2B", @@ -279,7 +289,7 @@ internal object WalletPreviewData { timestamp = "8:41", ), ), - WalletContentItemState.SingleCurrencyItem.TransactionGroupTitle("Yesterday"), + WalletContentItemState.SingleCurrencyItem.GroupTitle("Yesterday"), WalletContentItemState.SingleCurrencyItem.Transaction( TransactionState.Sending( address = "33BddS...ga2B", @@ -290,5 +300,6 @@ internal object WalletPreviewData { ), notifications = persistentListOf(WalletNotification.LikeTangemApp(onClick = {})), buttons = manageButtons, + marketplaceBlockState = marketplaceBlockContent, ) } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt index e615c7dedb..62b877549a 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt @@ -32,6 +32,7 @@ import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemTypography import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.WalletPreviewData +import com.tangem.feature.wallet.presentation.common.state.PriceChangeConfig import com.tangem.feature.wallet.presentation.common.state.TokenItemState import com.tangem.feature.wallet.presentation.common.state.TokenItemState.TokenOptionsState import org.burnoutcrew.reorderable.ReorderableLazyListState @@ -318,7 +319,7 @@ private fun TokenTitleAmountBlock(title: String, amount: String?, hasPending: Bo @Composable private fun TokenFiatPercentageBlock( fiatAmount: String, - priceChange: TokenOptionsState.PriceChange, + priceChange: PriceChangeConfig, modifier: Modifier = Modifier, ) { Column(modifier = modifier.requiredWidth(IntrinsicSize.Max)) { @@ -336,11 +337,11 @@ private fun TokenFiatPercentageBlock( val iconChangeArrow: Int val changeTextColor: Color when (priceChange.type) { - TokenOptionsState.PriceChange.Type.UP -> { + PriceChangeConfig.Type.UP -> { iconChangeArrow = R.drawable.img_arrow_up_8 changeTextColor = TangemTheme.colors.text.accent } - TokenOptionsState.PriceChange.Type.DOWN -> { + PriceChangeConfig.Type.DOWN -> { iconChangeArrow = R.drawable.img_arrow_down_8 changeTextColor = TangemTheme.colors.text.warning } @@ -353,7 +354,7 @@ private fun TokenFiatPercentageBlock( SpacerW4() Text( modifier = Modifier.align(Alignment.CenterVertically), - text = priceChange.valuePercent, + text = priceChange.valueInPercent, style = TangemTypography.body2, color = changeTextColor, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/PriceChangeConfig.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/PriceChangeConfig.kt new file mode 100644 index 0000000000..9d6b4989ee --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/PriceChangeConfig.kt @@ -0,0 +1,15 @@ +package com.tangem.feature.wallet.presentation.common.state + +/** + * Price changing config + * + * @property valueInPercent value in percent + * @property type type [Type] + */ +internal data class PriceChangeConfig(val valueInPercent: String, val type: Type) { + + /** Price changing type */ + enum class Type { + UP, DOWN + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/TokenItemState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/TokenItemState.kt index 706387e9d6..5489b5e602 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/TokenItemState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/state/TokenItemState.kt @@ -2,26 +2,17 @@ package com.tangem.feature.wallet.presentation.common.state import androidx.annotation.DrawableRes import androidx.compose.runtime.Immutable -import com.tangem.feature.wallet.presentation.common.state.TokenItemState.TokenOptionsState.PriceChange.Type /** Token item state */ @Immutable internal sealed interface TokenItemState { - /** Token id */ - val id: String - - /** - * Loading token state - * - * @property id token id - */ - data class Loading(override val id: String) : TokenItemState + /** Loading token state */ + object Loading : TokenItemState /** * Content token state * - * @property id token id * @property tokenIconUrl token icon url * @property tokenIconResId token icon resource id * @property networkIconResId network icon resource id, may be null if it is a coin @@ -31,7 +22,7 @@ internal sealed interface TokenItemState { * @property tokenOptions state for token options */ data class Content( - override val id: String, + val id: String, val tokenIconUrl: String?, @DrawableRes val tokenIconResId: Int, @DrawableRes val networkIconResId: Int?, @@ -44,14 +35,13 @@ internal sealed interface TokenItemState { /** * Draggable token state * - * @property id token id * @property tokenIconUrl token icon url * @property tokenIconResId token icon resource id * @property networkIconResId network icon resource id, may be null if it is a coin * @property name token name */ data class Draggable( - override val id: String, + val id: String, val tokenIconUrl: String?, @DrawableRes val tokenIconResId: Int, @DrawableRes val networkIconResId: Int?, @@ -69,7 +59,7 @@ internal sealed interface TokenItemState { * @property name token name */ data class Unreachable( - override val id: String, + val id: String, val tokenIconUrl: String?, @DrawableRes val tokenIconResId: Int, @DrawableRes val networkIconResId: Int?, @@ -85,27 +75,13 @@ internal sealed interface TokenItemState { * @property fiatAmount fiat amount of token * @property priceChange value of price changing */ - data class Visible(val fiatAmount: String, val priceChange: PriceChange) : TokenOptionsState + data class Visible(val fiatAmount: String, val priceChange: PriceChangeConfig) : TokenOptionsState /** * Hidden token options state * * @property priceChange value of price changing */ - data class Hidden(val priceChange: PriceChange) : TokenOptionsState - - /** - * Price changing option state - * - * @property valuePercent value in percent - * @property type type [Type] - */ - data class PriceChange(val valuePercent: String, val type: Type) { - - /** Price changing type */ - enum class Type { - UP, DOWN - } - } + data class Hidden(val priceChange: PriceChangeConfig) : TokenOptionsState } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt index 0e1c8436b3..12a164c4fa 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt @@ -5,11 +5,15 @@ import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController +import com.tangem.core.navigation.AppScreen +import com.tangem.core.navigation.NavigationAction +import com.tangem.core.navigation.NavigationStateHolder import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.presentation.WalletFragment import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensScreen @@ -19,14 +23,17 @@ import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletViewModel import kotlin.properties.Delegates /** Default implementation of wallet feature router */ -internal class DefaultWalletRouter : InnerWalletRouter { +internal class DefaultWalletRouter(private val navigationStateHolder: NavigationStateHolder) : InnerWalletRouter { private var navController: NavHostController by Delegates.notNull() + private var fragmentManager: FragmentManager by Delegates.notNull() override fun getEntryFragment(): Fragment = WalletFragment.create() @Composable - override fun Initialize() { + override fun Initialize(fragmentManager: FragmentManager) { + this.fragmentManager = fragmentManager + TangemTheme { NavHost( navController = rememberNavController().apply { navController = this }, @@ -53,10 +60,28 @@ internal class DefaultWalletRouter : InnerWalletRouter { } override fun popBackStack() { - navController.popBackStack() + /* + * It's hack that avoid issue with closing the wallet screen. + * We are using NavGraph only inside feature so first backstack's element is entry of NavGraph and + * next element is wallet screen entry. + * If backstack contains only NavGraph entry and wallet screen entry then we close the wallet fragment. + */ + if (navController.backQueue.size == BACKSTACK_ENTRY_COUNT_TO_CLOSE_WALLET_SCREEN) { + fragmentManager.popBackStack() + } else { + navController.popBackStack() + } } override fun openOrganizeTokensScreen() { navController.navigate(WalletScreens.ORGANIZE_TOKENS.name) } + + override fun openDetailsScreen() { + navigationStateHolder.navigate(NavigationAction.NavigateTo(AppScreen.Details)) + } + + private companion object { + const val BACKSTACK_ENTRY_COUNT_TO_CLOSE_WALLET_SCREEN = 2 + } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt index 7558ac61c7..520d008d6d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt @@ -2,6 +2,7 @@ package com.tangem.feature.wallet.presentation.router import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable +import androidx.fragment.app.FragmentManager import com.tangem.features.wallet.navigation.WalletRouter /** @@ -15,14 +16,21 @@ import com.tangem.features.wallet.navigation.WalletRouter @Stable internal interface InnerWalletRouter : WalletRouter { - /** Initialize router */ + /** + * Initialize router + * + * @param fragmentManager fragment manager + */ @Suppress("TopLevelComposableFunctions") @Composable - fun Initialize() + fun Initialize(fragmentManager: FragmentManager) /** Pop back stack */ fun popBackStack() /** Open organize tokens screen */ fun openOrganizeTokensScreen() + + /** Open details screen */ + fun openDetailsScreen() } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletImageResolver.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletImageResolver.kt new file mode 100644 index 0000000000..2dd09d7535 --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletImageResolver.kt @@ -0,0 +1,52 @@ +package com.tangem.feature.wallet.presentation.wallet.domain + +import androidx.annotation.DrawableRes +import com.tangem.blockchain.common.Blockchain +import com.tangem.domain.common.CardTypesResolver +import com.tangem.feature.wallet.impl.R + +/** + * Wallet image resolver + * +[REDACTED_AUTHOR] + */ +internal object WalletImageResolver { + + private const val DOUBLE_WALLET_SET_BACKUP_COUNT = 1 + private const val TRIPLE_WALLET_SET_BACKUP_COUNT = 2 + + /** Get image by [cardTypesResolver] */ + @DrawableRes + fun resolve(cardTypesResolver: CardTypesResolver): Int? { + return when { + cardTypesResolver.isWallet2() -> resolveWallet2(cardTypesResolver) + cardTypesResolver.isTangemWallet() -> R.drawable.ill_wallet_120_106 + cardTypesResolver.isWhiteWallet() -> R.drawable.ill_old_wallet_120_106 + cardTypesResolver.isTangemTwins() -> R.drawable.ill_twin_120_106 + cardTypesResolver.isStart2Coin() -> R.drawable.ill_start2coin_120_106 + cardTypesResolver.isTangemNote() -> resolveNote(cardTypesResolver) + cardTypesResolver.isDev() -> R.drawable.ill_dev_120_106 + else -> null + } + } + + private fun resolveWallet2(cardTypesResolver: CardTypesResolver): Int? { + return when (cardTypesResolver.getBackupCardsCount()) { + DOUBLE_WALLET_SET_BACKUP_COUNT -> R.drawable.ill_wallet2_cards2_120_106 + TRIPLE_WALLET_SET_BACKUP_COUNT -> R.drawable.ill_wallet2_cards3_120_106 + else -> null + } + } + + private fun resolveNote(cardTypesResolver: CardTypesResolver): Int? { + return when (cardTypesResolver.getBlockchain()) { + Blockchain.Bitcoin -> R.drawable.ill_note_btc_120_106 + Blockchain.Ethereum -> R.drawable.ill_note_ethereum_120_106 + Blockchain.Binance -> R.drawable.ill_note_binance_120_106 + Blockchain.Dogecoin -> R.drawable.ill_note_doge_120_106 + Blockchain.Cardano -> R.drawable.ill_note_cardano_120_106 + Blockchain.XRP -> R.drawable.ill_note_xrp_120_106 + else -> null + } + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletCardState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletCardState.kt index 2f000581e2..a04b0e3f45 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletCardState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletCardState.kt @@ -18,7 +18,7 @@ internal sealed interface WalletCardState { /** Wallet image resource id */ @get:DrawableRes - val imageResId: Int + val imageResId: Int? /** Lambda be invoked when card is clicked */ val onClick: (() -> Unit)? @@ -37,7 +37,7 @@ internal sealed interface WalletCardState { override val id: String, override val title: String, override val additionalInfo: String, - override val imageResId: Int, + override val imageResId: Int?, override val onClick: (() -> Unit)? = null, val balance: String, ) : WalletCardState @@ -55,8 +55,8 @@ internal sealed interface WalletCardState { override val id: String, override val title: String, override val additionalInfo: String, - override val imageResId: Int, - override val onClick: (() -> Unit)?, + override val imageResId: Int?, + override val onClick: (() -> Unit)? = null, ) : WalletCardState /** @@ -72,7 +72,7 @@ internal sealed interface WalletCardState { override val id: String, override val title: String, override val additionalInfo: String, - override val imageResId: Int, + override val imageResId: Int?, override val onClick: (() -> Unit)?, ) : WalletCardState @@ -89,7 +89,7 @@ internal sealed interface WalletCardState { override val id: String, override val title: String, override val additionalInfo: String, - override val imageResId: Int, + override val imageResId: Int?, override val onClick: (() -> Unit)?, ) : WalletCardState } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletContentItemState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletContentItemState.kt index f8934f6002..19142be1cd 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletContentItemState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletContentItemState.kt @@ -39,11 +39,11 @@ internal sealed interface WalletContentItemState { data class Title(val onExploreClick: () -> Unit) : SingleCurrencyItem /** - * Transaction group title item + * Group title item * * @property title title */ - data class TransactionGroupTitle(val title: String) : SingleCurrencyItem + data class GroupTitle(val title: String) : SingleCurrencyItem /** * Transaction item @@ -52,4 +52,6 @@ internal sealed interface WalletContentItemState { */ data class Transaction(val state: TransactionState) : SingleCurrencyItem } + + object Loading : WalletContentItemState } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMarketplaceBlockState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMarketplaceBlockState.kt new file mode 100644 index 0000000000..591c548d9e --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMarketplaceBlockState.kt @@ -0,0 +1,33 @@ +package com.tangem.feature.wallet.presentation.wallet.state + +import com.tangem.feature.wallet.presentation.common.state.PriceChangeConfig + +/** + * Wallet marketplace component state + * + * @property currencyName currency name + * +[REDACTED_AUTHOR] + */ +internal sealed class WalletMarketplaceBlockState(open val currencyName: String) { + + /** + * Loading state + * + * @property currencyName currency name + */ + data class Loading(override val currencyName: String) : WalletMarketplaceBlockState(currencyName = currencyName) + + /** + * Content state + * + * @property currencyName currency name + * @property price price + * @property priceChangeConfig price change config + */ + data class Content( + override val currencyName: String, + val price: String, + val priceChangeConfig: PriceChangeConfig, + ) : WalletMarketplaceBlockState(currencyName = currencyName) +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt index 0e9c80a61a..02b9d37a3d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt @@ -43,12 +43,13 @@ internal sealed class WalletStateHolder( /** * Single currency wallet content state * - * @property onBackClick lambda be invoked when back button is clicked - * @property topBarConfig top bar config - * @property walletsListConfig wallets list config - * @property contentItems content items - * @property notifications notifications - * @property buttons manage buttons + * @property onBackClick lambda be invoked when back button is clicked + * @property topBarConfig top bar config + * @property walletsListConfig wallets list config + * @property contentItems content items + * @property notifications notifications + * @property buttons manage buttons + * @property marketplaceBlockState marketplace block state */ data class SingleCurrencyContent( override val onBackClick: () -> Unit, @@ -57,5 +58,6 @@ internal sealed class WalletStateHolder( override val contentItems: ImmutableList, override val notifications: ImmutableList, val buttons: ImmutableList, + val marketplaceBlockState: WalletMarketplaceBlockState, ) : WalletStateHolder(onBackClick, topBarConfig, walletsListConfig, contentItems, notifications) } \ No newline at end of file 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 bf417cd9b1..438aaf5d32 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 @@ -5,15 +5,14 @@ import androidx.compose.animation.* import androidx.compose.foundation.* import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.* 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.res.stringResource -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider @@ -26,13 +25,16 @@ import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.WalletPreviewData import com.tangem.feature.wallet.presentation.common.component.NetworkGroupItem import com.tangem.feature.wallet.presentation.common.component.TokenItem +import com.tangem.feature.wallet.presentation.common.state.TokenItemState import com.tangem.feature.wallet.presentation.wallet.state.WalletContentItemState -import com.tangem.feature.wallet.presentation.wallet.state.WalletManageButtons import com.tangem.feature.wallet.presentation.wallet.state.WalletStateHolder import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletTopBar import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletsList +import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.TransactionsBlockGroupTitle +import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.TransactionsBlockTitle +import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.WalletManageButtons +import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.WalletMarketplaceBlock import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration -import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletNotificationDecoration import com.tangem.feature.wallet.presentation.wallet.ui.utils.changeWalletAnimator /** @@ -66,7 +68,6 @@ internal fun WalletScreen(state: WalletStateHolder) { WalletsList( config = state.walletsListConfig, lazyListState = walletsListState, - modifier = Modifier.padding(bottom = TangemTheme.dimens.spacing14), ) } @@ -74,33 +75,44 @@ internal fun WalletScreen(state: WalletStateHolder) { item { WalletManageButtons( buttons = state.buttons, - modifier = changeableItemModifier.padding(bottom = TangemTheme.dimens.spacing14), + modifier = changeableItemModifier.padding(top = TangemTheme.dimens.spacing14), ) } } - itemsIndexed( + items( items = state.notifications, - itemContent = { index, item -> + itemContent = { item -> Notification( state = item.state, - modifier = changeableItemModifier.walletNotificationDecoration( - currentIndex = index, - lastIndex = state.notifications.lastIndex, - ), + modifier = changeableItemModifier + .padding(top = TangemTheme.dimens.spacing14) + .padding(horizontal = TangemTheme.dimens.spacing16), ) }, ) + if (state is WalletStateHolder.SingleCurrencyContent) { + item { + WalletMarketplaceBlock( + state = state.marketplaceBlockState, + modifier = changeableItemModifier + .padding(top = TangemTheme.dimens.spacing14) + .padding(horizontal = TangemTheme.dimens.spacing16), + ) + } + } + itemsIndexed( items = state.contentItems, key = { index, item -> when (item) { is WalletContentItemState.MultiCurrencyItem.NetworkGroupTitle -> item.networkName - is WalletContentItemState.MultiCurrencyItem.Token -> item.state.id + is WalletContentItemState.MultiCurrencyItem.Token -> index is WalletContentItemState.SingleCurrencyItem.Title -> index - is WalletContentItemState.SingleCurrencyItem.TransactionGroupTitle -> item.title + is WalletContentItemState.SingleCurrencyItem.GroupTitle -> item.title is WalletContentItemState.SingleCurrencyItem.Transaction -> index + is WalletContentItemState.Loading -> index } }, itemContent = { index, item -> @@ -138,75 +150,20 @@ private fun ContentItem(item: WalletContentItemState, modifier: Modifier = Modif TokenItem(state = item.state, modifier = modifier) } is WalletContentItemState.SingleCurrencyItem.Title -> { - SingleCurrencyTitle(config = item, modifier = modifier) + TransactionsBlockTitle(config = item, modifier = modifier) } - is WalletContentItemState.SingleCurrencyItem.TransactionGroupTitle -> { - TransactionGroupTitle(config = item, modifier = modifier) + is WalletContentItemState.SingleCurrencyItem.GroupTitle -> { + TransactionsBlockGroupTitle(config = item, modifier = modifier) } is WalletContentItemState.SingleCurrencyItem.Transaction -> { Transaction(state = item.state, modifier = modifier) } - } -} - -@Composable -private fun SingleCurrencyTitle( - config: WalletContentItemState.SingleCurrencyItem.Title, - modifier: Modifier = Modifier, -) { - Row( - modifier = modifier - .background(TangemTheme.colors.background.primary) - .fillMaxWidth() - .padding(top = TangemTheme.dimens.spacing12) - .padding(horizontal = TangemTheme.dimens.spacing16), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = stringResource(id = R.string.common_transactions), - color = TangemTheme.colors.text.tertiary, - style = TangemTheme.typography.subtitle2, - ) - - Row( - modifier = Modifier.clickable(onClick = config.onExploreClick), - horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4), - ) { - Icon( - painter = painterResource(id = R.drawable.ic_compass_24), - contentDescription = null, - modifier = Modifier.size(size = TangemTheme.dimens.size18), - tint = TangemTheme.colors.icon.informative, - ) - Text( - text = stringResource(id = R.string.common_explorer), - color = TangemTheme.colors.text.tertiary, - style = TangemTheme.typography.subtitle2, - ) + WalletContentItemState.Loading -> { + TokenItem(state = TokenItemState.Loading, modifier = modifier) } } } -@Composable -private fun TransactionGroupTitle( - config: WalletContentItemState.SingleCurrencyItem.TransactionGroupTitle, - modifier: Modifier = Modifier, -) { - Text( - text = config.title, - modifier = modifier - .background(TangemTheme.colors.background.primary) - .fillMaxWidth() - .padding( - horizontal = TangemTheme.dimens.spacing16, - vertical = TangemTheme.dimens.spacing14, - ), - color = TangemTheme.colors.text.tertiary, - textAlign = TextAlign.Start, - style = TangemTheme.typography.body2, - ) -} - @Composable private fun OrganizeTokensButton(onClick: () -> Unit, modifier: Modifier = Modifier) { RoundedActionButton( diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletCard.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletCard.kt index d92651ac6f..afc27705b9 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletCard.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletCard.kt @@ -62,16 +62,18 @@ internal fun WalletCard(state: WalletCardState, modifier: Modifier = Modifier) { } val imageWidth = TangemTheme.dimens.size120 - WalletImage( - id = state.imageResId, - modifier = Modifier.constrainAs(imageItem) { - centerVerticallyTo(parent) - top.linkTo(parent.top) - end.linkTo(parent.end) - height = Dimension.fillToConstraints - width = Dimension.value(imageWidth) - }, - ) + state.imageResId?.let { + WalletImage( + id = it, + modifier = Modifier.constrainAs(imageItem) { + centerVerticallyTo(parent) + top.linkTo(parent.top) + end.linkTo(parent.end) + height = Dimension.fillToConstraints + width = Dimension.value(imageWidth) + }, + ) + } } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockGroupTitle.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockGroupTitle.kt new file mode 100644 index 0000000000..eed98b7ebf --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockGroupTitle.kt @@ -0,0 +1,54 @@ +package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import com.tangem.core.ui.res.TangemTheme +import com.tangem.feature.wallet.presentation.wallet.state.WalletContentItemState + +/** + * Transactions block group title + * + * @param config config + * @param modifier modifier + */ +@Composable +internal fun TransactionsBlockGroupTitle( + config: WalletContentItemState.SingleCurrencyItem.GroupTitle, + modifier: Modifier = Modifier, +) { + Text( + text = config.title, + modifier = modifier + .background(TangemTheme.colors.background.primary) + .fillMaxWidth() + .padding( + horizontal = TangemTheme.dimens.spacing16, + vertical = TangemTheme.dimens.spacing14, + ), + color = TangemTheme.colors.text.tertiary, + textAlign = TextAlign.Start, + style = TangemTheme.typography.body2, + ) +} + +@Preview +@Composable +private fun Preview_TransactionsBlockGroupTitle_Light() { + TangemTheme(isDark = false) { + TransactionsBlockGroupTitle(config = WalletContentItemState.SingleCurrencyItem.GroupTitle(title = "Today")) + } +} + +@Preview +@Composable +private fun Preview_TransactionsBlockGroupTitle_Dark() { + TangemTheme(isDark = true) { + TransactionsBlockGroupTitle(config = WalletContentItemState.SingleCurrencyItem.GroupTitle(title = "Today")) + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockTitle.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockTitle.kt new file mode 100644 index 0000000000..58e675f1fb --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TransactionsBlockTitle.kt @@ -0,0 +1,79 @@ +package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import com.tangem.core.ui.res.TangemTheme +import com.tangem.feature.wallet.impl.R +import com.tangem.feature.wallet.presentation.wallet.state.WalletContentItemState + +/** + * Transactions block title + * + * @param config config + * @param modifier modifier + */ +@Composable +internal fun TransactionsBlockTitle( + config: WalletContentItemState.SingleCurrencyItem.Title, + modifier: Modifier = Modifier, +) { + Row( + modifier = modifier + .background(TangemTheme.colors.background.primary) + .fillMaxWidth() + .padding(top = TangemTheme.dimens.spacing12) + .padding(horizontal = TangemTheme.dimens.spacing16), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = stringResource(id = R.string.common_transactions), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.subtitle2, + ) + + Row( + modifier = Modifier.clickable(onClick = config.onExploreClick), + horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4), + ) { + Icon( + painter = painterResource(id = R.drawable.ic_compass_24), + contentDescription = null, + modifier = Modifier.size(size = TangemTheme.dimens.size18), + tint = TangemTheme.colors.icon.informative, + ) + Text( + text = stringResource(id = R.string.common_explorer), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.subtitle2, + ) + } + } +} + +@Preview +@Composable +private fun Preview_TransactionsBlockTitle_Light() { + TangemTheme(isDark = false) { + TransactionsBlockTitle( + config = WalletContentItemState.SingleCurrencyItem.Title(onExploreClick = {}), + ) + } +} + +@Preview +@Composable +private fun Preview_TransactionsBlockTitle_Dark() { + TangemTheme(isDark = true) { + TransactionsBlockTitle( + config = WalletContentItemState.SingleCurrencyItem.Title(onExploreClick = {}), + ) + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletManageButtons.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt similarity index 93% rename from features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletManageButtons.kt rename to features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt index 7d19a06e5a..19b1a57045 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletManageButtons.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt @@ -1,4 +1,4 @@ -package com.tangem.feature.wallet.presentation.wallet.state +package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -13,6 +13,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import com.tangem.core.ui.components.buttons.actions.ActionButton import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.presentation.common.WalletPreviewData +import com.tangem.feature.wallet.presentation.wallet.state.WalletManageButton import kotlinx.collections.immutable.ImmutableList /** diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletMarketplaceBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletMarketplaceBlock.kt new file mode 100644 index 0000000000..7033b42c61 --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletMarketplaceBlock.kt @@ -0,0 +1,158 @@ +package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter +import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import androidx.compose.ui.unit.Dp +import com.tangem.core.ui.components.RectangleShimmer +import com.tangem.core.ui.res.TangemTheme +import com.tangem.feature.wallet.impl.R +import com.tangem.feature.wallet.presentation.common.WalletPreviewData +import com.tangem.feature.wallet.presentation.common.state.PriceChangeConfig +import com.tangem.feature.wallet.presentation.wallet.state.WalletMarketplaceBlockState + +/** + * Wallet marketplace block + * + * @param state state + * +[REDACTED_AUTHOR] + */ +@Composable +internal fun WalletMarketplaceBlock(state: WalletMarketplaceBlockState, modifier: Modifier = Modifier) { + var rootWidth by remember { mutableStateOf(value = 0) } + Column( + modifier = modifier + .background( + color = TangemTheme.colors.background.primary, + shape = RoundedCornerShape(TangemTheme.dimens.radius14), + ) + .heightIn(min = TangemTheme.dimens.size70) + .fillMaxWidth() + .padding(all = TangemTheme.dimens.spacing14) + .onSizeChanged { rootWidth = it.width }, + verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing6), + horizontalAlignment = Alignment.Start, + ) { + Text( + text = stringResource(id = R.string.wallet_marketplace_block_title, state.currencyName), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.subtitle2, + ) + + when (state) { + is WalletMarketplaceBlockState.Loading -> { + RectangleShimmer( + modifier = Modifier.size(width = TangemTheme.dimens.size158, height = TangemTheme.dimens.size20), + ) + } + is WalletMarketplaceBlockState.Content -> { + Price( + config = state, + priceWidthDp = with(LocalDensity.current) { rootWidth.div(other = 2).toDp() }, + ) + } + } + } +} + +@Composable +private fun Price(config: WalletMarketplaceBlockState.Content, priceWidthDp: Dp) { + Row( + modifier = Modifier, + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing8), + ) { + Text( + text = config.price, + modifier = Modifier.widthIn(max = priceWidthDp), + color = TangemTheme.colors.text.primary1, + overflow = TextOverflow.Ellipsis, + maxLines = 1, + style = TangemTheme.typography.body2, + ) + + PriceChangeInPercent(config.priceChangeConfig) + + Text( + text = stringResource(id = R.string.wallet_marketprice_block_update_time), + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.body2, + ) + } +} + +@Composable +private fun PriceChangeInPercent(config: PriceChangeConfig) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4), + ) { + Image( + painter = painterResource( + id = when (config.type) { + PriceChangeConfig.Type.UP -> R.drawable.img_arrow_up_8 + PriceChangeConfig.Type.DOWN -> R.drawable.img_arrow_down_8 + }, + ), + contentDescription = null, + ) + + Text( + text = config.valueInPercent, + color = when (config.type) { + PriceChangeConfig.Type.UP -> TangemTheme.colors.text.accent + PriceChangeConfig.Type.DOWN -> TangemTheme.colors.text.warning + }, + style = TangemTheme.typography.body2, + ) + } +} + +@Preview +@Composable +private fun Preview_MarketplaceBlock_Light( + @PreviewParameter(WalletMarketplaceStateProvider::class) + state: WalletMarketplaceBlockState, +) { + TangemTheme(isDark = false) { + WalletMarketplaceBlock(state = state) + } +} + +@Preview +@Composable +private fun Preview_MarketplaceBlock_Dark( + @PreviewParameter(WalletMarketplaceStateProvider::class) + state: WalletMarketplaceBlockState, +) { + TangemTheme(isDark = true) { + WalletMarketplaceBlock(state = state) + } +} + +private class WalletMarketplaceStateProvider : CollectionPreviewParameterProvider( + collection = listOf( + WalletPreviewData.marketplaceBlockContent, + WalletPreviewData.marketplaceBlockContent.copy( + priceChangeConfig = PriceChangeConfig( + valueInPercent = "5.16%", + type = PriceChangeConfig.Type.DOWN, + ), + ), + WalletMarketplaceBlockState.Loading(currencyName = "BTC"), + ), +) \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/decorations/WalletNotificationDecoration.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/decorations/WalletNotificationDecoration.kt deleted file mode 100644 index cd2cc0a5f1..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/decorations/WalletNotificationDecoration.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.decorations - -import androidx.compose.foundation.layout.padding -import androidx.compose.ui.Modifier -import androidx.compose.ui.composed -import com.tangem.core.ui.res.TangemTheme - -/** - * Wallet notification decoration - * - * @param currentIndex current index - * @param lastIndex last index - * -[REDACTED_AUTHOR] - */ -internal fun Modifier.walletNotificationDecoration(currentIndex: Int, lastIndex: Int): Modifier = composed { - val modifierWithHorizontalPadding = this.padding(horizontal = TangemTheme.dimens.spacing16) - - if (currentIndex != lastIndex) { - modifierWithHorizontalPadding.padding(bottom = TangemTheme.dimens.spacing14) - } else { - modifierWithHorizontalPadding - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/ScrollOffsetCollector.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/ScrollOffsetCollector.kt index b0b2072867..41cbf50ec1 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/ScrollOffsetCollector.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/ScrollOffsetCollector.kt @@ -20,13 +20,8 @@ internal class ScrollOffsetCollector( private val LazyListItemInfo.halfItemSize get() = size.div(other = 2) override suspend fun emit(value: List) { - val firstItem = requireNotNull(value.firstOrNull()) { - "At least 1 item should be visible in list" - } - - val lastItem = requireNotNull(value.lastOrNull()) { - "At least 1 item should be visible in list" - } + val firstItem = value.firstOrNull() ?: return + val lastItem = value.lastOrNull() ?: return if (abs(firstItem.offset) > firstItem.halfItemSize) { callback(firstItem.index + 1) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/WalletContentItemAnimator.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/WalletContentItemAnimator.kt index 61564d220c..61a190a01f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/WalletContentItemAnimator.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/utils/WalletContentItemAnimator.kt @@ -12,7 +12,7 @@ import androidx.compose.ui.composed import androidx.compose.ui.draw.alpha import androidx.compose.ui.unit.dp -private const val ANIMATION_MAX_OFFSET = 80 +private const val ANIMATION_MAX_OFFSET_IN_DP = 80 private const val ANIMATION_MAX_ALPHA = 1f /** @@ -46,7 +46,7 @@ internal fun Modifier.changeWalletAnimator(lazyListState: LazyListState) = compo walletItemSize - walletItemOffset } - ANIMATION_MAX_OFFSET.dp / walletItemSize * position + ANIMATION_MAX_OFFSET_IN_DP.dp / walletItemSize * position } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index e13dad1715..4cdda4fe30 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -8,6 +8,7 @@ import androidx.lifecycle.ViewModel import com.tangem.feature.wallet.presentation.common.WalletPreviewData import com.tangem.feature.wallet.presentation.router.InnerWalletRouter import com.tangem.feature.wallet.presentation.wallet.state.WalletStateHolder +import com.tangem.feature.wallet.presentation.wallet.state.WalletTopBarConfig import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject import kotlin.properties.Delegates @@ -30,8 +31,9 @@ internal class WalletViewModel @Inject constructor() : ViewModel() { // TODO: [REDACTED_TASK_KEY] Use production data instead of WalletPreviewData private fun getInitialState(): WalletStateHolder = WalletPreviewData.multicurrencyWalletScreenState.copy( onBackClick = { router.popBackStack() }, - topBarConfig = WalletPreviewData.multicurrencyWalletScreenState.topBarConfig.copy( + topBarConfig = WalletTopBarConfig( onScanCardClick = { router.openOrganizeTokensScreen() }, + onMoreClick = { router.openDetailsScreen() }, ), walletsListConfig = WalletPreviewData.multicurrencyWalletScreenState.walletsListConfig.copy( onWalletChange = ::selectWallet, diff --git a/features/wallet/impl/src/main/res/drawable/ill_dev_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_dev_120_106.webp new file mode 100644 index 0000000000..5f5810854c Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_dev_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_binance_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_binance_120_106.webp new file mode 100644 index 0000000000..6033022c35 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_binance_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_btc_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_btc_120_106.webp new file mode 100644 index 0000000000..a076339b55 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_btc_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_cardano_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_cardano_120_106.webp new file mode 100644 index 0000000000..9c948edb3d Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_cardano_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_doge_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_doge_120_106.webp new file mode 100644 index 0000000000..4dced68bb1 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_doge_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_ethereum_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_ethereum_120_106.webp new file mode 100644 index 0000000000..68ca577add Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_ethereum_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_note_xrp_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_note_xrp_120_106.webp new file mode 100644 index 0000000000..0fafd6fbe1 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_note_xrp_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_old_wallet_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_old_wallet_120_106.webp new file mode 100644 index 0000000000..baad83220c Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_old_wallet_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_start2coin_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_start2coin_120_106.webp new file mode 100644 index 0000000000..bdfa44d919 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_start2coin_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_twin_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_twin_120_106.webp new file mode 100644 index 0000000000..c70a8526de Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_twin_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards2_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards2_120_106.webp new file mode 100644 index 0000000000..6488b36718 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards2_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards3_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards3_120_106.webp new file mode 100644 index 0000000000..469d3e2dc5 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_wallet2_cards3_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_wallet_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_wallet_120_106.webp new file mode 100644 index 0000000000..890ad12eae Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_wallet_120_106.webp differ diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 8b3d5af5bd..ec573f8c66 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -73,8 +73,8 @@ mviCore = "1.3.1" kotlinSerialization = "1.4.1" arrow = "1.2.0-RC" reactiveNetwork = "3.0.8" -walletConnectCore = "1.15.0" -walletConnectWeb3 = "1.8.0" +walletConnectCore = "1.17.0" +walletConnectWeb3 = "1.10.0" # endregion Other libraries # region Tangem diff --git a/settings.gradle.kts b/settings.gradle.kts index 15b3f6a078..523476db95 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,6 +28,8 @@ dependencyResolutionManagement { } } +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + include(":app") include(":common") @@ -35,9 +37,10 @@ include(":common") include(":core:analytics") include(":core:datasource") include(":core:featuretoggles") +include(":core:navigation") include(":core:res") -include(":core:utils") include(":core:ui") +include(":core:utils") // endregion Core modules // region Libs modules @@ -61,6 +64,9 @@ include(":features:tester:impl") include(":features:wallet:api") include(":features:wallet:impl") +include(":features:tokendetails:api") +include(":features:tokendetails:impl") + include(":features:learn2earn:api") include(":features:learn2earn:impl") // endregion Feature modules @@ -72,6 +78,8 @@ include(":domain:legacy") include(":domain:core") include(":domain:card") +include(":domain:wallets") +include(":domain:wallets:models") // endregion Domain modules // region Data modules