Updated on 2026-08-14

This commit is contained in:
Tangem 2022-05-25 15:48:47 +03:00
parent eaa1215307
commit 7b026e8447
12 changed files with 249 additions and 186 deletions

View file

@ -108,24 +108,22 @@ fun BigDecimal.isLessThanOrEqual(value: BigDecimal): Boolean {
fun BigDecimal.formatAmountAsSpannedString(
currencySymbol: String,
integerPartSizeProportion: Float = 1.4f
reminderPartSizeProportion: Float = 0.7f
): SpannedString {
val amount = this
.setScale(2, RoundingMode.HALF_UP)
.toString()
.formatWithSpaces()
val integer = amount.substringBefore('.')
val reminder = amount.substringAfter('.')
return buildSpannedString {
append(integer)
append('.')
append(
integer,
RelativeSizeSpan(integerPartSizeProportion),
"$reminder $currencySymbol",
RelativeSizeSpan(reminderPartSizeProportion),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
append('.')
append(reminder)
append(' ')
append(currencySymbol)
}
}