Skip to content

Commit d0b2cbe

Browse files
committed
feat: wallet view scrollview
1 parent d262164 commit d0b2cbe

File tree

3 files changed

+65
-60
lines changed

3 files changed

+65
-60
lines changed

BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct TransactionItemView: View {
3838
let suffix = format.displayText
3939

4040
Text("\(prefix)\(amount) \(suffix)")
41-
.font(.title)
41+
.font(.title3)
4242
.fontWeight(.semibold)
4343
.fontDesign(.rounded)
4444
.lineLimit(1)
@@ -103,7 +103,7 @@ struct TransactionItemView: View {
103103

104104
}
105105
.foregroundStyle(.secondary)
106-
.font(.callout)
106+
.font(.caption)
107107

108108
// HStack {
109109
// Text(txDetails.txid.description)

BDKSwiftExampleWallet/View/Activity/TransactionListView.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ struct TransactionListView: View {
3232

3333
var body: some View {
3434

35-
List {
35+
LazyVStack(alignment: .leading) {
3636
if transactions.isEmpty && walletSyncState == .syncing {
3737
TransactionItemView(
3838
txDetails: .mock,
3939
isRedacted: true,
4040
format: format,
4141
fiatPrice: fiatPrice
4242
)
43-
.listRowInsets(EdgeInsets())
44-
.listRowSeparator(.hidden)
4543
} else if transactions.isEmpty {
4644

4745
VStack(alignment: .leading) {
@@ -94,8 +92,6 @@ struct TransactionListView: View {
9492
}
9593

9694
}
97-
.listRowInsets(EdgeInsets())
98-
.listRowSeparator(.hidden)
9995

10096
} else {
10197

@@ -122,6 +118,14 @@ struct TransactionListView: View {
122118
format: format,
123119
fiatPrice: fiatPrice
124120
)
121+
.frame(maxWidth: .infinity, alignment: .leading)
122+
.overlay(alignment: .trailing) {
123+
Image(systemName: "chevron.right")
124+
.font(.footnote.weight(.semibold))
125+
.foregroundStyle(.tertiary)
126+
.padding(.leading, 8)
127+
}
128+
.padding(.trailing, 4)
125129
}
126130

127131
} else {
@@ -134,14 +138,11 @@ struct TransactionListView: View {
134138
}
135139

136140
}
137-
.listRowInsets(EdgeInsets())
138-
.listRowSeparator(.hidden)
139-
.listRowBackground(Color.clear)
140141

141142
}
142143

143144
}
144-
.listStyle(.plain)
145+
.frame(maxWidth: .infinity, alignment: .leading)
145146
.alert(isPresented: $viewModel.showingWalletTransactionsViewErrorAlert) {
146147
Alert(
147148
title: Text("Wallet Transaction Error"),

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,64 +27,68 @@ struct WalletView: View {
2727
Color(uiColor: .systemBackground)
2828
.ignoresSafeArea()
2929

30-
VStack(spacing: 20) {
30+
ScrollView {
31+
VStack(spacing: 20) {
3132

32-
BalanceView(
33-
format: balanceFormat,
34-
balance: viewModel.balanceTotal,
35-
fiatPrice: viewModel.price
36-
).onTapGesture {
37-
withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) {
38-
balanceFormat =
39-
BalanceDisplayFormat.allCases[
40-
(balanceFormat.index + 1) % BalanceDisplayFormat.allCases.count
41-
]
42-
}
43-
}
44-
45-
VStack {
46-
ActivityHomeHeaderView(
47-
walletSyncState: viewModel.walletSyncState,
48-
progress: viewModel.progress,
49-
inspectedScripts: viewModel.inspectedScripts,
50-
totalScripts: viewModel.totalScripts,
51-
needsFullScan: viewModel.needsFullScan,
52-
isKyotoClient: viewModel.isKyotoClient,
53-
isKyotoConnected: viewModel.isKyotoConnected,
54-
currentBlockHeight: viewModel.currentBlockHeight
55-
) {
56-
showAllTransactions = true
33+
BalanceView(
34+
format: balanceFormat,
35+
balance: viewModel.balanceTotal,
36+
fiatPrice: viewModel.price
37+
).onTapGesture {
38+
withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) {
39+
balanceFormat =
40+
BalanceDisplayFormat.allCases[
41+
(balanceFormat.index + 1)
42+
% BalanceDisplayFormat
43+
.allCases.count
44+
]
45+
}
5746
}
5847

59-
if shouldShowKyotoInitialSyncNotice {
60-
KyotoInitialSyncNoticeView(isConnected: viewModel.isKyotoConnected)
61-
.transition(.opacity)
62-
}
48+
VStack {
49+
ActivityHomeHeaderView(
50+
walletSyncState: viewModel.walletSyncState,
51+
progress: viewModel.progress,
52+
inspectedScripts: viewModel.inspectedScripts,
53+
totalScripts: viewModel.totalScripts,
54+
needsFullScan: viewModel.needsFullScan,
55+
isKyotoClient: viewModel.isKyotoClient,
56+
isKyotoConnected: viewModel.isKyotoConnected,
57+
currentBlockHeight: viewModel.currentBlockHeight
58+
) {
59+
showAllTransactions = true
60+
}
6361

64-
TransactionListView(
65-
viewModel: .init(),
66-
transactions: viewModel.recentTransactions,
67-
walletSyncState: viewModel.walletSyncState,
68-
format: balanceFormat,
69-
fiatPrice: viewModel.price
70-
)
71-
.refreshable {
72-
if viewModel.isKyotoClient {
73-
viewModel.getBalance()
74-
viewModel.getTransactions()
75-
await viewModel.getPrices()
76-
} else {
77-
await viewModel.syncOrFullScan()
78-
viewModel.getBalance()
79-
viewModel.getTransactions()
80-
await viewModel.getPrices()
62+
if shouldShowKyotoInitialSyncNotice {
63+
KyotoInitialSyncNoticeView(isConnected: viewModel.isKyotoConnected)
64+
.transition(.opacity)
8165
}
66+
67+
TransactionListView(
68+
viewModel: .init(),
69+
transactions: viewModel.recentTransactions,
70+
walletSyncState: viewModel.walletSyncState,
71+
format: balanceFormat,
72+
fiatPrice: viewModel.price
73+
)
74+
8275
}
8376

8477
}
85-
78+
.padding()
79+
}
80+
.refreshable {
81+
if viewModel.isKyotoClient {
82+
viewModel.getBalance()
83+
viewModel.getTransactions()
84+
await viewModel.getPrices()
85+
} else {
86+
await viewModel.syncOrFullScan()
87+
viewModel.getBalance()
88+
viewModel.getTransactions()
89+
await viewModel.getPrices()
90+
}
8691
}
87-
.padding()
8892
.onReceive(
8993
NotificationCenter.default.publisher(for: Notification.Name("TransactionSent")),
9094
perform: { _ in

0 commit comments

Comments
 (0)