Skip to content

Commit d448ee2

Browse files
authored
feat: transaction item dynamic type
1 parent 946479a commit d448ee2

File tree

1 file changed

+52
-60
lines changed

1 file changed

+52
-60
lines changed

BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift

Lines changed: 52 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -30,50 +30,50 @@ struct TransactionItemView: View {
3030

3131
var body: some View {
3232

33-
HStack(spacing: 15) {
33+
VStack(alignment: .leading, spacing: 20) {
3434

35-
if isRedacted {
36-
Image(
37-
systemName:
38-
"circle.fill"
39-
)
40-
.font(.largeTitle)
41-
.symbolRenderingMode(.palette)
42-
.foregroundStyle(
43-
Color.gray.opacity(0.5)
44-
)
45-
} else {
46-
ZStack {
47-
Image(systemName: "circle.fill")
48-
.font(.largeTitle)
49-
.foregroundStyle(Color.gray.opacity(0.25))
35+
let delta = txDetails.balanceDelta
36+
let prefix = (delta >= 0 ? "+ " : "- ").appending("\(format.displayPrefix) ")
37+
let amount = format.formatted(UInt64(abs(delta)), fiatPrice: fiatPrice)
38+
let suffix = format.displayText
39+
40+
Text("\(prefix)\(amount) \(suffix)")
41+
.font(.title)
42+
.fontWeight(.semibold)
43+
.fontDesign(.rounded)
44+
.lineLimit(1)
45+
.redacted(reason: isRedacted ? .placeholder : [])
46+
47+
HStack {
48+
if isRedacted {
5049
Image(
5150
systemName:
52-
txDetails.balanceDelta >= 0
53-
? "arrow.down" : "arrow.up"
51+
"circle.fill"
5452
)
55-
.font(.callout)
53+
.symbolRenderingMode(.palette)
5654
.foregroundStyle(
57-
{
58-
switch txDetails.chainPosition {
59-
case .confirmed(_, _):
60-
Color.bitcoinOrange
61-
case .unconfirmed(_):
62-
Color.gray.opacity(0.5)
63-
}
64-
}()
55+
Color.gray.opacity(0.5)
6556
)
57+
} else {
58+
ZStack {
59+
Image(
60+
systemName:
61+
txDetails.balanceDelta >= 0
62+
? "arrow.down" : "arrow.up"
63+
)
64+
.foregroundStyle(
65+
{
66+
switch txDetails.chainPosition {
67+
case .confirmed(_, _):
68+
Color.bitcoinOrange
69+
case .unconfirmed(_):
70+
Color.gray.opacity(0.5)
71+
}
72+
}()
73+
)
74+
}
6675
}
67-
}
6876

69-
VStack(alignment: .leading, spacing: 5) {
70-
Text(txDetails.txid.description)
71-
.truncationMode(.middle)
72-
.lineLimit(1)
73-
.fontDesign(.monospaced)
74-
.fontWeight(.semibold)
75-
.font(.title)
76-
.foregroundStyle(.primary)
7777
switch txDetails.chainPosition {
7878
case .confirmed(let confirmationBlockTime, _):
7979
Text(
@@ -83,8 +83,7 @@ struct TransactionItemView: View {
8383
)
8484
)
8585
.lineLimit(dynamicTypeSize.isAccessibilitySize ? 2 : 1)
86-
.font(.caption2)
87-
.fontWidth(.condensed)
86+
.redacted(reason: isRedacted ? .placeholder : [])
8887
case .unconfirmed(let timestamp):
8988
if let timestamp {
9089
Text(
@@ -94,38 +93,31 @@ struct TransactionItemView: View {
9493
)
9594
)
9695
.lineLimit(dynamicTypeSize.isAccessibilitySize ? 2 : 1)
97-
.font(.caption2)
98-
.fontWidth(.condensed)
96+
.redacted(reason: isRedacted ? .placeholder : [])
9997
} else {
10098
Text("Pending")
10199
.lineLimit(dynamicTypeSize.isAccessibilitySize ? 2 : 1)
102-
.font(.caption2)
103-
.fontWidth(.condensed)
100+
.redacted(reason: isRedacted ? .placeholder : [])
104101
}
105102
}
103+
106104
}
107105
.foregroundStyle(.secondary)
108-
.font(.subheadline)
109-
.padding(.trailing, 30.0)
110-
.redacted(reason: isRedacted ? .placeholder : [])
111-
112-
Spacer()
106+
.font(.callout)
113107

114-
let delta = txDetails.balanceDelta
115-
let prefix = (delta >= 0 ? "+ " : "- ").appending("\(format.displayPrefix) ")
116-
let amount = format.formatted(UInt64(abs(delta)), fiatPrice: fiatPrice)
117-
let suffix = format.displayText
118-
119-
Text("\(prefix)\(amount) \(suffix)")
120-
.font(.subheadline)
121-
.fontWeight(.semibold)
122-
.fontDesign(.rounded)
123-
.lineLimit(1)
124-
.redacted(reason: isRedacted ? .placeholder : [])
108+
HStack {
109+
Text(txDetails.txid.description)
110+
.truncationMode(.middle)
111+
.lineLimit(1)
112+
.fontDesign(.monospaced)
113+
.font(.callout)
114+
.foregroundStyle(.primary)
115+
Spacer(minLength: 80)
116+
}
117+
.redacted(reason: isRedacted ? .placeholder : [])
125118

126119
}
127-
.padding(.vertical, 15.0)
128-
.padding(.vertical, 5.0)
120+
.padding(.vertical)
129121
.minimumScaleFactor(0.5)
130122

131123
}

0 commit comments

Comments
 (0)