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 73eb9ea393..0f54d5b13a 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
@@ -1,7 +1,11 @@
package com.tangem.tap.features.wallet.ui
import android.os.Bundle
-import android.view.*
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.view.View
+import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.annotation.ColorRes
@@ -11,21 +15,32 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.transition.TransitionInflater
import by.kirich1409.viewbindingdelegate.viewBinding
+import com.tangem.domain.common.TapWorkarounds.derivationStyle
import com.tangem.tangem_sdk_new.extensions.dpToPx
import com.tangem.tap.common.SnackbarHandler
import com.tangem.tap.common.TestActions
-import com.tangem.tap.common.extensions.*
+import com.tangem.tap.common.extensions.appendIfNotNull
+import com.tangem.tap.common.extensions.beginDelayedTransition
+import com.tangem.tap.common.extensions.fitChipsByGroupWidth
+import com.tangem.tap.common.extensions.getColor
+import com.tangem.tap.common.extensions.getString
+import com.tangem.tap.common.extensions.hide
+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.navigation.NavigationAction
import com.tangem.tap.domain.tokens.models.BlockchainNetwork
import com.tangem.tap.features.onboarding.getQRReceiveMessage
import com.tangem.tap.features.wallet.models.Currency
import com.tangem.tap.features.wallet.models.PendingTransaction
-import com.tangem.tap.features.wallet.redux.*
+import com.tangem.tap.features.wallet.redux.ErrorType
+import com.tangem.tap.features.wallet.redux.ProgressState
+import com.tangem.tap.features.wallet.redux.WalletAction
+import com.tangem.tap.features.wallet.redux.WalletData
+import com.tangem.tap.features.wallet.redux.WalletState
import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.adapters.PendingTransactionsAdapter
import com.tangem.tap.features.wallet.ui.adapters.WalletDetailWarningMessagesAdapter
-import com.tangem.tap.features.wallet.ui.images.loadCurrencyIcon
import com.tangem.tap.features.wallet.ui.test.TestWalletDetails
import com.tangem.tap.store
import com.tangem.wallet.R
@@ -199,11 +214,12 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
}
private fun handleCurrencyIcon(wallet: WalletData) = with(binding.lWalletDetails.lBalance) {
- loadCurrencyIcon(
- currencyImageView = ivCurrency,
- currencyTextView = tvTokenLetter,
- blockchain = wallet.currency.blockchain,
- token = (wallet.currency as? Currency.Token)?.token
+ ivCurrency.load(
+ currency = wallet.currency,
+ derivationStyle = store.state.globalState
+ .scanResponse
+ ?.card
+ ?.derivationStyle,
)
}
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt
index 78bbb4c3ed..4be9104bb1 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt
@@ -9,15 +9,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import com.tangem.domain.common.TapWorkarounds.derivationStyle
-import com.tangem.tap.common.extensions.getRoundIconRes
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.show
-import com.tangem.tap.features.wallet.models.Currency
import com.tangem.tap.features.wallet.redux.WalletAction
import com.tangem.tap.features.wallet.redux.WalletData
import com.tangem.tap.features.wallet.ui.BalanceStatus
-import com.tangem.tap.features.wallet.ui.images.loadCurrencyIcon
import com.tangem.tap.store
import com.tangem.wallet.R
import com.tangem.wallet.databinding.ItemCurrencyWalletBinding
@@ -67,12 +64,6 @@ class WalletAdapter
// Skip changes when on refreshing status
if (status == BalanceStatus.Refreshing) return@with
- val isCustomCurrency = wallet.currency.isCustomCurrency(
- derivationStyle = store.state.globalState
- .scanResponse
- ?.card
- ?.derivationStyle
- )
val statusMessage = when (status) {
BalanceStatus.TransactionInProgress -> {
root.getString(R.string.wallet_balance_tx_in_progress)
@@ -87,7 +78,8 @@ class WalletAdapter
BalanceStatus.UnknownBlockchain,
BalanceStatus.Loading,
BalanceStatus.Refreshing,
- null -> null
+ null,
+ -> null
}
if (status == null || status == BalanceStatus.Loading) {
@@ -98,11 +90,12 @@ class WalletAdapter
lContent.root.show()
}
- loadCurrencyIcon(
- currencyImageView = ivCurrency,
- currencyTextView = tvTokenLetter,
- token = (wallet.currency as? Currency.Token)?.token,
- blockchain = wallet.currency.blockchain,
+ ivCurrency.load(
+ currency = wallet.currency,
+ derivationStyle = store.state.globalState
+ .scanResponse
+ ?.card
+ ?.derivationStyle,
)
lContent.tvCurrency.text = wallet.currencyData.currency
@@ -116,10 +109,6 @@ class WalletAdapter
lContent.tvExchangeRate.text = wallet.fiatRateString
?: root.getString(id = R.string.token_item_no_rate)
- badgeCustomBalance.isVisible = isCustomCurrency
- ivBlockchain.isVisible = wallet.currency.isToken()
- ivBlockchain.setImageResource(wallet.currency.blockchain.getRoundIconRes())
-
cardWallet.setOnClickListener {
store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet))
}
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt
index 41076760dc..cd7959319e 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt
@@ -19,22 +19,7 @@ import com.tangem.wallet.R
private const val QCX = "QCX"
private const val VOYR = "VOYRME"
-fun loadCurrencyIcon(
- currencyImageView: CurrencyIconView,
- currencyTextView: TextView,
- token: Token?,
- blockchain: Blockchain,
-) {
- CurrencyIconLoader(
- currencyImageView = currencyImageView.imageView,
- currencyTextView = currencyTextView,
- token = token,
- blockchain = blockchain
- )
- .load()
-}
-
-private class CurrencyIconLoader(
+class CurrencyIconRequest(
private val currencyImageView: ImageFilterView,
private val currencyTextView: TextView,
private val token: Token?,
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt
index b973c9cc52..ec9ff38519 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt
@@ -3,27 +3,69 @@ package com.tangem.tap.features.wallet.ui.images
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
+import android.widget.TextView
+import androidx.annotation.DrawableRes
import androidx.constraintlayout.utils.widget.ImageFilterView
-import com.google.android.material.card.MaterialCardView
+import androidx.constraintlayout.widget.ConstraintLayout
+import androidx.core.view.isVisible
+import com.tangem.blockchain.common.DerivationStyle
import com.tangem.tangem_sdk_new.extensions.dpToPx
+import com.tangem.tap.common.extensions.getRoundIconRes
+import com.tangem.tap.features.wallet.models.Currency
import com.tangem.wallet.databinding.ViewCurrencyIconBinding
+import kotlin.math.roundToInt
class CurrencyIconView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
-) : MaterialCardView(context, attrs, defStyleAttr) {
+) : ConstraintLayout(context, attrs, defStyleAttr) {
private val binding = ViewCurrencyIconBinding.inflate(
LayoutInflater.from(context),
- this
+ this,
)
- val imageView: ImageFilterView
- get() = binding.iv
+ private val currencyImageView: ImageFilterView
+ get() = binding.ivCurrency
+
+ private val currencyTextView: TextView
+ get() = binding.tvTokenLetter
+
+ private var isBlockchainIconVisible: Boolean
+ get() = binding.ivBlockchain.isVisible
+ set(value) = binding.ivBlockchain::isVisible.set(value)
+
+ private var isBadgeVisible: Boolean
+ get() = binding.badge.isVisible
+ set(value) = binding.badge::isVisible.set(value)
+
+ @DrawableRes
+ private var blockchainIconRes: Int? = null
+ set(value) {
+ if (value != null && value != field && isBlockchainIconVisible) {
+ binding.ivBlockchain.setImageResource(value)
+ field = value
+ }
+ }
init {
- elevation = 0f
- cardElevation = 0f
- radius = dpToPx(6f)
+ minWidth = dpToPx(48f).roundToInt()
+ minHeight = dpToPx(48f).roundToInt()
+ }
+
+ fun load(
+ currency: Currency,
+ derivationStyle: DerivationStyle?,
+ ) {
+ isBlockchainIconVisible = currency.isToken()
+ isBadgeVisible = currency.isCustomCurrency(derivationStyle)
+ blockchainIconRes = currency.blockchain.getRoundIconRes()
+
+ CurrencyIconRequest(
+ currencyImageView = currencyImageView,
+ currencyTextView = currencyTextView,
+ token = (currency as? Currency.Token)?.token,
+ blockchain = currency.blockchain,
+ ).load()
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_currency_wallet.xml b/app/src/main/res/layout/item_currency_wallet.xml
index 01860acfb1..0c6ef1fa3f 100644
--- a/app/src/main/res/layout/item_currency_wallet.xml
+++ b/app/src/main/res/layout/item_currency_wallet.xml
@@ -27,52 +27,12 @@
-
-
-
-
-
-
-
-
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ tools:layout_gravity="center"
+ tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
-
+
+
+
+
+
+
+
+
+
+
+