Skip to content

Commit d3dcbfe

Browse files
authored
ui: transaction details
1 parent fa1fc63 commit d3dcbfe

3 files changed

Lines changed: 61 additions & 25 deletions

File tree

LDKNodeMonday/View/Home/Payments/PaymentDetailView.swift

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,100 @@ import SwiftUI
1010

1111
struct PaymentDetailView: View {
1212
let payment: PaymentDetails
13+
let displayBalanceType: DisplayBalanceType
14+
let price: Double
1315
@Environment(\.dismiss) var dismiss
1416

1517
var body: some View {
1618
VStack(alignment: .leading, spacing: 0) {
1719

18-
VStack(alignment: .leading, spacing: 12) {
19-
20-
HStack {
21-
Spacer()
22-
Image(
23-
systemName: payment.isChainPayment
24-
? "bitcoinsign.circle" : "bolt.circle"
25-
)
26-
.foregroundColor(.primary)
27-
.font(.largeTitle)
28-
Spacer()
29-
}
20+
Text("Transaction Detail").bold()
3021
.padding()
22+
.padding(.bottom, 20)
23+
24+
VStack(alignment: .leading, spacing: 12) {
3125

3226
Group {
33-
if let amountMsat = payment.amountMsat {
27+
if let amountMsat = payment.amountMsat, amountMsat > 0 {
3428
Divider()
3529
DetailRowView(
3630
label: "Amount",
37-
value: "\(amountMsat.mSatsAsSats.formatted()) sats"
31+
primaryValue: payment.primaryAmount(
32+
displayBalanceType: displayBalanceType,
33+
price: price
34+
),
35+
secondaryValue: payment.secondaryAmount(
36+
displayBalanceType: displayBalanceType,
37+
price: price
38+
),
39+
primaryColor: payment.amountColor,
40+
secondaryColor: payment.secondaryAmountColor
3841
)
3942
}
4043
Divider()
4144
DetailRowView(label: "Status", value: payment.title)
4245
Divider()
43-
DetailRowView(label: "Payment Type", value: payment.paymentKindString)
46+
DetailRowView(
47+
label: "Payment Type",
48+
value: payment.paymentKindString,
49+
systemImageName: payment.isChainPayment
50+
? "bitcoinsign.circle" : "bolt.circle"
51+
)
4452
Divider()
4553
DetailRowView(label: "Date", value: payment.formattedDate)
4654
}
4755
.padding(.horizontal)
4856
.padding(.vertical, 4)
4957

5058
}
51-
.padding(.top)
5259

5360
}
5461
}
5562
}
5663

5764
struct DetailRowView: View {
5865
let label: String
59-
let value: String
66+
var value: String? = nil
67+
var systemImageName: String? = nil
68+
var primaryValue: String? = nil
69+
var secondaryValue: String? = nil
70+
var primaryColor: Color? = .primary
71+
var secondaryColor: Color? = .secondary
6072

6173
var body: some View {
6274
HStack {
6375
Text(label)
64-
.foregroundColor(.secondary)
65-
Spacer()
66-
Text(value)
6776
.foregroundColor(.primary)
77+
Spacer()
78+
if let systemImageName = systemImageName, let value = value {
79+
Image(systemName: systemImageName)
80+
.foregroundColor(.secondary)
81+
Text(value)
82+
.foregroundColor(.secondary)
83+
} else if let primaryValue = primaryValue, let secondaryValue = secondaryValue {
84+
VStack(alignment: .trailing) {
85+
Text(primaryValue)
86+
.foregroundColor(primaryColor)
87+
Text(secondaryValue)
88+
.font(.caption)
89+
.foregroundColor(secondaryColor)
90+
}
91+
} else if let value = value {
92+
Text(value)
93+
.foregroundColor(.secondary)
94+
}
6895
}
6996
}
7097
}
7198

7299
#if DEBUG
73100
struct PaymentDetailView_Previews: PreviewProvider {
74101
static var previews: some View {
75-
PaymentDetailView(payment: mockPayments.first!)
102+
PaymentDetailView(
103+
payment: mockPayments.first!,
104+
displayBalanceType: .fiatSats,
105+
price: 70000.0
106+
)
76107
}
77108
}
78109
#endif

LDKNodeMonday/View/Home/Payments/PaymentsListView.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ struct PaymentsListView: View {
8585
.listStyle(.plain)
8686
.padding(.horizontal)
8787
.sheet(item: $selectedPayment) { paymentDetail in
88-
PaymentDetailView(payment: paymentDetail)
89-
.presentationDetents([.medium])
90-
.presentationDragIndicator(.hidden)
88+
PaymentDetailView(
89+
payment: paymentDetail,
90+
displayBalanceType: displayBalanceType,
91+
price: price
92+
)
93+
.presentationDetents([.medium])
94+
.presentationDragIndicator(.hidden)
9195
}
9296
}
9397
}

LDKNodeMonday/View/Home/Send/SendManualEntry.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ struct SendManualEntry: View {
6464
viewModel.address.extractPaymentInfo()
6565

6666
if extractedPaymentAddress != nil && viewModel.paymentAddress == nil {
67-
viewModel.amountSat = extractedAmount != 0 ? extractedAmount : viewModel.amountSat
67+
viewModel.amountSat =
68+
extractedAmount != 0 ? extractedAmount : viewModel.amountSat
6869
viewModel.paymentAddress = extractedPaymentAddress
6970

7071
if extractedAmount != 0 {

0 commit comments

Comments
 (0)