Merge pull request #1762 from AlphaWallet/display-token-balance-4-decimal-places

Make token balance displayed be always 4 decimal places, except for send confirmation and transaction details screen and for fiat to be 2 decimal places. Rounding down is always used
pull/1764/head
James Sangalli 5 years ago committed by GitHub
commit 9862d668ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      AlphaWallet/Accounts/ViewModels/AccountViewModel.swift
  2. 1
      AlphaWallet/Core/Formatters/CurrencyFormatter.swift
  3. 1
      AlphaWallet/Foundation/StringFormatter.swift
  4. 2
      AlphaWallet/Transactions/ViewModels/BalanceTokenViewModel.swift

@ -22,7 +22,7 @@ struct AccountViewModel {
return wallet.type == .watch(wallet.address)
}
var balance: String {
let amount = walletBalance?.amountFull ?? "--"
let amount = walletBalance?.amountShort ?? "--"
return "\(amount) \(server.symbol)"
}
var address: AlphaWallet.Address {

@ -7,6 +7,7 @@ class CurrencyFormatter {
let formatter = NumberFormatter()
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.roundingMode = .down
//TODO support multiple currency values
formatter.currencyCode = Currency.USD.rawValue
formatter.numberStyle = .currency

@ -9,6 +9,7 @@ final class StringFormatter {
formatter.currencySymbol = ""
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.roundingMode = .down
formatter.numberStyle = .currencyAccounting
formatter.isLenient = true
return formatter

@ -14,7 +14,7 @@ struct BalanceTokenViewModel: BalanceBaseViewModel {
}
var amountShort: String {
return EtherNumberFormatter.full.string(from: token.valueBigInt, decimals: token.decimals)
return EtherNumberFormatter.short.string(from: token.valueBigInt, decimals: token.decimals)
}
var name: String {

Loading…
Cancel
Save