From c6efeb3d566ba4805530ddfe3c1e7db2db1dff68 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 3 Jun 2024 13:41:55 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/state/model/WalletManageButton.kt | 8 +++++++- .../InitializeWalletsTransformer.kt | 2 +- .../SetCryptoCurrencyActionsTransformer.kt | 3 +++ .../state/utils/WalletLoadingStateFactory.kt | 2 +- .../WalletCurrencyActionsClickIntents.kt | 18 ++++++++++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletManageButton.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletManageButton.kt index 8035434bcf..afbd667405 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletManageButton.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletManageButton.kt @@ -24,6 +24,9 @@ internal sealed class WalletManageButton(val config: ActionButtonConfig) { /** Lambda be invoked when manage button is clicked */ abstract val onClick: () -> Unit + /** Lambda be invoked when manage button is long clicked */ + open val onLongClick: (() -> TextReference?)? = null + /** * Buy * @@ -69,17 +72,20 @@ internal sealed class WalletManageButton(val config: ActionButtonConfig) { * Receive * * @property onClick lambda be invoked when Receive button is clicked + * @property onLongClick lambda be invoked when Receive button is long clicked */ data class Receive( override val enabled: Boolean, override val dimContent: Boolean, override val onClick: () -> Unit, + override val onLongClick: (() -> TextReference?)?, ) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_receive), iconResId = R.drawable.ic_arrow_down_24, - onClick = onClick, dimContent = dimContent, + onClick = onClick, + onLongClick = onLongClick, ), ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt index 82097668ff..0ead18d878 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt @@ -85,7 +85,7 @@ internal class InitializeWalletsTransformer( private fun createDisabledButtons(): PersistentList { return persistentListOf( - WalletManageButton.Receive(enabled = false, dimContent = false, onClick = {}), + WalletManageButton.Receive(enabled = false, dimContent = false, onClick = {}, onLongClick = null), WalletManageButton.Send(enabled = false, dimContent = false, onClick = {}), WalletManageButton.Buy(enabled = false, dimContent = false, onClick = {}), WalletManageButton.Sell(enabled = false, dimContent = false, onClick = {}), diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetCryptoCurrencyActionsTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetCryptoCurrencyActionsTransformer.kt index ef747e1305..c541164b5f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetCryptoCurrencyActionsTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetCryptoCurrencyActionsTransformer.kt @@ -61,6 +61,9 @@ internal class SetCryptoCurrencyActionsTransformer( onClick = { clickIntents.onReceiveClick(cryptoCurrencyStatus = cryptoCurrencyStatus) }, + onLongClick = { + clickIntents.onCopyAddressLongClick(cryptoCurrencyStatus = cryptoCurrencyStatus) + }, ) } is TokenActionsState.ActionState.Sell -> { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt index 71f0bdd4c4..feeb07e488 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt @@ -88,7 +88,7 @@ internal class WalletLoadingStateFactory(private val clickIntents: WalletClickIn private fun createDimmedButtons(): PersistentList { return persistentListOf( - WalletManageButton.Receive(enabled = true, dimContent = true, onClick = {}), + WalletManageButton.Receive(enabled = true, dimContent = true, onClick = {}, onLongClick = null), WalletManageButton.Send(enabled = true, dimContent = true, onClick = {}), WalletManageButton.Buy(enabled = true, dimContent = true, onClick = {}), WalletManageButton.Sell(enabled = true, dimContent = true, onClick = {}), diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletCurrencyActionsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletCurrencyActionsClickIntents.kt index 53f2f86e93..318fddb6c3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletCurrencyActionsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletCurrencyActionsClickIntents.kt @@ -2,6 +2,7 @@ package com.tangem.feature.wallet.presentation.wallet.viewmodels.intents import com.tangem.blockchain.common.address.AddressType import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.core.ui.clipboard.ClipboardManager import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent import com.tangem.core.ui.components.bottomsheets.chooseaddress.ChooseAddressBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.tokenreceive.AddressModel @@ -11,6 +12,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.WrappedList import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.wrappedList +import com.tangem.core.ui.haptic.HapticManager import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.extenstions.unwrap import com.tangem.domain.common.util.cardTypesResolver @@ -56,6 +58,8 @@ interface WalletCurrencyActionsClickIntents { fun onReceiveClick(cryptoCurrencyStatus: CryptoCurrencyStatus) + fun onCopyAddressLongClick(cryptoCurrencyStatus: CryptoCurrencyStatus): TextReference? + fun onCopyAddressClick(cryptoCurrencyStatus: CryptoCurrencyStatus) fun onHideTokensClick(cryptoCurrencyStatus: CryptoCurrencyStatus) @@ -83,6 +87,8 @@ internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor( private val analyticsEventHandler: AnalyticsEventHandler, private val dispatchers: CoroutineDispatcherProvider, private val reduxStateHolder: ReduxStateHolder, + private val hapticManager: HapticManager, + private val clipboardManager: ClipboardManager, ) : BaseWalletClickIntents(), WalletCurrencyActionsClickIntents { override fun onSendClick( @@ -175,6 +181,18 @@ internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor( ) } + override fun onCopyAddressLongClick(cryptoCurrencyStatus: CryptoCurrencyStatus): TextReference? { + val networkAddress = cryptoCurrencyStatus.value.networkAddress ?: return null + val cryptoCurrency = cryptoCurrencyStatus.currency + val addresses = networkAddress.availableAddresses.mapToAddressModels(cryptoCurrency).toImmutableList() + val defaultAddress = addresses.firstOrNull()?.value ?: return null + + hapticManager.vibrateMeduim() + clipboardManager.setText(text = defaultAddress) + analyticsEventHandler.send(TokenReceiveAnalyticsEvent.ButtonCopyAddress(cryptoCurrency.symbol)) + return resourceReference(R.string.wallet_notification_address_copied) + } + private fun createReceiveBottomSheetContent( currency: CryptoCurrency, addresses: Set,