mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-05 20:16:25 +03:00
Split transaction info into separate cells
This commit is contained in:
parent
f947f3247c
commit
572f8a8600
@ -32,6 +32,17 @@ struct Transaction {
|
||||
}
|
||||
|
||||
func description(chain: EthereumChain, ethPrice: Double?) -> String {
|
||||
var result = [String]()
|
||||
if let value = valueWithSymbol(chain: chain, ethPrice: ethPrice, withLabel: false) {
|
||||
result.append(value)
|
||||
}
|
||||
result.append(feeWithSymbol(chain: chain, ethPrice: ethPrice))
|
||||
result.append("Data: " + data)
|
||||
|
||||
return result.joined(separator: "\n\n")
|
||||
}
|
||||
|
||||
func feeWithSymbol(chain: EthereumChain, ethPrice: Double?) -> String {
|
||||
let fee: String
|
||||
if let gasPrice = gasPrice,
|
||||
let gas = gas,
|
||||
@ -43,18 +54,19 @@ struct Transaction {
|
||||
} else {
|
||||
fee = "Calculating…"
|
||||
}
|
||||
var result = [String]()
|
||||
return "Fee: " + fee
|
||||
}
|
||||
|
||||
func valueWithSymbol(chain: EthereumChain, ethPrice: Double?, withLabel: Bool) -> String? {
|
||||
if let decimal = try? weiAmount.value().toNormalizedDecimal(power: 18) {
|
||||
let decimalNumber = NSDecimalNumber(decimal: decimal)
|
||||
let costString = chain.hasUSDPrice ? cost(value: decimalNumber, price: ethPrice) : ""
|
||||
if let value = ethString(decimalNumber: decimalNumber) {
|
||||
result.append("\(value) \(chain.symbol)" + costString)
|
||||
let valueString = "\(value) \(chain.symbol)" + costString
|
||||
return withLabel ? "Value: " + valueString : valueString
|
||||
}
|
||||
}
|
||||
result.append("Fee: " + fee)
|
||||
result.append("Data: " + data)
|
||||
|
||||
return result.joined(separator: "\n\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
private func cost(value: NSDecimalNumber, price: Double?) -> String {
|
||||
|
@ -63,9 +63,15 @@ class ApproveTransactionViewController: UIViewController {
|
||||
private func updateInterface() {
|
||||
cellModels = [
|
||||
.textWithImage(text: peerMeta?.name ?? Strings.unknownWebsite, imageURL: peerMeta?.iconURLString, image: nil),
|
||||
.textWithImage(text: address.trimmedAddress, imageURL: nil, image: Blockies(seed: address.lowercased()).createImage()),
|
||||
.text(transaction.description(chain: chain, ethPrice: priceService.currentPrice))
|
||||
.textWithImage(text: address.trimmedAddress, imageURL: nil, image: Blockies(seed: address.lowercased()).createImage())
|
||||
]
|
||||
|
||||
if let value = transaction.valueWithSymbol(chain: chain, ethPrice: priceService.currentPrice, withLabel: true) {
|
||||
cellModels.append(.text(value))
|
||||
}
|
||||
cellModels.append(.text(transaction.feeWithSymbol(chain: chain, ethPrice: priceService.currentPrice)))
|
||||
// TODO: display tx data somehow
|
||||
|
||||
tableView.reloadData()
|
||||
okButton.isEnabled = transaction.hasFee
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user