Updated on 2026-08-14
This commit is contained in:
parent
2e857d5e3e
commit
45fa120411
49 changed files with 669 additions and 92 deletions
|
|
@ -172,6 +172,40 @@ fun BigDecimalFiatFormat.price(): BigDecimalFormat = BigDecimalFormat { value ->
|
|||
.replace(formatterCurrency.getSymbol(locale), fiatCurrencySymbol)
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats fiat price with precision calculated based on the value.
|
||||
* Styled version — fractional part uses [spanStyleReference].
|
||||
* @see getFiatPriceAmountWithScale
|
||||
*/
|
||||
fun BigDecimalFiatFormatStyled.price() = price(spanStyleReference)
|
||||
|
||||
private fun BigDecimalFiatFormatStyled.price(spanStyleReference: SpanStyleReference) = BigDecimalFormatStyled { value ->
|
||||
val formatterCurrency = getJavaCurrencyByCode(fiatCurrencyCode)
|
||||
|
||||
val (priceAmount, finalScale) = getFiatPriceAmountWithScale(value = value)
|
||||
|
||||
val formatter = NumberFormat.getCurrencyInstance(locale).apply {
|
||||
currency = formatterCurrency
|
||||
maximumFractionDigits = finalScale
|
||||
minimumFractionDigits = FIAT_MARKET_DEFAULT_DIGITS
|
||||
roundingMode = RoundingMode.HALF_UP
|
||||
}
|
||||
|
||||
val decimalSeparator = (formatter as? DecimalFormat)?.decimalFormatSymbols?.decimalSeparator
|
||||
val formattedAmount = formatter.format(priceAmount)
|
||||
.replace(formatterCurrency.getSymbol(locale), fiatCurrencySymbol)
|
||||
|
||||
val separatorIndex = decimalSeparator?.let { formattedAmount.indexOf(it) } ?: formattedAmount.length
|
||||
|
||||
val wholePart = formattedAmount.take(separatorIndex)
|
||||
val fractionalPart = formattedAmount.drop(separatorIndex)
|
||||
|
||||
combinedReference(
|
||||
stringReference(wholePart),
|
||||
styledStringReference(fractionalPart, spanStyleReference),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats fiat amount with an exact number of fractional digits.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -198,6 +198,18 @@ class TangemTypography2 internal constructor(
|
|||
),
|
||||
)
|
||||
|
||||
val bodyMedium16: TextStyle = TextStyle(
|
||||
fontFamily = fontFamily,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
letterSpacing = TextUnit(value = -0.32f, type = TextUnitType.Sp),
|
||||
lineHeight = TextUnit(value = 20f, type = TextUnitType.Sp),
|
||||
lineHeightStyle = LineHeightStyle(
|
||||
alignment = LineHeightStyle.Alignment.Center,
|
||||
trim = LineHeightStyle.Trim.None,
|
||||
),
|
||||
)
|
||||
|
||||
val bodyRegular15: TextStyle = TextStyle(
|
||||
fontFamily = fontFamily,
|
||||
fontSize = 15.sp,
|
||||
|
|
|
|||
9
core/ui/src/main/res/drawable/ic_yield_mode_16.xml
Normal file
9
core/ui/src/main/res/drawable/ic_yield_mode_16.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="16">
|
||||
<path
|
||||
android:pathData="M4,8.667C4.368,8.667 4.667,8.965 4.667,9.333V12C4.667,12.368 4.368,12.667 4,12.667C3.632,12.667 3.333,12.368 3.333,12V9.333C3.333,8.965 3.632,8.667 4,8.667ZM8,6C8.368,6 8.667,6.298 8.667,6.667V12C8.667,12.368 8.368,12.667 8,12.667C7.632,12.667 7.333,12.368 7.333,12V6.667C7.333,6.298 7.632,6 8,6ZM12,3.333C12.368,3.333 12.667,3.632 12.667,4V12C12.667,12.368 12.368,12.667 12,12.667C11.632,12.667 11.333,12.368 11.333,12V4C11.333,3.632 11.632,3.333 12,3.333Z"
|
||||
android:fillColor="#656565"/>
|
||||
</vector>
|
||||
Loading…
Add table
Add a link
Reference in a new issue