Updated on 2026-08-14
This commit is contained in:
parent
47ffea91f2
commit
355f67a325
2 changed files with 27 additions and 7 deletions
|
|
@ -54,8 +54,6 @@ fun BigDecimal.toFormattedFiatValue(fiatCurrencyName: String): String {
|
|||
return "≈ ${fiatCurrencyName} $this"
|
||||
}
|
||||
|
||||
fun CurrenciesResponse.Currency.toFormattedString(): String = "${this.name} (${this.code}) - ${this.unit}"
|
||||
|
||||
fun BigDecimal.stripZeroPlainString(): String = this.stripTrailingZeros().toPlainString()
|
||||
|
||||
// 0.00 -> 0.00
|
||||
|
|
@ -89,4 +87,26 @@ fun BigDecimal.isGreaterThanOrEqual(value: BigDecimal): Boolean {
|
|||
fun BigDecimal.isLessThanOrEqual(value: BigDecimal): Boolean {
|
||||
val compareResult = this.compareTo(value)
|
||||
return compareResult == -1 || compareResult == 0
|
||||
}
|
||||
|
||||
fun BigDecimal.formatAmountAsSpannedString(
|
||||
currencySymbol: String,
|
||||
integerPartSizeProportion: Float = 1.4f
|
||||
): SpannedString {
|
||||
val amount = this.scaleToFiat(applyPrecision = true)
|
||||
.stripZeroPlainString()
|
||||
val integer = amount.substringAfter('.')
|
||||
val reminder = amount.substringBefore('.')
|
||||
|
||||
return buildSpannedString {
|
||||
append(
|
||||
integer,
|
||||
RelativeSizeSpan(integerPartSizeProportion),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
append('.')
|
||||
append(reminder)
|
||||
append(' ')
|
||||
append(currencySymbol)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import com.tangem.common.card.Card
|
||||
import com.tangem.domain.common.TapWorkarounds.derivationStyle
|
||||
import com.tangem.domain.common.TapWorkarounds.isTestCard
|
||||
import com.tangem.tap.common.extensions.formatAmountAsSpannedString
|
||||
import com.tangem.tap.common.extensions.hide
|
||||
import com.tangem.tap.common.extensions.show
|
||||
import com.tangem.tap.common.redux.StateDialog
|
||||
|
|
@ -134,11 +135,10 @@ class MultiWalletView : WalletView {
|
|||
binding: FragmentWalletBinding,
|
||||
totalBalance: TotalBalance,
|
||||
) = with(binding.lCardTotalBalance) {
|
||||
val fiatAmountFormatted = with(totalBalance) {
|
||||
"${fiatAmount.stripTrailingZeros()} $fiatCurrencyName"
|
||||
}
|
||||
tvBalance.text = fiatAmountFormatted
|
||||
tvCurrencyName.text = totalBalance.fiatCurrencyName
|
||||
tvBalance.text = totalBalance.fiatAmount.formatAmountAsSpannedString(
|
||||
currencySymbol = totalBalance.fiatCurrency.symbol
|
||||
)
|
||||
tvCurrencyName.text = totalBalance.fiatCurrency.code
|
||||
tvCurrencyName.setOnClickListener {
|
||||
// TODO: Open app currency selector
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue