@@ -10,69 +10,100 @@ import SwiftUI
1010
1111struct 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
5764struct 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
0 commit comments