Updated on 2026-08-14
This commit is contained in:
parent
45ab6836ad
commit
5c56f04c38
52 changed files with 228 additions and 72 deletions
|
|
@ -10,6 +10,7 @@ import com.tangem.domain.transaction.usecase.ValidateWalletMemoUseCase
|
|||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.delegate.DefaultUserWalletsSyncDelegate
|
||||
import com.tangem.domain.wallets.delegate.UserWalletsSyncDelegate
|
||||
import com.tangem.domain.wallets.derivations.DerivationsRepository
|
||||
import com.tangem.domain.wallets.hot.HotWalletAccessor
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.domain.wallets.repository.WalletNamesMigrationRepository
|
||||
|
|
@ -435,4 +436,16 @@ internal object WalletsDomainModule {
|
|||
hotWalletAccessor = hotWalletAccessor,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesColdWalletInteractionNeededUseCase(
|
||||
derivationsRepository: DerivationsRepository,
|
||||
getUserWalletUseCase: GetUserWalletUseCase,
|
||||
): ColdWalletAndHasMissedDerivationsUseCase {
|
||||
return ColdWalletAndHasMissedDerivationsUseCase(
|
||||
derivationsRepository = derivationsRepository,
|
||||
userWalletUseCase = getUserWalletUseCase,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ private fun GiveTxPermissionBottomSheetContent(content: GiveTxPermissionBottomSh
|
|||
|
||||
PrimaryButtonIconEnd(
|
||||
text = stringResourceSafe(id = R.string.common_approve),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = content.walletInteractionIcon,
|
||||
showProgress = data.approveButton.loading,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
@ -319,5 +319,6 @@ private val previewData = GiveTxPermissionBottomSheetConfig(
|
|||
dialogText = resourceReference(R.string.give_permission_staking_footer),
|
||||
footerText = resourceReference(R.string.swap_give_permission_fee_footer),
|
||||
),
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24,
|
||||
onCancel = {},
|
||||
)
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.tangem.common.ui.bottomsheet.permission.state
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
|
||||
data class GiveTxPermissionBottomSheetConfig(
|
||||
val data: GiveTxPermissionState.ReadyForRequest,
|
||||
@DrawableRes val walletInteractionIcon: Int?,
|
||||
val onCancel: () -> Unit,
|
||||
) : TangemBottomSheetConfigContent
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.common.ui.userwallet.ext
|
||||
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
|
||||
fun walletInterationIcon(userWallet: UserWallet): Int? {
|
||||
return when (userWallet) {
|
||||
is UserWallet.Cold -> R.drawable.ic_tangem_24
|
||||
is UserWallet.Hot -> null
|
||||
}
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ fun PrimaryButton(
|
|||
@Composable
|
||||
fun PrimaryButtonIconEnd(
|
||||
text: String,
|
||||
@DrawableRes iconResId: Int,
|
||||
@DrawableRes iconResId: Int?,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
size: TangemButtonSize = TangemButtonSize.Default,
|
||||
|
|
@ -122,7 +122,7 @@ fun PrimaryButtonIconEnd(
|
|||
TangemButton(
|
||||
modifier = modifier,
|
||||
text = text,
|
||||
icon = TangemButtonIconPosition.End(iconResId),
|
||||
icon = if (iconResId != null) TangemButtonIconPosition.End(iconResId) else TangemButtonIconPosition.None,
|
||||
onClick = onClick,
|
||||
colors = TangemButtonsDefaults.primaryButtonColors,
|
||||
enabled = enabled,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.derivations.DerivationsRepository
|
||||
|
||||
/**
|
||||
* Helps to determine whether the tangem icon should be displayed on the buttons for interacting with the wallet.
|
||||
*/
|
||||
class ColdWalletAndHasMissedDerivationsUseCase(
|
||||
private val derivationsRepository: DerivationsRepository,
|
||||
private val userWalletUseCase: GetUserWalletUseCase,
|
||||
) {
|
||||
suspend operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
networksWithDerivationPath: Map<BackendId, String?>,
|
||||
): Boolean {
|
||||
val userWallet = userWalletUseCase.invoke(userWalletId).getOrNull() ?: return false
|
||||
return userWallet is UserWallet.Cold &&
|
||||
derivationsRepository.hasMissedDerivations(userWalletId, networksWithDerivationPath)
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ internal class PreviewManageTokensComponent(
|
|||
loadMore = { false },
|
||||
saveChanges = {},
|
||||
isSavingInProgress = false,
|
||||
needToAddDerivations = showTangemIcon,
|
||||
needToInteractWithColdWallet = showTangemIcon,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.managetokens.entity.customtoken
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -15,7 +16,7 @@ internal data class CustomTokenFormUM(
|
|||
val notifications: PersistentList<NotificationUM> = persistentListOf(),
|
||||
val canAddToken: Boolean = false,
|
||||
val isValidating: Boolean = false,
|
||||
val needToAddDerivation: Boolean = false,
|
||||
@DrawableRes val walletInteractionIcon: Int? = null,
|
||||
val saveToken: () -> Unit,
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ internal sealed class ManageTokensUM {
|
|||
val saveChanges: () -> Unit,
|
||||
val hasChanges: Boolean,
|
||||
val isSavingInProgress: Boolean,
|
||||
val needToAddDerivations: Boolean,
|
||||
val needToInteractWithColdWallet: Boolean,
|
||||
) : ManageTokensUM()
|
||||
|
||||
fun copySealed(
|
||||
|
|
@ -53,7 +53,7 @@ internal sealed class ManageTokensUM {
|
|||
isNextBatchLoading: Boolean = this.isNextBatchLoading,
|
||||
isSavingInProgress: Boolean = this is ManageContent && this.isSavingInProgress,
|
||||
scrollToTop: StateEvent<Unit> = this.scrollToTop,
|
||||
needToAddDerivations: Boolean = this is ManageContent && this.needToAddDerivations,
|
||||
needToInteractWithColdWallet: Boolean = this is ManageContent && this.needToInteractWithColdWallet,
|
||||
): ManageTokensUM {
|
||||
return when (this) {
|
||||
is ManageContent -> copy(
|
||||
|
|
@ -64,7 +64,7 @@ internal sealed class ManageTokensUM {
|
|||
isNextBatchLoading = isNextBatchLoading,
|
||||
isSavingInProgress = isSavingInProgress,
|
||||
scrollToTop = scrollToTop,
|
||||
needToAddDerivations = needToAddDerivations,
|
||||
needToInteractWithColdWallet = needToInteractWithColdWallet,
|
||||
)
|
||||
is ReadContent -> copy(
|
||||
search = search,
|
||||
|
|
|
|||
|
|
@ -164,8 +164,8 @@ internal class CustomTokenFormModel @Inject constructor(
|
|||
isAlreadyAdded: Boolean,
|
||||
isCustom: Boolean,
|
||||
) = modelScope.launch {
|
||||
val needToAddDerivation = useCasesFacade.hasMissedDerivationsUseCase(
|
||||
networksWithDerivationPath = mapOf(currency.network.backendId to getDerivationPath().value),
|
||||
val needColdWalletInteraction = useCasesFacade.needColdWalletInteraction(
|
||||
network = mapOf(currency.network.backendId to getDerivationPath().value),
|
||||
)
|
||||
|
||||
state.update { state ->
|
||||
|
|
@ -177,7 +177,7 @@ internal class CustomTokenFormModel @Inject constructor(
|
|||
clearNotifications = true,
|
||||
clearFieldErrors = true,
|
||||
disableSecondaryFields = !isCustom,
|
||||
needToAddDerivation = needToAddDerivation,
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24.takeIf { needColdWalletInteraction },
|
||||
)
|
||||
|
||||
if (fillForm) {
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ internal class ManageTokensModel @Inject constructor(
|
|||
hasChanges = false,
|
||||
saveChanges = ::saveChanges,
|
||||
loadMore = ::loadMoreItems,
|
||||
needToAddDerivations = false,
|
||||
needToInteractWithColdWallet = false,
|
||||
isSavingInProgress = false,
|
||||
)
|
||||
}
|
||||
|
|
@ -271,12 +271,12 @@ internal class ManageTokensModel @Inject constructor(
|
|||
.flatten()
|
||||
.toSet()
|
||||
.associate { it.backendId to null }
|
||||
val hasMissedDerivations = useCasesFacade.hasMissedDerivationsUseCase(networks)
|
||||
val needToInteractWithColdWallet = useCasesFacade.needColdWalletInteraction(networks)
|
||||
|
||||
state.update { state ->
|
||||
state.copySealed(
|
||||
hasChanges = currenciesToAdd.isNotEmpty() || currenciesToRemove.isNotEmpty(),
|
||||
needToAddDerivations = hasMissedDerivations,
|
||||
needToInteractWithColdWallet = needToInteractWithColdWallet,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,12 +216,12 @@ internal class OnboardingManageTokensModel @Inject constructor(
|
|||
.flatten()
|
||||
.toSet()
|
||||
.associate { it.backendId to null }
|
||||
val hasMissedDerivations = useCasesFacade.hasMissedDerivationsUseCase(network = network)
|
||||
val showTangemIcon = useCasesFacade.needColdWalletInteraction(network = network)
|
||||
state.update { state ->
|
||||
state.copy(
|
||||
actionButtonConfig = OnboardingManageTokensUM.ActionButtonConfig.Continue(
|
||||
onClick = ::saveChanges,
|
||||
showTangemIcon = hasMissedDerivations,
|
||||
showTangemIcon = showTangemIcon,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ internal fun CustomTokenFormContent(model: CustomTokenFormUM, modifier: Modifier
|
|||
enabled = model.canAddToken,
|
||||
showProgress = model.isValidating,
|
||||
animateContentChange = true,
|
||||
icon = if (model.needToAddDerivation) {
|
||||
TangemButtonIconPosition.End(R.drawable.ic_tangem_24)
|
||||
icon = if (model.walletInteractionIcon != null) {
|
||||
TangemButtonIconPosition.End(model.walletInteractionIcon)
|
||||
} else {
|
||||
TangemButtonIconPosition.None
|
||||
},
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ internal fun ManageTokensScreen(state: ManageTokensUM, modifier: Modifier = Modi
|
|||
.fillMaxWidth(),
|
||||
isVisible = state.hasChanges,
|
||||
showProgress = state.isSavingInProgress,
|
||||
showIcon = state.needToAddDerivations,
|
||||
showIcon = state.needToInteractWithColdWallet,
|
||||
onClick = state.saveChanges,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ import com.tangem.domain.managetokens.model.exceptoin.FindTokenException
|
|||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.tokens.AddCryptoCurrenciesUseCase
|
||||
import com.tangem.domain.wallets.usecase.BackendId
|
||||
import com.tangem.domain.wallets.usecase.ColdWalletAndHasMissedDerivationsUseCase
|
||||
import com.tangem.domain.wallets.usecase.DerivePublicKeysUseCase
|
||||
import com.tangem.domain.wallets.usecase.HasMissedDerivationsUseCase
|
||||
import com.tangem.features.managetokens.component.AddCustomTokenMode
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
|
|
@ -22,24 +21,23 @@ import dagger.assisted.AssistedInject
|
|||
|
||||
@Suppress("LongParameterList")
|
||||
internal class CustomTokenFormUseCasesFacade @AssistedInject constructor(
|
||||
private val hasMissedDerivationsUseCase: HasMissedDerivationsUseCase,
|
||||
private val addCryptoCurrenciesUseCase: AddCryptoCurrenciesUseCase,
|
||||
private val derivePublicKeysUseCase: DerivePublicKeysUseCase,
|
||||
private val validateTokenFormUseCase: ValidateTokenFormUseCase,
|
||||
private val createCryptoCurrencyUseCase: CreateCryptoCurrencyUseCase,
|
||||
private val findTokenUseCase: FindTokenUseCase,
|
||||
private val checkIsCurrencyNotAddedUseCase: CheckIsCurrencyNotAddedUseCase,
|
||||
private val coldWalletAndHasMissedDerivationsUseCase: ColdWalletAndHasMissedDerivationsUseCase,
|
||||
@Assisted private val mode: AddCustomTokenMode,
|
||||
) {
|
||||
|
||||
suspend fun hasMissedDerivationsUseCase(networksWithDerivationPath: Map<BackendId, String?>): Boolean =
|
||||
when (mode) {
|
||||
is AddCustomTokenMode.Account -> TODO("Account")
|
||||
is AddCustomTokenMode.Wallet -> hasMissedDerivationsUseCase.invoke(
|
||||
userWalletId = mode.userWalletId,
|
||||
networksWithDerivationPath = networksWithDerivationPath,
|
||||
)
|
||||
}
|
||||
suspend fun needColdWalletInteraction(network: Map<String, String?>): Boolean = when (mode) {
|
||||
is AddCustomTokenMode.Account -> TODO("Account")
|
||||
is AddCustomTokenMode.Wallet -> coldWalletAndHasMissedDerivationsUseCase.invoke(
|
||||
userWalletId = mode.userWalletId,
|
||||
networksWithDerivationPath = network,
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun addCryptoCurrenciesUseCase(currency: CryptoCurrency): Either<Throwable, Unit> = when (mode) {
|
||||
is AddCustomTokenMode.Account -> TODO("Account")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.tangem.domain.managetokens.model.ManageTokensListConfig
|
|||
import com.tangem.domain.managetokens.model.ManagedCryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.HasMissedDerivationsUseCase
|
||||
import com.tangem.domain.wallets.usecase.ColdWalletAndHasMissedDerivationsUseCase
|
||||
import com.tangem.features.managetokens.component.ManageTokensMode
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
|
|
@ -21,7 +21,7 @@ internal class ManageTokensUseCasesFacade @AssistedInject constructor(
|
|||
private val checkHasLinkedTokensUseCase: CheckHasLinkedTokensUseCase,
|
||||
private val removeCustomCurrencyUseCase: RemoveCustomManagedCryptoCurrencyUseCase,
|
||||
private val checkCurrencyUnsupportedUseCase: CheckCurrencyUnsupportedUseCase,
|
||||
private val hasMissedDerivationsUseCase: HasMissedDerivationsUseCase,
|
||||
private val coldWalletAndHasMissedDerivationsUseCase: ColdWalletAndHasMissedDerivationsUseCase,
|
||||
private val saveManagedTokensUseCase: SaveManagedTokensUseCase,
|
||||
@Assisted private val mode: ManageTokensMode,
|
||||
) {
|
||||
|
|
@ -79,9 +79,9 @@ internal class ManageTokensUseCasesFacade @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun hasMissedDerivationsUseCase(network: Map<String, Nothing?>): Boolean = when (mode) {
|
||||
suspend fun needColdWalletInteraction(network: Map<String, Nothing?>): Boolean = when (mode) {
|
||||
is ManageTokensMode.Account -> TODO("Account")
|
||||
is ManageTokensMode.Wallet -> hasMissedDerivationsUseCase.invoke(
|
||||
is ManageTokensMode.Wallet -> coldWalletAndHasMissedDerivationsUseCase.invoke(
|
||||
userWalletId = mode.userWalletId,
|
||||
networksWithDerivationPath = network,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ internal fun CustomTokenFormUM.updateWithProgress(
|
|||
showProgress: Boolean,
|
||||
isWasFilled: Boolean = this.tokenForm?.wasFilled ?: false,
|
||||
canAddToken: Boolean = this.canAddToken,
|
||||
needToAddDerivation: Boolean = false,
|
||||
walletInteractionIcon: Int? = this.walletInteractionIcon,
|
||||
clearNotifications: Boolean = false,
|
||||
clearFieldErrors: Boolean = false,
|
||||
disableSecondaryFields: Boolean = false,
|
||||
|
|
@ -35,7 +35,7 @@ internal fun CustomTokenFormUM.updateWithProgress(
|
|||
return copy(
|
||||
isValidating = showProgress,
|
||||
canAddToken = canAddToken,
|
||||
needToAddDerivation = needToAddDerivation,
|
||||
walletInteractionIcon = walletInteractionIcon,
|
||||
notifications = if (clearNotifications) persistentListOf() else notifications,
|
||||
).updateTokenForm {
|
||||
val updatedFields = fields.mapValues { (key, field) ->
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ internal class AddToPortfolioBSContentUMFactory(
|
|||
alreadyAddedNetworks = alreadyAddedNetworks,
|
||||
onNetworkSwitchClick = onNetworkSwitchClick,
|
||||
).convert(value = token),
|
||||
isScanCardNotificationVisible = portfolioUIData.hasMissedDerivations,
|
||||
isScanCardNotificationVisible = portfolioUIData.needColdWalletInteraction,
|
||||
continueButtonEnabled = portfolioUIData.addToPortfolioData.isUserAddedNetworks(
|
||||
userWalletId = selectedWallet.walletId,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ import com.tangem.domain.models.wallet.UserWalletId
|
|||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
import com.tangem.domain.tokens.GetViewedTokenReceiveWarningUseCase
|
||||
import com.tangem.domain.transaction.usecase.GetEnsNameUseCase
|
||||
import com.tangem.domain.wallets.usecase.ColdWalletAndHasMissedDerivationsUseCase
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase
|
||||
import com.tangem.domain.wallets.usecase.HasMissedDerivationsUseCase
|
||||
import com.tangem.features.markets.impl.R
|
||||
import com.tangem.features.markets.portfolio.api.MarketsPortfolioComponent
|
||||
import com.tangem.features.markets.portfolio.impl.analytics.PortfolioAnalyticsEvent
|
||||
|
|
@ -65,7 +65,7 @@ internal class MarketsPortfolioModel @Inject constructor(
|
|||
private val checkCurrencyUnsupportedUseCase: CheckCurrencyUnsupportedUseCase,
|
||||
private val getSelectedWalletUseCase: GetSelectedWalletUseCase,
|
||||
private val portfolioDataLoader: PortfolioDataLoader,
|
||||
private val hasMissedDerivationsUseCase: HasMissedDerivationsUseCase,
|
||||
private val coldWalletAndHasMissedDerivationsUseCase: ColdWalletAndHasMissedDerivationsUseCase,
|
||||
private val saveMarketTokensUseCase: SaveMarketTokensUseCase,
|
||||
private val addToPortfolioManager: AddToPortfolioManager,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
|
|
@ -232,18 +232,18 @@ internal class MarketsPortfolioModel @Inject constructor(
|
|||
portfolioBSVisibilityModel = portfolioBSVisibilityModel,
|
||||
selectedWalletId = selectedWalletId,
|
||||
addToPortfolioData = addToPortfolioData,
|
||||
hasMissedDerivations = hasMissedDerivations(selectedWalletId, addToPortfolioData),
|
||||
needColdWalletInteraction = needColdWalletInteraction(selectedWalletId, addToPortfolioData),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun hasMissedDerivations(
|
||||
private suspend fun needColdWalletInteraction(
|
||||
selectedWalletId: UserWalletId?,
|
||||
addToPortfolioData: AddToPortfolioManager.AddToPortfolioData,
|
||||
): Boolean {
|
||||
return if (selectedWalletId != null) {
|
||||
hasMissedDerivationsUseCase.invoke(
|
||||
coldWalletAndHasMissedDerivationsUseCase.invoke(
|
||||
userWalletId = selectedWalletId,
|
||||
networksWithDerivationPath = addToPortfolioData.addedNetworks[selectedWalletId].orEmpty()
|
||||
.associate { it.networkId to null },
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.tangem.domain.models.wallet.UserWalletId
|
|||
* @property portfolioBSVisibilityModel portfolio bottom sheet visibility model
|
||||
* @property selectedWalletId selected wallet id
|
||||
* @property addToPortfolioData add to portfolio data
|
||||
* @property hasMissedDerivations flag that indicates if user has missed derivations
|
||||
* @property needColdWalletInteraction flag that indicates if user has missed derivations and has a cold wallet
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
|
|
@ -16,5 +16,5 @@ internal data class PortfolioUIData(
|
|||
val portfolioBSVisibilityModel: PortfolioBSVisibilityModel,
|
||||
val selectedWalletId: UserWalletId?,
|
||||
val addToPortfolioData: AddToPortfolioManager.AddToPortfolioData,
|
||||
val hasMissedDerivations: Boolean,
|
||||
val needColdWalletInteraction: Boolean,
|
||||
)
|
||||
|
|
@ -37,7 +37,11 @@ data class OnrampAddToPortfolioUM(
|
|||
formatArgs = wrappedList(networkName),
|
||||
)
|
||||
|
||||
data class AddButtonUM(val isProgress: Boolean, val onClick: () -> Unit) {
|
||||
data class AddButtonUM(
|
||||
val isProgress: Boolean,
|
||||
val isTangemIconVisible: Boolean,
|
||||
val onClick: () -> Unit,
|
||||
) {
|
||||
|
||||
val text: TextReference = resourceReference(R.string.common_add_to_portfolio)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,20 @@ internal class OnrampAddToPortfolioModel @Inject constructor(
|
|||
currencyName = params.cryptoCurrency.name,
|
||||
networkName = params.cryptoCurrency.network.name,
|
||||
currencyIconState = params.currencyIconState,
|
||||
addButtonUM = OnrampAddToPortfolioUM.AddButtonUM(isProgress = false, onClick = ::onAddClick),
|
||||
addButtonUM = OnrampAddToPortfolioUM.AddButtonUM(
|
||||
isProgress = false,
|
||||
isTangemIconVisible = isTangemIconVisible(),
|
||||
onClick = ::onAddClick,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun isTangemIconVisible(): Boolean {
|
||||
return getUserWalletUseCase(params.userWalletId)
|
||||
.onLeft { Timber.e("Unable to get wallet by id [${params.userWalletId}]: $it") }
|
||||
.fold(ifLeft = { false }, ifRight = { it is UserWallet.Cold })
|
||||
}
|
||||
|
||||
private fun getUserWalletName(): String {
|
||||
return getUserWalletUseCase(params.userWalletId)
|
||||
.onLeft { Timber.e("Unable to get wallet name by id [${params.userWalletId}]: $it") }
|
||||
|
|
|
|||
|
|
@ -149,7 +149,11 @@ private fun PreviewOnrampAddToPortfolioContent() {
|
|||
isGrayscale = false,
|
||||
showCustomBadge = false,
|
||||
),
|
||||
addButtonUM = OnrampAddToPortfolioUM.AddButtonUM(isProgress = false, onClick = {}),
|
||||
addButtonUM = OnrampAddToPortfolioUM.AddButtonUM(
|
||||
isProgress = false,
|
||||
onClick = {},
|
||||
isTangemIconVisible = true,
|
||||
),
|
||||
),
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ dependencies {
|
|||
implementation(projects.core.decompose)
|
||||
implementation(projects.libs.crypto)
|
||||
implementation(projects.common.routing)
|
||||
implementation(projects.common.ui)
|
||||
|
||||
/** AndroidX */
|
||||
implementation(deps.androidx.appCompat)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -147,13 +148,18 @@ internal class ReferralModel @Inject constructor(
|
|||
url = tosLink,
|
||||
expectedAwards = expectedAwards,
|
||||
)
|
||||
is ReferralData.NonParticipantData -> ReferralInfoState.NonParticipantContent(
|
||||
award = getAwardValue(),
|
||||
networkName = getNetworkName(),
|
||||
discount = getDiscountValue(),
|
||||
url = tosLink,
|
||||
onParticipateClicked = ::participate,
|
||||
)
|
||||
is ReferralData.NonParticipantData -> {
|
||||
val userWallet = getUserWalletUseCase(params.userWalletId).getOrNull() ?: error("User wallet not found")
|
||||
|
||||
ReferralInfoState.NonParticipantContent(
|
||||
award = getAwardValue(),
|
||||
networkName = getNetworkName(),
|
||||
discount = getDiscountValue(),
|
||||
url = tosLink,
|
||||
onParticipateClicked = ::participate,
|
||||
participateButtonIcon = walletInterationIcon(userWallet),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ReferralData.getAwardValue(): String = "$award ${getToken().symbol}"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.referral.models
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.feature.referral.domain.models.ExpectedAwards
|
||||
|
||||
internal data class ReferralStateHolder(
|
||||
|
|
@ -36,6 +37,7 @@ internal data class ReferralStateHolder(
|
|||
override val networkName: String,
|
||||
override val discount: String,
|
||||
override val url: String,
|
||||
@DrawableRes val participateButtonIcon: Int?,
|
||||
val onParticipateClicked: () -> Unit,
|
||||
) : ReferralInfoState, ReferralInfoContentState
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.referral.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -15,7 +16,11 @@ import com.tangem.core.ui.res.TangemThemePreview
|
|||
import com.tangem.feature.referral.presentation.R
|
||||
|
||||
@Composable
|
||||
internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipateClick: () -> Unit) {
|
||||
internal fun NonParticipateBottomBlock(
|
||||
@DrawableRes buttonIconRes: Int?,
|
||||
onAgreementClick: () -> Unit,
|
||||
onParticipateClick: () -> Unit,
|
||||
) {
|
||||
Column {
|
||||
AgreementText(
|
||||
firstPartResId = R.string.referral_tos_not_enroled_prefix,
|
||||
|
|
@ -24,7 +29,7 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa
|
|||
|
||||
PrimaryButtonIconEnd(
|
||||
text = stringResourceSafe(id = R.string.referral_button_participate),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = buttonIconRes,
|
||||
onClick = onParticipateClick,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
@ -39,7 +44,7 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa
|
|||
private fun Preview_NonParticipateBottomBlock() {
|
||||
TangemThemePreview {
|
||||
Column(Modifier.background(TangemTheme.colors.background.primary)) {
|
||||
NonParticipateBottomBlock(onAgreementClick = {}, onParticipateClick = {})
|
||||
NonParticipateBottomBlock(buttonIconRes = null, onAgreementClick = {}, onParticipateClick = {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -183,6 +183,7 @@ private fun ReferralInfo(
|
|||
NonParticipateBottomBlock(
|
||||
onAgreementClick = onAgreementClick,
|
||||
onParticipateClick = state.onParticipateClicked,
|
||||
buttonIconRes = state.participateButtonIcon,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +466,7 @@ private fun Preview_ReferralScreen_NonParticipant() {
|
|||
discount = "10%",
|
||||
url = "",
|
||||
onParticipateClicked = {},
|
||||
participateButtonIcon = R.drawable.ic_tangem_24,
|
||||
),
|
||||
errorSnackbar = null,
|
||||
analytics = Analytics(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer
|
|||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.navigationButtons.NavigationButton
|
||||
import com.tangem.common.ui.navigationButtons.NavigationUM
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -664,7 +665,7 @@ internal class SendConfirmModel @Inject constructor(
|
|||
}
|
||||
else -> resourceReference(R.string.common_send)
|
||||
},
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
iconRes = walletInterationIcon(userWallet),
|
||||
isIconVisible = isReadyToSend,
|
||||
isEnabled = confirmUM.isPrimaryButtonEnabled,
|
||||
isHapticClick = isReadyToSend,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.blockchain.common.TransactionData
|
|||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.common.ui.navigationButtons.NavigationButton
|
||||
import com.tangem.common.ui.navigationButtons.NavigationUM
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -516,7 +517,7 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
}
|
||||
else -> resourceReference(R.string.common_send)
|
||||
},
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
iconRes = walletInterationIcon(userWallet),
|
||||
isIconVisible = isReadyToSend,
|
||||
isEnabled = confirmUM.isPrimaryButtonEnabled,
|
||||
isHapticClick = isReadyToSend,
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ internal class StakingModel @Inject constructor(
|
|||
subscribeOnSelectedAppCurrency()
|
||||
subscribeOnBalanceHiding()
|
||||
subscribeOnCurrencyStatusUpdates()
|
||||
stateController.initializeWithUserWallet(userWallet)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
@ -607,6 +608,7 @@ internal class StakingModel @Inject constructor(
|
|||
override fun showApprovalBottomSheet() {
|
||||
stateController.update(
|
||||
ShowApprovalBottomSheetTransformer(
|
||||
userWallet = userWallet,
|
||||
appCurrencyProvider = Provider { appCurrency },
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
feeCryptoCurrencyStatus = feeCryptoCurrencyStatus,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.core.navigation.url.UrlOpener
|
|||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.event.triggeredEvent
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.presentation.state.events.StakingEvent
|
||||
import com.tangem.features.staking.impl.presentation.state.stub.StakingClickIntentsStub
|
||||
|
|
@ -33,6 +34,14 @@ internal class StakingStateController @Inject constructor(
|
|||
private val buttonsTransformer = SetButtonsStateTransformer(urlOpener)
|
||||
private val titleTransformer = SetTitleTransformer
|
||||
|
||||
fun initializeWithUserWallet(userWallet: UserWallet) {
|
||||
mutableUiState.update {
|
||||
it.copy(
|
||||
showColdWalletInteractionIcon = userWallet is UserWallet.Cold,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun update(function: (StakingUiState) -> StakingUiState) {
|
||||
mutableUiState.update(function = function)
|
||||
mutableUiState.update(function = buttonsTransformer::transform)
|
||||
|
|
@ -88,6 +97,7 @@ internal class StakingStateController @Inject constructor(
|
|||
actionType = StakingActionCommonType.Enter(skipEnterAmount = false),
|
||||
buttonsState = NavigationButtonsState.Empty,
|
||||
balanceState = null,
|
||||
showColdWalletInteractionIcon = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ internal data class StakingUiState(
|
|||
val buttonsState: NavigationButtonsState,
|
||||
val event: StateEvent<StakingEvent>,
|
||||
val balanceState: BalanceState?,
|
||||
val showColdWalletInteractionIcon: Boolean,
|
||||
) {
|
||||
|
||||
fun copyWrapped(
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ internal class SetButtonsStateTransformer(
|
|||
val isPrimaryButtonDisabled = prevState.isPrimaryButtonDisabled()
|
||||
return NavigationButton(
|
||||
textReference = prevState.getButtonText(),
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
iconRes = R.drawable.ic_tangem_24.takeIf { prevState.showColdWalletInteractionIcon },
|
||||
isDimmed = isPrimaryButtonDisabled,
|
||||
isIconVisible = isIconVisible,
|
||||
showProgress = isInProgress,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.features.staking.impl.presentation.state.transformers.approva
|
|||
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.bottomsheet.permission.state.*
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
|
|
@ -10,6 +11,7 @@ import com.tangem.core.ui.format.bigdecimal.fiat
|
|||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.FeeState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
|
|
@ -18,6 +20,7 @@ import com.tangem.utils.Provider
|
|||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal class ShowApprovalBottomSheetTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val feeCryptoCurrencyStatus: CryptoCurrencyStatus?,
|
||||
|
|
@ -75,6 +78,7 @@ internal class ShowApprovalBottomSheetTransformer(
|
|||
footerText = resourceReference(R.string.staking_give_permission_fee_footer),
|
||||
onChangeApproveType = prevState.clickIntents::onApproveTypeChange,
|
||||
),
|
||||
walletInteractionIcon = walletInterationIcon(userWallet),
|
||||
onCancel = onDismiss,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer
|
|||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.navigationButtons.NavigationButton
|
||||
import com.tangem.common.ui.navigationButtons.NavigationUM
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.analytics.models.Basic
|
||||
|
|
@ -439,7 +440,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
}
|
||||
else -> resourceReference(R.string.common_send)
|
||||
},
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
iconRes = walletInterationIcon(params.userWallet),
|
||||
isIconVisible = isReadyToSend,
|
||||
isHapticClick = isReadyToSend,
|
||||
isEnabled = confirmUM.isPrimaryButtonEnabled,
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ internal class SwapModel @Inject constructor(
|
|||
private val selectedAppCurrencyFlow: StateFlow<AppCurrency> = createSelectedAppCurrencyFlow()
|
||||
|
||||
private val stateBuilder = StateBuilder(
|
||||
userWalletProvider = Provider { userWallet },
|
||||
actions = createUiActions(),
|
||||
isBalanceHiddenProvider = Provider { isBalanceHidden },
|
||||
appCurrencyProvider = Provider(selectedAppCurrencyFlow::value),
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ sealed class SwapCardState {
|
|||
}
|
||||
|
||||
data class SwapButton(
|
||||
@DrawableRes val walletInteractionIcon: Int?,
|
||||
val enabled: Boolean,
|
||||
val onClick: () -> Unit,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.common.ui.alerts.models.AlertDemoModeUM
|
|||
import com.tangem.common.ui.bottomsheet.permission.state.*
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.common.ui.swapStoriesScreen.SwapStoriesFactory
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.currency.icon.converter.CryptoCurrencyToIconStateConverter
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
|
|
@ -19,6 +20,7 @@ import com.tangem.core.ui.utils.parseBigDecimal
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.promo.models.StoryContent
|
||||
import com.tangem.feature.swap.converters.SwapTransactionErrorStateConverter
|
||||
import com.tangem.feature.swap.converters.TokensDataConverter
|
||||
|
|
@ -53,6 +55,7 @@ import kotlin.math.min
|
|||
*/
|
||||
@Suppress("LargeClass", "TooManyFunctions")
|
||||
internal class StateBuilder(
|
||||
private val userWalletProvider: Provider<UserWallet>,
|
||||
private val actions: UiActions,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
|
|
@ -111,7 +114,11 @@ internal class StateBuilder(
|
|||
isBalanceHidden = true,
|
||||
),
|
||||
fee = FeeItemState.Empty,
|
||||
swapButton = SwapButton(enabled = false, onClick = {}),
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
),
|
||||
onRefresh = {},
|
||||
onBackClicked = actions.onBackClicked,
|
||||
onChangeCardsClicked = actions.onChangeCardsClicked,
|
||||
|
|
@ -167,6 +174,7 @@ internal class StateBuilder(
|
|||
notifications = notificationsFactory.getNotAvailableStateNotifications(fromToken.currency.name),
|
||||
fee = FeeItemState.Empty,
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = false,
|
||||
onClick = { },
|
||||
),
|
||||
|
|
@ -225,7 +233,11 @@ internal class StateBuilder(
|
|||
),
|
||||
notifications = persistentListOf(),
|
||||
fee = FeeItemState.Empty,
|
||||
swapButton = SwapButton(enabled = false, onClick = {}),
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
),
|
||||
providerState = ProviderState.Loading(),
|
||||
permissionState = uiStateHolder.permissionState,
|
||||
changeCardsButtonState = ChangeCardsButtonState.UPDATE_IN_PROGRESS,
|
||||
|
|
@ -338,6 +350,7 @@ internal class StateBuilder(
|
|||
),
|
||||
fee = feeState,
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = getSwapButtonEnabled(notifications),
|
||||
onClick = actions.onSwapClick,
|
||||
),
|
||||
|
|
@ -465,6 +478,7 @@ internal class StateBuilder(
|
|||
permissionState = GiveTxPermissionState.Empty,
|
||||
fee = FeeItemState.Empty,
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = false,
|
||||
onClick = actions.onSwapClick,
|
||||
),
|
||||
|
|
@ -561,6 +575,7 @@ internal class StateBuilder(
|
|||
isInsufficientFunds = false,
|
||||
fee = FeeItemState.Empty,
|
||||
swapButton = SwapButton(
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
enabled = false,
|
||||
onClick = { },
|
||||
),
|
||||
|
|
@ -973,6 +988,7 @@ internal class StateBuilder(
|
|||
val config = GiveTxPermissionBottomSheetConfig(
|
||||
data = permissionState,
|
||||
onCancel = onDismiss,
|
||||
walletInteractionIcon = walletInterationIcon(userWalletProvider()),
|
||||
)
|
||||
return uiState.copy(
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ private fun MainButton(state: SwapStateHolder, onPermissionWarningClick: () -> U
|
|||
PrimaryButtonIconEnd(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResourceSafe(id = R.string.swapping_swap_action),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = state.swapButton.walletInteractionIcon,
|
||||
enabled = state.swapButton.enabled,
|
||||
onClick = state.swapButton.onClick,
|
||||
)
|
||||
|
|
@ -441,7 +441,7 @@ private val state = SwapStateHolder(
|
|||
),
|
||||
SwapNotificationUM.Warning.NoAvailableTokensToSwap("POLYGON"),
|
||||
),
|
||||
swapButton = SwapButton(enabled = true, onClick = {}),
|
||||
swapButton = SwapButton(enabled = true, onClick = {}, walletInteractionIcon = null),
|
||||
onRefresh = {},
|
||||
onBackClicked = {},
|
||||
onChangeCardsClicked = {},
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package com.tangem.feature.tokendetails.presentation.tokendetails.state.components
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.networkIconResId
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import org.joda.time.DateTime
|
||||
|
|
@ -212,6 +214,7 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
|
|||
)
|
||||
|
||||
data class KaspaIncompleteTransactionWarning(
|
||||
private val userWallet: UserWallet,
|
||||
private val currency: CryptoCurrency,
|
||||
private val amount: String,
|
||||
private val currencySymbol: String,
|
||||
|
|
@ -227,7 +230,7 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
|
|||
buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = resourceReference(R.string.alert_button_try_again),
|
||||
onClick = onRetryIncompleteTransactionClick,
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = walletInterationIcon(userWallet),
|
||||
),
|
||||
onCloseClick = onDismissIncompleteTransactionClick,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory
|
||||
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
|
|
@ -7,9 +8,11 @@ import com.tangem.core.ui.format.bigdecimal.crypto
|
|||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.core.ui.format.bigdecimal.shorted
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
|
||||
import com.tangem.domain.tokens.model.warnings.HederaWarnings
|
||||
import com.tangem.domain.tokens.model.warnings.KaspaWarnings
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification
|
||||
|
|
@ -23,6 +26,8 @@ import timber.log.Timber
|
|||
import java.math.BigDecimal
|
||||
|
||||
internal class TokenDetailsNotificationConverter(
|
||||
private val userWalletId: UserWalletId,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
private val clickIntents: TokenDetailsClickIntents,
|
||||
) : Converter<Set<CryptoCurrencyWarning>, ImmutableList<TokenDetailsNotification>> {
|
||||
|
||||
|
|
@ -131,6 +136,8 @@ internal class TokenDetailsNotificationConverter(
|
|||
onOpenClick = clickIntents::onOpenTrustlineClick,
|
||||
)
|
||||
is KaspaWarnings.IncompleteTransaction -> KaspaIncompleteTransactionWarning(
|
||||
userWallet = getUserWalletUseCase.invoke(userWalletId)
|
||||
.getOrElse { error("Cannot find user wallet with id: ${userWalletId.stringValue}") },
|
||||
currency = warning.currency,
|
||||
amount = warning.amount.format { crypto(symbol = "", decimals = warning.currencyDecimals) },
|
||||
currencySymbol = warning.currencySymbol,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,11 @@ internal class TokenDetailsStateFactory(
|
|||
}
|
||||
|
||||
private val notificationConverter by lazy {
|
||||
TokenDetailsNotificationConverter(clickIntents = clickIntents)
|
||||
TokenDetailsNotificationConverter(
|
||||
userWalletId = userWalletId,
|
||||
getUserWalletUseCase = getUserWalletUseCase,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val tokenDetailsLoadedBalanceConverter by lazy {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.domain
|
||||
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig.ButtonsState
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig.IconTint
|
||||
|
|
@ -76,7 +77,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
|
||||
addSepaPromoNotification(userWallet, clickIntents, shouldShowSepaBanner)
|
||||
|
||||
addInformationalNotifications(cardTypesResolver, maybeTokenList, clickIntents)
|
||||
addInformationalNotifications(userWallet, cardTypesResolver, maybeTokenList, clickIntents)
|
||||
|
||||
addWarningNotifications(cardTypesResolver, maybeTokenList, isNeedToBackup, clickIntents)
|
||||
|
||||
|
|
@ -177,6 +178,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addInformationalNotifications(
|
||||
userWallet: UserWallet,
|
||||
cardTypesResolver: CardTypesResolver?,
|
||||
maybeTokenList: Lce<TokenListError, TokenList>,
|
||||
clickIntents: WalletClickIntents,
|
||||
|
|
@ -186,10 +188,11 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
condition = cardTypesResolver != null && isDemoCardUseCase(cardId = cardTypesResolver.getCardId()),
|
||||
)
|
||||
|
||||
addMissingAddressesNotification(maybeTokenList, clickIntents)
|
||||
addMissingAddressesNotification(userWallet, maybeTokenList, clickIntents)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addMissingAddressesNotification(
|
||||
userWallet: UserWallet,
|
||||
maybeTokenList: Lce<TokenListError, TokenList>,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
|
|
@ -198,6 +201,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
|
||||
addIf(
|
||||
element = WalletNotification.Informational.MissingAddresses(
|
||||
tangemIcon = walletInterationIcon(userWallet),
|
||||
missingAddressesCount = currencies.count(),
|
||||
onGenerateClick = {
|
||||
clickIntents.onGenerateMissedAddressesClick(missedAddressCurrencies = currencies)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
|
|
@ -152,7 +153,11 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
),
|
||||
) {
|
||||
|
||||
data class MissingAddresses(val missingAddressesCount: Int, val onGenerateClick: () -> Unit) : Informational(
|
||||
data class MissingAddresses(
|
||||
@DrawableRes val tangemIcon: Int?,
|
||||
val missingAddressesCount: Int,
|
||||
val onGenerateClick: () -> Unit,
|
||||
) : Informational(
|
||||
title = resourceReference(id = R.string.warning_missing_derivation_title),
|
||||
subtitle = pluralReference(
|
||||
id = R.plurals.warning_missing_derivation_message,
|
||||
|
|
@ -161,7 +166,7 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
),
|
||||
buttonsState = NotificationConfig.ButtonsState.PrimaryButtonConfig(
|
||||
text = resourceReference(id = R.string.common_generate_addresses),
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = tangemIcon,
|
||||
onClick = onGenerateClick,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMessageSignUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMethodContext
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcSignState
|
||||
|
|
@ -32,6 +33,7 @@ internal class WcSignTransactionUMConverter @Inject constructor(
|
|||
networkInfo = networkInfoUMConverter.convert(value.context.network),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
address = WcAddressConverter.convert(value.context.derivationState),
|
||||
walletInteractionIcon = walletInterationIcon(value.context.session.wallet),
|
||||
),
|
||||
transactionRequestInfo = WcTransactionRequestInfoUM(
|
||||
requestBlockUMConverter.convert(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMessageSignUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMethodContext
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcSignState
|
||||
|
|
@ -32,6 +33,7 @@ internal class WcSignTypedDataUMConverter @Inject constructor(
|
|||
networkInfo = networkInfoUMConverter.convert(value.context.network),
|
||||
address = WcAddressConverter.convert(value.context.derivationState),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
walletInteractionIcon = walletInterationIcon(value.context.session.wallet),
|
||||
),
|
||||
transactionRequestInfo = WcTransactionRequestInfoUM(
|
||||
blocks = buildList {
|
||||
|
|
|
|||
|
|
@ -32,4 +32,5 @@ internal data class WcSendTransactionItemUM(
|
|||
val sendEnabled: Boolean,
|
||||
val feeErrorNotification: NotificationUM.Info?,
|
||||
val isLoading: Boolean = false,
|
||||
val walletInteractionIcon: Int? = null,
|
||||
) : TangemBottomSheetConfigContent
|
||||
|
|
@ -18,5 +18,6 @@ internal data class WcSignTransactionItemUM(
|
|||
val walletName: String?,
|
||||
val networkInfo: WcNetworkInfoUM,
|
||||
val address: String?,
|
||||
val walletInteractionIcon: Int?,
|
||||
val isLoading: Boolean = false,
|
||||
) : TangemBottomSheetConfigContent
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.ui.common
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
|
|
@ -16,11 +17,13 @@ import com.tangem.core.ui.extensions.stringResourceSafe
|
|||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.walletconnect.impl.R
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
internal fun WcTransactionRequestButtons(
|
||||
activeButtonText: TextReference,
|
||||
isLoading: Boolean,
|
||||
validationResult: ValidationResult?,
|
||||
@DrawableRes walletInteractionIcon: Int?,
|
||||
onDismiss: () -> Unit,
|
||||
onClickActiveButton: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -52,7 +55,7 @@ internal fun WcTransactionRequestButtons(
|
|||
.weight(1f),
|
||||
text = activeButtonText.resolveReference(),
|
||||
onClick = onClickActiveButton,
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
iconResId = walletInteractionIcon,
|
||||
showProgress = isLoading,
|
||||
enabled = enabled,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ internal fun WcSendTransactionModalBottomSheet(
|
|||
activeButtonText = resourceReference(R.string.common_send),
|
||||
isLoading = state.isLoading,
|
||||
enabled = state.sendEnabled,
|
||||
walletInteractionIcon = state.walletInteractionIcon,
|
||||
validationResult = state.transactionValidationResult,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ internal fun WcSignTransactionModalBottomSheetContent(
|
|||
onClickActiveButton = state.onSign,
|
||||
activeButtonText = resourceReference(R.string.common_sign),
|
||||
isLoading = state.isLoading,
|
||||
walletInteractionIcon = state.walletInteractionIcon,
|
||||
validationResult = null,
|
||||
)
|
||||
},
|
||||
|
|
@ -184,6 +185,7 @@ private class WcSignTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
walletName = "Tangem 2.0",
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
address = null,
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24,
|
||||
),
|
||||
WcSignTransactionItemUM(
|
||||
onDismiss = {},
|
||||
|
|
@ -197,6 +199,7 @@ private class WcSignTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
walletName = null,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
address = "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24,
|
||||
),
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue