Updated on 2026-08-14

This commit is contained in:
Tangem 2024-06-03 13:41:55 +05:00
parent a14f93ab82
commit c6efeb3d56
5 changed files with 30 additions and 3 deletions

View file

@ -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,
),
)

View file

@ -85,7 +85,7 @@ internal class InitializeWalletsTransformer(
private fun createDisabledButtons(): PersistentList<WalletManageButton> {
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 = {}),

View file

@ -61,6 +61,9 @@ internal class SetCryptoCurrencyActionsTransformer(
onClick = {
clickIntents.onReceiveClick(cryptoCurrencyStatus = cryptoCurrencyStatus)
},
onLongClick = {
clickIntents.onCopyAddressLongClick(cryptoCurrencyStatus = cryptoCurrencyStatus)
},
)
}
is TokenActionsState.ActionState.Sell -> {

View file

@ -88,7 +88,7 @@ internal class WalletLoadingStateFactory(private val clickIntents: WalletClickIn
private fun createDimmedButtons(): PersistentList<WalletManageButton> {
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 = {}),

View file

@ -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<NetworkAddress.Address>,