Skip to content

Commit

Permalink
Fixes issue #152 - Failed outgoing payments should display amount in …
Browse files Browse the repository at this point in the history
…HomeView
  • Loading branch information
robbiehanson committed Apr 13, 2021
1 parent 27f8713 commit df25601
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions phoenix-ios/phoenix-ios/views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ struct HomeView : MVIView, ViewName {
if msatTotal > 0 {
return Utils.format(currencyPrefs, msat: msatTotal)
} else {
return Utils.format(currencyPrefs, sat: 100_000)
return nil
}
}
Expand Down Expand Up @@ -332,23 +331,25 @@ struct PaymentCell : View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding([.leading, .trailing], 6)

if payment.state() != .failure {
HStack(alignment: VerticalAlignment.firstTextBaseline, spacing: 0) {

let amount = Utils.format(currencyPrefs, msat: payment.amountMsat())
let isNegative = payment.amountMsat() < 0

Text(isNegative ? "" : "+")
.foregroundColor(isNegative ? .appNegative : .appPositive)
.padding(.trailing, 1)
HStack(alignment: VerticalAlignment.firstTextBaseline, spacing: 0) {

let amount = Utils.format(currencyPrefs, msat: payment.amountMsat())

let isFailure = payment.state() == WalletPaymentState.failure
let isNegative = payment.amountMsat() < 0

let color: Color = isFailure ? .secondary : (isNegative ? .appNegative : .appPositive)

Text(isNegative ? "" : "+")
.foregroundColor(color)
.padding(.trailing, 1)

Text(amount.digits)
.foregroundColor(color)

Text(amount.digits)
.foregroundColor(isNegative ? .appNegative : .appPositive)

Text(" " + amount.type)
.font(.caption)
.foregroundColor(.gray)
}
Text(" " + amount.type)
.font(.caption)
.foregroundColor(.gray)
}
}
.padding([.top, .bottom], 14)
Expand Down

0 comments on commit df25601

Please sign in to comment.