Skip to content

Commit d289867

Browse files
authored
ui: send moved from tabview to main view
1 parent db4a2ae commit d289867

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

BDKSwiftExampleWallet/View/TabHomeView.swift

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import SwiftUI
99

1010
struct TabHomeView: View {
1111
@Bindable var viewModel: TabHomeViewModel
12-
@State private var sendNavigationPath = NavigationPath()
1312

1413
var body: some View {
1514

@@ -27,34 +26,6 @@ struct TabHomeView: View {
2726
Image(systemName: "bitcoinsign")
2827
}
2928

30-
NavigationStack(path: $sendNavigationPath) {
31-
AmountView(viewModel: .init(), navigationPath: $sendNavigationPath)
32-
.navigationDestination(for: NavigationDestination.self) { destination in
33-
switch destination {
34-
case .address(let amount):
35-
AddressView(amount: amount, navigationPath: $sendNavigationPath)
36-
case .fee(let amount, let address):
37-
FeeView(
38-
amount: amount,
39-
address: address,
40-
viewModel: .init(),
41-
navigationPath: $sendNavigationPath
42-
)
43-
case .buildTransaction(let amount, let address, let fee):
44-
BuildTransactionView(
45-
amount: amount,
46-
address: address,
47-
fee: fee,
48-
viewModel: .init(),
49-
navigationPath: $sendNavigationPath
50-
)
51-
}
52-
}
53-
}
54-
.tabItem {
55-
Image(systemName: "arrow.up")
56-
}
57-
5829
SettingsView(viewModel: .init())
5930
.tabItem {
6031
Image(systemName: "gear")
@@ -81,6 +52,7 @@ struct TabHomeView: View {
8152
}
8253

8354
enum NavigationDestination: Hashable {
55+
case amount
8456
case address(amount: String)
8557
case fee(amount: String, address: String)
8658
case buildTransaction(amount: String, address: String, fee: Int)

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ struct WalletView: View {
1616
@State private var newTransactionSent = false
1717
@State private var showAllTransactions = false
1818
@State private var showReceiveView = false
19+
@State private var sendNavigationPath = NavigationPath()
1920

2021
var body: some View {
2122

22-
NavigationStack {
23+
NavigationStack(path: $sendNavigationPath) {
2324

2425
ZStack {
2526
Color(uiColor: .systemBackground)
@@ -196,6 +197,29 @@ struct WalletView: View {
196197
.navigationDestination(isPresented: $showAllTransactions) {
197198
ActivityListView(viewModel: .init())
198199
}
200+
.navigationDestination(for: NavigationDestination.self) { destination in
201+
switch destination {
202+
case .amount:
203+
AmountView(viewModel: .init(), navigationPath: $sendNavigationPath)
204+
case .address(let amount):
205+
AddressView(amount: amount, navigationPath: $sendNavigationPath)
206+
case .fee(let amount, let address):
207+
FeeView(
208+
amount: amount,
209+
address: address,
210+
viewModel: .init(),
211+
navigationPath: $sendNavigationPath
212+
)
213+
case .buildTransaction(let amount, let address, let fee):
214+
BuildTransactionView(
215+
amount: amount,
216+
address: address,
217+
fee: fee,
218+
viewModel: .init(),
219+
navigationPath: $sendNavigationPath
220+
)
221+
}
222+
}
199223
.toolbar {
200224
ToolbarItem(placement: .navigationBarLeading) {
201225
Button(action: {
@@ -210,6 +234,13 @@ struct WalletView: View {
210234
.foregroundColor(.clear)
211235
}
212236
}
237+
ToolbarItem(placement: .navigationBarTrailing) {
238+
Button(action: {
239+
sendNavigationPath.append(NavigationDestination.amount)
240+
}) {
241+
Image(systemName: "qrcode.viewfinder")
242+
}
243+
}
213244
}
214245

215246
}

0 commit comments

Comments
 (0)