Updated on 2026-08-14

This commit is contained in:
Tangem 2022-05-27 17:35:14 +03:00
parent b9113a443a
commit 0c57e22fb3
4 changed files with 132 additions and 81 deletions

View file

@ -92,14 +92,18 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
}
private fun setupButtons() = with(binding) {
btnConfirm.text = getString(R.string.wallet_button_send)
btnConfirm.setOnClickListener { store.dispatch(WalletAction.Send()) }
binding.lWalletDetails.btnShare.setOnClickListener { store.dispatch(WalletAction.ShowDialog.QrCode) }
btnTrade.setOnClickListener { store.dispatch(WalletAction.TradeCryptoAction.Buy) }
btnSell.setOnClickListener { store.dispatch(WalletAction.TradeCryptoAction.Sell) }
rowButtons.onBuyClick = {
store.dispatch(WalletAction.TradeCryptoAction.Buy)
}
rowButtons.onSellClick = {
store.dispatch(WalletAction.TradeCryptoAction.Sell)
}
rowButtons.onTradeClick = {
store.dispatch(WalletAction.DialogAction.ChooseTradeActionDialog)
}
rowButtons.onSendClick = {
store.dispatch(WalletAction.Send())
}
}
private fun setupTestActionButton() {
@ -156,7 +160,6 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
}
private fun setupButtons(selectedWallet: WalletData) = with(binding) {
btnConfirm.isEnabled = selectedWallet.mainButton.enabled
lWalletDetails.btnCopy.setOnClickListener {
selectedWallet.walletAddresses?.selectedAddress?.address?.let { addressString ->
store.dispatch(WalletAction.CopyAddress(addressString, requireContext()))
@ -167,8 +170,12 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
store.dispatch(WalletAction.ShareAddress(addressString, requireContext()))
}
}
btnTrade.isEnabled = selectedWallet.tradeCryptoState.buyingAllowed
btnSell.show(selectedWallet.tradeCryptoState.sellingAllowed)
rowButtons.updateButtonsVisibility(
buyAllowed = selectedWallet.tradeCryptoState.buyingAllowed,
sellAllowed = selectedWallet.tradeCryptoState.sellingAllowed,
sendAllowed = selectedWallet.mainButton.enabled
)
}
private fun handleWarnings(selectedWallet: WalletData) = with(binding) {

View file

@ -0,0 +1,45 @@
package com.tangem.tap.features.wallet.ui.view
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.core.view.isVisible
import com.tangem.wallet.databinding.ViewWalletDetailsButtonsRowBinding
internal class WalletDetailsButtonsRow @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : LinearLayout(context, attrs, defStyleAttr) {
private val binding = ViewWalletDetailsButtonsRowBinding.inflate(
LayoutInflater.from(context),
this
)
var onBuyClick: (() -> Unit)? = null
var onSellClick: (() -> Unit)? = null
var onTradeClick: (() -> Unit)? = null
var onSendClick: (() -> Unit)? = null
init {
orientation = HORIZONTAL
with(binding) {
btnBuy.setOnClickListener { onBuyClick?.invoke() }
btnSell.setOnClickListener { onSellClick?.invoke() }
btnTrade.setOnClickListener { onTradeClick?.invoke() }
btnSend.setOnClickListener { onSendClick?.invoke() }
}
}
fun renderButtons(
buyAllowed: Boolean,
sellAllowed: Boolean,
) = with(binding) {
btnBuy.isVisible = (buyAllowed && !sellAllowed) || (!buyAllowed && !sellAllowed)
btnBuy.isEnabled = buyAllowed
btnSell.isVisible = !buyAllowed && sellAllowed
btnTrade.isVisible = buyAllowed && sellAllowed
}
}