Merge pull request #2301 from AlphaWallet/enter-to-send-blank-eth-should-show-0-in-actionsheet

Fix: if enter "" for eth when sending ETH, should show "0 ETH" instead of " ETH"
pull/2302/head
James Sangalli 4 years ago committed by GitHub
commit 0ce184dfd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      AlphaWallet/Transfer/ViewModels/TransactionConfirmationViewModel.swift

@ -155,11 +155,12 @@ extension TransactionConfirmationViewModel {
switch transferType {
case .nativeCryptocurrency(let token, _, _):
let cryptoToDollarSymbol = Constants.Currency.usd
if let cryptoToDollarRate = cryptoToDollarRate, let amount = Double(amount) {
let cryptoToDollarValue = StringFormatter().currency(with: amount * cryptoToDollarRate, and: cryptoToDollarSymbol)
return "\(amount) \(token.symbol)\(cryptoToDollarValue) \(cryptoToDollarSymbol)"
let double = Double(amount) ?? 0
if let cryptoToDollarRate = cryptoToDollarRate {
let cryptoToDollarValue = StringFormatter().currency(with: double * cryptoToDollarRate, and: cryptoToDollarSymbol)
return "\(double) \(token.symbol)\(cryptoToDollarValue) \(cryptoToDollarSymbol)"
} else {
return "\(amount) \(token.symbol)"
return "\(double) \(token.symbol)"
}
case .ERC20Token(let token, _, _):
return "\(amount) \(token.symbol)"

Loading…
Cancel
Save