Formatting balance properly

pull/2/head
Michael Scoff 7 years ago
parent 5c6aaaa91b
commit dbce039b2b
  1. 2
      Trust/InCoordinator.swift
  2. 7
      Trust/Tokens/ViewModels/TokensViewModel.swift
  3. 2
      Trust/Transactions/ViewModels/BalanceViewModel.swift

@ -134,7 +134,7 @@ class InCoordinator: Coordinator {
config.isDebugEnabled = !config.isDebugEnabled
guard let transactionCoordinator = transactionCoordinator else { return }
restart(for: initialAccount, in: transactionCoordinator)
restart(for: transactionCoordinator.session.account, in: transactionCoordinator)
}
func restart(for account: Account, in coordinator: TransactionCoordinator) {

@ -16,11 +16,12 @@ struct TokensViewModel {
self.tickers = tickers
}
var amount: String? {
private var amount: String? {
var totalAmount: Double = 0
tokens.forEach { token in
totalAmount += amount(for: token)
}
guard totalAmount != 0 else { return "--" }
return CurrencyFormatter.formatter.string(from: NSNumber(value: totalAmount))
}
@ -32,8 +33,8 @@ struct TokensViewModel {
return tokenValue * price
}
var headerBalance: String {
return amount ?? "--"
var headerBalance: String? {
return amount
}
var headerBalanceTextColor: UIColor {

@ -21,7 +21,7 @@ struct BalanceViewModel: BalanceBaseViewModel {
var amount: Double {
guard let balance = balance else { return 0.00 }
return balance.amountFull.doubleValue
return CurrencyFormatter.plainFormatter.string(from: balance.value).doubleValue
}
var amountString: String {

Loading…
Cancel
Save