diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt
index 28a7f06b08..c15813fdaa 100644
--- a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt
+++ b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt
@@ -7,6 +7,7 @@ import com.tangem.tap.common.extensions.stripZeroPlainString
import com.tangem.tap.features.send.redux.ReceiptAction.RefreshReceipt
import com.tangem.tap.features.send.redux.SendScreenAction
import com.tangem.tap.features.send.redux.states.*
+import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.store
import java.math.BigDecimal
@@ -15,10 +16,6 @@ import java.math.BigDecimal
*/
class ReceiptReducer : SendInternalReducer {
- companion object {
- const val EMPTY = "-"
- }
-
private lateinit var sendState: SendState
private lateinit var amountState: AmountState
private lateinit var feeState: FeeState
@@ -137,9 +134,9 @@ class ReceiptReducer : SendInternalReducer {
)
} else {
ReceiptTokenFiat(
- amountFiat = EMPTY,
- feeFiat = EMPTY,
- totalFiat = EMPTY,
+ amountFiat = UNKNOWN_AMOUNT_SIGN,
+ feeFiat = UNKNOWN_AMOUNT_SIGN,
+ totalFiat = UNKNOWN_AMOUNT_SIGN,
willSentToken = tokensToSend.stripZeroPlainString(),
willSentFeeCoin = feeCoin.stripZeroPlainString(),
symbols = symbols
@@ -169,7 +166,7 @@ class ReceiptReducer : SendInternalReducer {
ReceiptTokenCrypto(
amountToken = tokensToSend.stripZeroPlainString(),
feeCoin = feeCoin.stripZeroPlainString().addPrecisionSign(),
- totalFiat = EMPTY,
+ totalFiat = UNKNOWN_AMOUNT_SIGN,
symbols = symbols
)
}
@@ -206,7 +203,7 @@ class ReceiptReducer : SendInternalReducer {
return when {
!isToken && sendState.coinIsConvertible() -> sendState.coinConverter!!.toFiatWithPrecision(value).stripZeroPlainString()
isToken && sendState.tokenIsConvertible() -> sendState.tokenConverter!!.toFiatWithPrecision(value).stripZeroPlainString()
- else -> EMPTY
+ else -> UNKNOWN_AMOUNT_SIGN
}
}
diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt
index 3c49da49fb..2b71c1ba31 100644
--- a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt
+++ b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt
@@ -17,12 +17,13 @@ import com.tangem.tap.features.BaseStoreFragment
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.Error
import com.tangem.tap.features.send.redux.FeeAction
import com.tangem.tap.features.send.redux.SendAction
-import com.tangem.tap.features.send.redux.reducers.ReceiptReducer
import com.tangem.tap.features.send.redux.states.*
import com.tangem.tap.features.send.ui.FeeUiHelper
import com.tangem.tap.features.send.ui.SendFragment
import com.tangem.tap.features.send.ui.dialogs.SendTransactionFailsDialog
import com.tangem.tap.features.send.ui.dialogs.TezosWarningDialog
+import com.tangem.tap.features.wallet.redux.WalletState.Companion.ROUGH_SIGN
+import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.adapters.WarningMessagesAdapter
import com.tangem.tap.store
import com.tangem.wallet.R
@@ -257,12 +258,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
val mainLayout = clReceiptContainer as ViewGroup
val totalLayout = llTotalContainer.llTotal as ViewGroup
val totalTokenLayout = llTotalContainer.flTotalTokenCrypto as ViewGroup
- fun getString(id: Int, vararg formatStrings: String): String =
- mainLayout.context.getString(id, *formatStrings)
- val rough = getString(R.string.sign_rough)
- fun roughOrEmpty(value: String): String =
- if (value == ReceiptReducer.EMPTY) value else "$rough $value"
+ fun getString(id: Int, vararg formatStrings: String): String = mainLayout.getString(id, *formatStrings)
+
+ fun roughOrEmpty(value: String): String {
+ return if (value == UNKNOWN_AMOUNT_SIGN) value else "$ROUGH_SIGN $value"
+ }
when (state.visibleTypeOfReceipt) {
ReceiptLayoutType.FIAT -> {
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt
index b906784269..b4502b9267 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt
@@ -1,12 +1,7 @@
package com.tangem.tap.features.wallet.redux
import android.graphics.Bitmap
-import com.tangem.blockchain.common.Amount
-import com.tangem.blockchain.common.Blockchain
-import com.tangem.blockchain.common.DerivationStyle
-import com.tangem.blockchain.common.Token
-import com.tangem.blockchain.common.Wallet
-import com.tangem.blockchain.common.WalletManager
+import com.tangem.blockchain.common.*
import com.tangem.blockchain.common.address.AddressType
import com.tangem.common.extensions.isZero
import com.tangem.domain.common.extensions.canHandleToken
@@ -24,21 +19,15 @@ import com.tangem.tap.domain.extensions.sellIsAllowed
import com.tangem.tap.domain.tokens.models.BlockchainNetwork
import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsState
import com.tangem.tap.features.tokens.redux.TokenWithBlockchain
-import com.tangem.tap.features.wallet.models.PendingTransaction
-import com.tangem.tap.features.wallet.models.TotalBalance
-import com.tangem.tap.features.wallet.models.WalletRent
-import com.tangem.tap.features.wallet.models.WalletWarning
-import com.tangem.tap.features.wallet.models.hasPendingTransactions
-import com.tangem.tap.features.wallet.models.hasSendableAmounts
-import com.tangem.tap.features.wallet.models.isSendableAmount
+import com.tangem.tap.features.wallet.models.*
import com.tangem.tap.features.wallet.redux.reducers.calculateTotalFiatAmount
import com.tangem.tap.features.wallet.redux.reducers.findProgressState
import com.tangem.tap.features.wallet.ui.BalanceStatus
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
import com.tangem.tap.network.exchangeServices.CurrencyExchangeManager
import com.tangem.tap.store
-import java.math.BigDecimal
import org.rekotlin.StateType
+import java.math.BigDecimal
import kotlin.properties.ReadOnlyProperty
data class WalletState(
@@ -315,6 +304,11 @@ data class WalletState(
)
} else this
}
+
+ companion object {
+ const val UNKNOWN_AMOUNT_SIGN = "—"
+ const val ROUGH_SIGN = "≈"
+ }
}
sealed interface WalletDialog : StateDialog {
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt
index 850f6b3b3b..80ccfca757 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt
@@ -11,6 +11,7 @@ import com.tangem.tap.features.wallet.models.filterByToken
import com.tangem.tap.features.wallet.models.getPendingTransactions
import com.tangem.tap.features.wallet.models.removeUnknownTransactions
import com.tangem.tap.features.wallet.redux.*
+import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.BalanceStatus
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
import com.tangem.tap.features.wallet.ui.TokenData
@@ -125,9 +126,8 @@ class MultiWalletReducer {
action.amount.decimals, action.amount.currencySymbol
),
fiatAmountFormatted = tokenWalletData.fiatRate?.let {
- action.amount.value
- ?.toFiatString(it, store.state.globalState.appCurrency.symbol)
- },
+ action.amount.value?.toFiatString(it, store.state.globalState.appCurrency.symbol)
+ } ?: UNKNOWN_AMOUNT_SIGN,
blockchainAmount = wallet.amounts[AmountType.Coin]?.value ?: BigDecimal.ZERO
),
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt
index ac3ede0818..2e03a3f88d 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt
@@ -13,11 +13,11 @@ import com.tangem.tap.features.wallet.models.filterByToken
import com.tangem.tap.features.wallet.models.getPendingTransactions
import com.tangem.tap.features.wallet.models.removeUnknownTransactions
import com.tangem.tap.features.wallet.redux.*
+import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.BalanceStatus
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
import com.tangem.tap.features.wallet.ui.TokenData
import com.tangem.tap.store
-import java.math.RoundingMode
class OnWalletLoadedReducer {
@@ -54,6 +54,8 @@ class OnWalletLoadedReducer {
}
val fiatAmount = walletData.fiatRate?.let { coinAmountValue?.toFiatValue(it) }
+ val fiatAmountFormatted = fiatAmount?.toFormattedFiatValue(fiatCurrency.symbol) ?: UNKNOWN_AMOUNT_SIGN
+
val newWalletData = walletData.copy(
currencyData = walletData.currencyData.copy(
status = balanceStatus,
@@ -63,7 +65,7 @@ class OnWalletLoadedReducer {
amount = coinAmountValue,
amountFormatted = formattedAmount,
fiatAmount = fiatAmount,
- fiatAmountFormatted = fiatAmount?.toFormattedFiatValue(fiatCurrency.symbol)
+ fiatAmountFormatted = fiatAmountFormatted,
),
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
mainButton = WalletMainButton.SendButton(isCoinSendButtonEnabled),
@@ -81,8 +83,9 @@ class OnWalletLoadedReducer {
else -> BalanceStatus.VerifiedOnline
}
val tokenAmountValue = wallet.getTokenAmount(token)?.value
- val tokenFiatAmount =
- tokenWalletData?.fiatRate?.let { rate -> tokenAmountValue?.toFiatValue(rate) }
+ val tokenFiatAmount = tokenWalletData?.fiatRate?.let { tokenAmountValue?.toFiatValue(it) }
+ val tokenFiatAmountFormatted = tokenFiatAmount?.toFormattedFiatValue(fiatCurrency.symbol)
+ ?: UNKNOWN_AMOUNT_SIGN
val isTokenSendButtonEnabled = newWalletData.shouldEnableTokenSendButton()
&& pendingTransactions.isEmpty()
@@ -96,7 +99,7 @@ class OnWalletLoadedReducer {
token.symbol
),
fiatAmount = tokenFiatAmount,
- fiatAmountFormatted = tokenFiatAmount?.toFormattedFiatValue(fiatCurrency.symbol)
+ fiatAmountFormatted = tokenFiatAmountFormatted,
),
pendingTransactions = tokenPendingTransactions.removeUnknownTransactions(),
mainButton = WalletMainButton.SendButton(isTokenSendButtonEnabled),
@@ -140,9 +143,8 @@ class OnWalletLoadedReducer {
wallet.blockchain.decimals(),
wallet.blockchain.currency
)
- val fiatRate = walletState.primaryWallet?.fiatRate
- val fiatAmountRaw = fiatRate?.multiply(amount)?.setScale(2, RoundingMode.DOWN)
- val fiatAmount = fiatRate?.let { amount?.toFiatString(it, fiatCurrencyName) }
+ val fiatAmount = walletState.primaryWallet?.fiatRate?.let { amount?.toFiatValue(it) }
+ val fiatAmountFormatted = fiatAmount?.toFormattedFiatValue(fiatCurrencyName) ?: UNKNOWN_AMOUNT_SIGN
val pendingTransactions = wallet.getPendingTransactions()
val sendButtonEnabled = amount?.isZero() == false && pendingTransactions.isEmpty()
@@ -159,8 +161,8 @@ class OnWalletLoadedReducer {
blockchainAmount = amount,
amount = amount,
amountFormatted = formattedAmount,
- fiatAmountFormatted = fiatAmount,
- fiatAmount = fiatAmountRaw
+ fiatAmount = fiatAmount,
+ fiatAmountFormatted = fiatAmountFormatted
),
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/BalanceWidget.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/BalanceWidget.kt
index 2be2f19145..c627aa2e32 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/ui/BalanceWidget.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/BalanceWidget.kt
@@ -26,8 +26,8 @@ data class BalanceWidgetData(
val blockchainAmount: BigDecimal? = BigDecimal.ZERO,
val amount: BigDecimal? = null,
val amountFormatted: String? = null,
- val fiatAmountFormatted: String? = null,
val fiatAmount: BigDecimal? = null,
+ val fiatAmountFormatted: String? = null,
val token: TokenData? = null,
val amountToCreateAccount: String? = null,
val errorMessage: String? = null
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 77ed03ebfa..00b0fb8d78 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,11 +1,7 @@
package com.tangem.tap.features.wallet.ui
import android.os.Bundle
-import android.view.Menu
-import android.view.MenuInflater
-import android.view.MenuItem
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.annotation.ColorRes
@@ -16,28 +12,17 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.transition.TransitionInflater
import by.kirich1409.viewbindingdelegate.viewBinding
import com.squareup.picasso.Picasso
+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.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.loadCurrenciesIcon
-import com.tangem.tap.common.extensions.show
-import com.tangem.tap.common.extensions.toQrCode
+import com.tangem.tap.common.extensions.*
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.PendingTransaction
-import com.tangem.tap.features.wallet.redux.Currency
-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.*
+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.test.TestWalletDetails
@@ -143,6 +128,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
handleCurrencyIcon(selectedWallet)
handleWarnings(selectedWallet)
+ updateViewMeasurements()
binding.srlWalletDetails.setOnRefreshListener {
if (selectedWallet.currencyData.status != BalanceStatus.Loading) {
@@ -161,13 +147,27 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
}
}
+ private fun updateViewMeasurements() {
+ val tvFiatAmount = binding.lWalletDetails.lBalance.tvFiatAmount
+ val paddingStart = when (tvFiatAmount.text) {
+ UNKNOWN_AMOUNT_SIGN -> 16f
+ else -> 12f
+ }
+ tvFiatAmount.setPadding(
+ tvFiatAmount.dpToPx(paddingStart).toInt(),
+ tvFiatAmount.paddingTop,
+ tvFiatAmount.paddingEnd,
+ tvFiatAmount.paddingBottom,
+ )
+ }
+
private fun setupCurrency(currencyData: BalanceWidgetData, currency: Currency) = with(binding) {
tvCurrencyTitle.text = currencyData.currency
if (currency is Currency.Token) {
- binding.tvCurrencySubtitle.text = currency.blockchain.tokenDisplayName()
- binding.tvCurrencySubtitle.show()
+ tvCurrencySubtitle.text = currency.blockchain.tokenDisplayName()
+ tvCurrencySubtitle.show()
} else {
- binding.tvCurrencySubtitle.hide()
+ tvCurrencySubtitle.hide()
}
}
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 afcb72f78e..f786bbe4c3 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
@@ -106,8 +106,8 @@ class WalletAdapter
)
lContent.tvCurrency.text = wallet.currencyData.currency
- lContent.tvAmountFiat.text = wallet.currencyData.fiatAmountFormatted ?: "—"
- lContent.tvAmount.text = wallet.currencyData.amountFormatted ?: "—"
+ lContent.tvAmountFiat.text = wallet.currencyData.fiatAmountFormatted
+ lContent.tvAmount.text = wallet.currencyData.amountFormatted
lContent.tvStatus.isVisible = statusMessage != null
lContent.tvStatus.text = statusMessage
diff --git a/app/src/main/res/layout/layout_balance_wallet_details.xml b/app/src/main/res/layout/layout_balance_wallet_details.xml
index 29a44311c8..781b8f5145 100644
--- a/app/src/main/res/layout/layout_balance_wallet_details.xml
+++ b/app/src/main/res/layout/layout_balance_wallet_details.xml
@@ -7,13 +7,12 @@
android:layout_height="120dp">
+ tools:text="496304.28 RUB" />
+ app:layout_constraintTop_toBottomOf="@id/tv_fiat_amount"
+ tools:text="0.43 BTC" />
+ app:layout_constraintTop_toBottomOf="@id/tv_amount"
+ tools:text="Some error" />
diff --git a/app/src/main/res/values/strings_untranslatable.xml b/app/src/main/res/values/strings_untranslatable.xml
deleted file mode 100644
index ff1f090a6f..0000000000
--- a/app/src/main/res/values/strings_untranslatable.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- ≈
-
-