Use slider for setting gas price

pull/2/head
Michael Scoff 7 years ago
parent 4396400ddf
commit 217be7bcdd
  1. 21
      Trust/Transfer/ViewControllers/ConfigureTransactionViewController.swift

@ -22,8 +22,8 @@ class ConfigureTransactionViewController: FormViewController {
return ConfigureTransactionViewModel(config: self.config) return ConfigureTransactionViewModel(config: self.config)
}() }()
var gasPriceRow: TextFloatLabelRow? { var gasPriceRow: SliderRow? {
return form.rowBy(tag: Values.gasPrice) as? TextFloatLabelRow return form.rowBy(tag: Values.gasPrice) as? SliderRow
} }
var gasLimitRow: TextFloatLabelRow? { var gasLimitRow: TextFloatLabelRow? {
return form.rowBy(tag: Values.gasLimit) as? TextFloatLabelRow return form.rowBy(tag: Values.gasLimit) as? TextFloatLabelRow
@ -60,13 +60,14 @@ class ConfigureTransactionViewController: FormViewController {
footer: viewModel.gasLimitFooterText footer: viewModel.gasLimitFooterText
) )
<<< AppFormAppearance.textFieldFloat(tag: Values.gasPrice) { <<< SliderRow(Values.gasPrice) {
$0.validationOptions = .validatesOnDemand $0.title = NSLocalizedString("configureTransaction.gasPrice", value: "Gas Price", comment: "")
$0.value = gasPriceGwei $0.value = Float(gasPriceGwei) ?? 1
}.cellUpdate { cell, _ in $0.minimumValue = 1
cell.textField.textAlignment = .left $0.maximumValue = 50
cell.textField.placeholder = NSLocalizedString("configureTransaction.gasPrice", value: "Gas Price (Gwei)", comment: "") $0.displayValueFor = { (rowValue: Float?) in
cell.textField.rightViewMode = .always return "\(Int(rowValue ?? 1)) (Gwei)"
}
} }
+++ Section( +++ Section(
@ -83,7 +84,7 @@ class ConfigureTransactionViewController: FormViewController {
} }
@objc func save() { @objc func save() {
let gasPrice = EtherNumberFormatter.full.number(from: gasPriceRow?.value ?? "0", units: gasPriceUnit) ?? BigInt() let gasPrice = EtherNumberFormatter.full.number(from: String(Int(gasPriceRow?.value ?? 1)), units: gasPriceUnit) ?? BigInt()
let gasLimit = BigInt(gasLimitRow?.value ?? "0", radix: 10) ?? BigInt() let gasLimit = BigInt(gasLimitRow?.value ?? "0", radix: 10) ?? BigInt()
let totalFee = gasPrice * gasLimit let totalFee = gasPrice * gasLimit

Loading…
Cancel
Save