Skip to content

Commit

Permalink
Make small fixes in Market Global Metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jun 13, 2024
1 parent cab1a59 commit ca4c231
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.math.BigDecimal
import java.math.BigInteger
import java.math.RoundingMode
import java.text.NumberFormat
import java.util.*
import java.util.Locale
import java.util.concurrent.ConcurrentHashMap

class NumberFormatter(
Expand Down Expand Up @@ -115,7 +115,8 @@ class NumberFormatter(
when (value) {
is Value.Currency -> {
val currencyValue = value.currencyValue
formatFiatShort(currencyValue.value, currencyValue.currency.symbol, currencyValue.currency.decimal)
val formatted = formatFiatShort(currencyValue.value.abs(), currencyValue.currency.symbol, currencyValue.currency.decimal)
sign(value.currencyValue.value) + formatted
}
is Value.Percent -> {
format(value.percent.abs(), 0, 2, sign(value.percent), "%")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class MarketViewModel(
globalMarket.btcDominance?.let {
App.numberFormatter.format(it, 0, 2, suffix = "%")
} ?: "-",
globalMarket.btcDominance?.let { getDiff(it) } ?: "----",
globalMarket.btcDominance?.let { it > BigDecimal.ZERO } ?: false,
globalMarket.btcDominanceChange?.let { getDiff(it) } ?: "----",
globalMarket.btcDominanceChange?.let { it > BigDecimal.ZERO } ?: false,
MetricsType.TotalMarketCap
),
MarketOverviewViewItem(
Expand All @@ -105,7 +105,7 @@ class MarketViewModel(
?: "-",
globalMarket.etfDailyInflow?.let {
val sign = if (it >= BigDecimal.ZERO) "+" else "-"
"$sign${formatFiatShortened(it, baseCurrency.symbol)}"
"$sign${formatFiatShortened(it.abs(), baseCurrency.symbol)}"
} ?: "----",
globalMarket.etfDailyInflow?.let { it > BigDecimal.ZERO } ?: false,
MetricsType.Etf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ fun ChartEtf(loading: Boolean, etfPoints: List<EtfPoint>, currency: Currency) {
}

val dailyInflowStr = dailyInflow?.let {
App.numberFormatter.formatFiatShort(it.abs(), currency.symbol, currency.decimal)
val sign = when {
it == BigDecimal.ZERO -> ""
it < BigDecimal.ZERO -> "-"
else -> "+"
}
sign + App.numberFormatter.formatFiatShort(it.abs(), currency.symbol, currency.decimal)
}
val dailyInflowPositive = dailyInflow != null && dailyInflow > BigDecimal.ZERO

Expand Down

0 comments on commit ca4c231

Please sign in to comment.