Show available balance, not actual balance.
This commit is contained in:
parent
7d3353b3b0
commit
5b450a5ccb
@ -514,7 +514,11 @@ public class SendPaymentCompletionActionSheet: ActionSheetController {
|
||||
|
||||
@objc
|
||||
public func updateBalanceLabel() {
|
||||
SendPaymentHelper.updateBalanceLabel(balanceLabel)
|
||||
guard let helper = helper else {
|
||||
Logger.verbose("Missing helper.")
|
||||
return
|
||||
}
|
||||
helper.updateBalanceLabel(balanceLabel)
|
||||
}
|
||||
|
||||
private func tryToSendPayment(paymentInfo: PaymentInfo) {
|
||||
|
||||
@ -65,12 +65,15 @@ class SendPaymentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private var maximumPaymentAmount: TSPaymentAmount?
|
||||
|
||||
required init(delegate: SendPaymentHelperDelegate) {
|
||||
self.delegate = delegate
|
||||
|
||||
addObservers()
|
||||
|
||||
updateCurrentCurrencyConversion()
|
||||
updateMaximumPaymentAmount()
|
||||
}
|
||||
|
||||
private func addObservers() {
|
||||
@ -144,9 +147,9 @@ class SendPaymentHelper {
|
||||
return label
|
||||
}
|
||||
|
||||
public static func updateBalanceLabel(_ balanceLabel: UILabel) {
|
||||
public func updateBalanceLabel(_ balanceLabel: UILabel) {
|
||||
|
||||
guard let paymentBalance = Self.paymentsSwift.currentPaymentBalance else {
|
||||
guard let maximumPaymentAmount = self.maximumPaymentAmount else {
|
||||
// Use whitespace to ensure that the height of the label
|
||||
// is constant, avoiding layout jitter.
|
||||
balanceLabel.text = " "
|
||||
@ -156,12 +159,28 @@ class SendPaymentHelper {
|
||||
let format = NSLocalizedString("PAYMENTS_NEW_PAYMENT_BALANCE_FORMAT",
|
||||
comment: "Format for the 'balance' indicator. Embeds {{ the current payments balance }}.")
|
||||
balanceLabel.text = String(format: format,
|
||||
Self.formatMobileCoinAmount(paymentBalance.amount))
|
||||
Self.formatMobileCoinAmount(maximumPaymentAmount))
|
||||
}
|
||||
|
||||
private func updateMaximumPaymentAmount() {
|
||||
firstly {
|
||||
Self.paymentsSwift.maximumPaymentAmount()
|
||||
}.done(on: .main) { [weak self] maximumPaymentAmount in
|
||||
guard let self = self else { return }
|
||||
self.maximumPaymentAmount = maximumPaymentAmount
|
||||
self.delegate?.balanceDidChange()
|
||||
}.catch(on: .global()) { error in
|
||||
owsFailDebugUnlessNetworkFailure(error)
|
||||
}
|
||||
|
||||
delegate?.balanceDidChange()
|
||||
}
|
||||
|
||||
@objc
|
||||
private func currentPaymentBalanceDidChange() {
|
||||
delegate?.balanceDidChange()
|
||||
|
||||
updateMaximumPaymentAmount()
|
||||
}
|
||||
|
||||
@objc
|
||||
|
||||
@ -673,7 +673,11 @@ public class SendPaymentViewController: OWSViewController {
|
||||
}
|
||||
|
||||
private func updateBalanceLabel() {
|
||||
SendPaymentHelper.updateBalanceLabel(balanceLabel)
|
||||
guard let helper = helper else {
|
||||
Logger.verbose("Missing helper.")
|
||||
return
|
||||
}
|
||||
helper.updateBalanceLabel(balanceLabel)
|
||||
}
|
||||
|
||||
private func showInvalidAmountAlert() {
|
||||
|
||||
@ -3392,7 +3392,7 @@
|
||||
"PAYMENTS_NEW_PAYMENT_ADD_MEMO" = "Add Note";
|
||||
|
||||
/* Format for the 'balance' indicator. Embeds {{ the current payments balance }}. */
|
||||
"PAYMENTS_NEW_PAYMENT_BALANCE_FORMAT" = "Balance: %@";
|
||||
"PAYMENTS_NEW_PAYMENT_BALANCE_FORMAT" = "Available Balance: %@";
|
||||
|
||||
/* Label for the 'confirm payment' button. */
|
||||
"PAYMENTS_NEW_PAYMENT_CONFIRM_PAYMENT_BUTTON" = "Confirm Payment";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user