Skip to content

Commit 4d26d34

Browse files
committed
format
1 parent 6db1270 commit 4d26d34

File tree

7 files changed

+70
-136
lines changed

7 files changed

+70
-136
lines changed

BDKSwiftExampleWallet/Service/BDK Service/BDKService.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ private class BDKService {
170170
amount: amount,
171171
feeRate: feeRate
172172
)
173-
try! signAndBroadcast(psbt: psbt)
174-
print("send sended")
173+
try signAndBroadcast(psbt: psbt)
175174
}
176175

177176
func buildTransaction(address: String, amount: UInt64, feeRate: UInt64) throws

BDKSwiftExampleWallet/View Model/BuildTransactionViewModel.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class BuildTransactionViewModel {
4444
name: Notification.Name("TransactionSent"),
4545
object: nil
4646
)
47-
print("Sent!")
4847
} catch let error as EsploraError {
4948
self.buildTransactionViewError = .generic(message: error.localizedDescription)
5049
self.showingBuildTransactionViewErrorAlert = true

BDKSwiftExampleWallet/View/AddressView.swift

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import SwiftUI
1212
struct AddressView: View {
1313
let amount: String
1414
@State var address: String = ""
15-
// @Binding var rootIsActive: Bool
1615
@Binding var navigationPath: NavigationPath
1716
let pasteboard = UIPasteboard.general
1817
@State private var isShowingScanner = false
@@ -100,34 +99,18 @@ struct AddressView: View {
10099

101100
Spacer()
102101

103-
// NavigationLink(
104-
// destination:
105-
// FeeView(
106-
// amount: amount,
107-
// address: address,
108-
// viewModel: .init(),
109-
// rootIsActive: self.$rootIsActive
110-
// )
111-
// ) {
112-
// Label(
113-
// title: { Text("Next") },
114-
// icon: { Image(systemName: "arrow.right") }
115-
// )
116-
// .labelStyle(.iconOnly)
117-
// }
118-
// .isDetailLink(false)
119-
// .buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
120-
121102
Button {
122-
navigationPath.append(NavigationDestination.fee(amount: amount, address: address))
123-
} label: {
124-
Label(
125-
title: { Text("Next") },
126-
icon: { Image(systemName: "arrow.right") }
127-
)
128-
.labelStyle(.iconOnly)
129-
}
130-
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
103+
navigationPath.append(
104+
NavigationDestination.fee(amount: amount, address: address)
105+
)
106+
} label: {
107+
Label(
108+
title: { Text("Next") },
109+
icon: { Image(systemName: "arrow.right") }
110+
)
111+
.labelStyle(.iconOnly)
112+
}
113+
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
131114

132115
}
133116
.padding()
@@ -164,21 +147,17 @@ extension AddressView {
164147

165148
#if DEBUG
166149
#Preview {
167-
168150
AddressView(
169151
amount: "200",
170152
address: "tb1pw6y0vtmsn46epvz0j8ddc46ketmp28t82p22hcrrkch3a0jhu40qe267dl",
171-
// rootIsActive: .constant(false)
172153
navigationPath: .constant(NavigationPath())
173154
)
174155
}
175156
#Preview {
176157
AddressView(
177158
amount: "200",
178159
address: "tb1pw6y0vtmsn46epvz0j8ddc46ketmp28t82p22hcrrkch3a0jhu40qe267dl",
179-
// rootIsActive: .constant(false)\
180160
navigationPath: .constant(NavigationPath())
181-
182161
)
183162
.environment(\.dynamicTypeSize, .accessibility5)
184163
}

BDKSwiftExampleWallet/View/AmountView.swift

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import SwiftUI
1111
struct AmountView: View {
1212
@Bindable var viewModel: AmountViewModel
1313
@State var numpadAmount = "0"
14-
// @State var isActive: Bool = false
1514
@Binding var navigationPath: NavigationPath
1615

1716
var body: some View {
@@ -61,36 +60,20 @@ struct AmountView: View {
6160
Spacer()
6261

6362
VStack {
64-
65-
// Button {
66-
// isActive = true
67-
// } label: {
68-
// Label(
69-
// title: { Text("Next") },
70-
// icon: { Image(systemName: "arrow.right") }
71-
// )
72-
// .labelStyle(.iconOnly)
73-
// }
74-
// .buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
75-
// NavigationLink(
76-
// destination: AddressView(amount: numpadAmount, rootIsActive: $isActive),
77-
// isActive: $isActive
78-
// ) {
79-
// EmptyView()
80-
// }
81-
// .hidden()
82-
63+
8364
Button {
84-
navigationPath.append(NavigationDestination.address(amount: numpadAmount))
85-
} label: {
86-
Label(
87-
title: { Text("Next") },
88-
icon: { Image(systemName: "arrow.right") }
89-
)
90-
.labelStyle(.iconOnly)
91-
}
92-
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
93-
65+
navigationPath.append(
66+
NavigationDestination.address(amount: numpadAmount)
67+
)
68+
} label: {
69+
Label(
70+
title: { Text("Next") },
71+
icon: { Image(systemName: "arrow.right") }
72+
)
73+
.labelStyle(.iconOnly)
74+
}
75+
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
76+
9477
}
9578

9679
}
@@ -99,11 +82,6 @@ struct AmountView: View {
9982
viewModel.getBalance()
10083
}
10184
}
102-
// .onChange(of: isActive) {
103-
// if !isActive {
104-
// numpadAmount = "0"
105-
// }
106-
// }
10785
.onChange(of: navigationPath) { oldPath, newPath in
10886
if newPath.isEmpty {
10987
numpadAmount = "0"
@@ -165,7 +143,7 @@ struct NumpadButton: View {
165143
#if DEBUG
166144
#Preview {
167145
AmountView(
168-
viewModel: .init(bdkClient: .mock),
146+
viewModel: .init(bdkClient: .mock),
169147
navigationPath: .constant(NavigationPath())
170148
)
171149
}
@@ -176,6 +154,6 @@ struct NumpadButton: View {
176154
navigationPath: .constant(NavigationPath())
177155

178156
)
179-
.environment(\.dynamicTypeSize, .accessibility5)
157+
.environment(\.dynamicTypeSize, .accessibility5)
180158
}
181159
#endif

BDKSwiftExampleWallet/View/BuildTransactionView.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct BuildTransactionView: View {
1616
@Bindable var viewModel: BuildTransactionViewModel
1717
@State var isSent: Bool = false
1818
@State var isError: Bool = false
19-
// @Binding var shouldPopToRootView: Bool
2019
@Binding var navigationPath: NavigationPath
2120
@State private var isCopied = false
2221
@State private var showCheckmark = false
@@ -87,7 +86,6 @@ struct BuildTransactionView: View {
8786
if self.viewModel.buildTransactionViewError == nil {
8887
self.isSent = true
8988
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
90-
// self.shouldPopToRootView = false
9189
self.navigationPath.removeLast(self.navigationPath.count)
9290
}
9391
} else {
@@ -188,9 +186,7 @@ struct BuildTransactionView: View {
188186
viewModel: .init(
189187
bdkClient: .mock
190188
),
191-
// shouldPopToRootView: .constant(false)
192189
navigationPath: .constant(NavigationPath())
193-
194190
)
195191
}
196192

@@ -202,9 +198,7 @@ struct BuildTransactionView: View {
202198
viewModel: .init(
203199
bdkClient: .mock
204200
),
205-
// shouldPopToRootView: .constant(false)
206201
navigationPath: .constant(NavigationPath())
207-
208202
)
209203
.environment(\.dynamicTypeSize, .accessibility5)
210204
}

BDKSwiftExampleWallet/View/FeeView.swift

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct FeeView: View {
1313
let amount: String
1414
let address: String
1515
@Bindable var viewModel: FeeViewModel
16-
// @Binding var rootIsActive: Bool
1716
@Binding var navigationPath: NavigationPath
1817

1918
var body: some View {
@@ -67,35 +66,22 @@ struct FeeView: View {
6766

6867
Spacer()
6968

70-
// NavigationLink(
71-
// destination: BuildTransactionView(
72-
// amount: amount,
73-
// address: address,
74-
// fee: viewModel.selectedFee ?? 1,
75-
// viewModel: .init(),
76-
// shouldPopToRootView: self.$rootIsActive
77-
//
78-
// )
79-
// ) {
80-
// Label(
81-
// title: { Text("Next") },
82-
// icon: { Image(systemName: "arrow.right") }
83-
// )
84-
// .labelStyle(.iconOnly)
85-
// }
86-
// .isDetailLink(false)
87-
// .buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
88-
8969
Button {
90-
navigationPath.append(NavigationDestination.buildTransaction(amount: amount, address: address, fee: viewModel.selectedFee ?? 1))
91-
} label: {
92-
Label(
93-
title: { Text("Next") },
94-
icon: { Image(systemName: "arrow.right") }
95-
)
96-
.labelStyle(.iconOnly)
97-
}
98-
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
70+
navigationPath.append(
71+
NavigationDestination.buildTransaction(
72+
amount: amount,
73+
address: address,
74+
fee: viewModel.selectedFee ?? 1
75+
)
76+
)
77+
} label: {
78+
Label(
79+
title: { Text("Next") },
80+
icon: { Image(systemName: "arrow.right") }
81+
)
82+
.labelStyle(.iconOnly)
83+
}
84+
.buttonStyle(BitcoinOutlined(width: 100, isCapsule: true))
9985

10086
}
10187
.padding()
@@ -125,9 +111,7 @@ struct FeeView: View {
125111
amount: "50",
126112
address: "tb1pxg0lakl0x4jee73f38m334qsma7mn2yv764x9an5ylht6tx8ccdsxtktrt",
127113
viewModel: .init(feeClient: .mock, bdkClient: .mock),
128-
// rootIsActive: .constant(false)
129114
navigationPath: .constant(NavigationPath())
130-
131115
)
132116
}
133117

@@ -136,9 +120,7 @@ struct FeeView: View {
136120
amount: "50",
137121
address: "tb1pxg0lakl0x4jee73f38m334qsma7mn2yv764x9an5ylht6tx8ccdsxtktrt",
138122
viewModel: .init(feeClient: .mock, bdkClient: .mock),
139-
// rootIsActive: .constant(false)
140123
navigationPath: .constant(NavigationPath())
141-
142124
)
143125
.environment(\.dynamicTypeSize, .accessibility5)
144126
}

BDKSwiftExampleWallet/View/TabHomeView.swift

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,35 @@ struct TabHomeView: View {
3030
.tabItem {
3131
Image(systemName: "arrow.down")
3232
}
33-
34-
// AmountView(viewModel: .init())
35-
// .tabItem {
36-
// Image(systemName: "arrow.up")
37-
// }
38-
39-
33+
4034
NavigationStack(path: $sendNavigationPath) {
41-
AmountView(viewModel: .init(), navigationPath: $sendNavigationPath)
42-
.navigationDestination(for: NavigationDestination.self) { destination in
43-
switch destination {
44-
case .address(let amount):
45-
AddressView(amount: amount, navigationPath: $sendNavigationPath)
46-
case .fee(let amount, let address):
47-
FeeView(amount: amount, address: address, viewModel: .init(), navigationPath: $sendNavigationPath)
48-
case .buildTransaction(let amount, let address, let fee):
49-
BuildTransactionView(amount: amount, address: address, fee: fee, viewModel: .init(), navigationPath: $sendNavigationPath)
50-
}
51-
}
52-
}
53-
.tabItem {
54-
Image(systemName: "arrow.up")
55-
}
56-
57-
35+
AmountView(viewModel: .init(), navigationPath: $sendNavigationPath)
36+
.navigationDestination(for: NavigationDestination.self) { destination in
37+
switch destination {
38+
case .address(let amount):
39+
AddressView(amount: amount, navigationPath: $sendNavigationPath)
40+
case .fee(let amount, let address):
41+
FeeView(
42+
amount: amount,
43+
address: address,
44+
viewModel: .init(),
45+
navigationPath: $sendNavigationPath
46+
)
47+
case .buildTransaction(let amount, let address, let fee):
48+
BuildTransactionView(
49+
amount: amount,
50+
address: address,
51+
fee: fee,
52+
viewModel: .init(),
53+
navigationPath: $sendNavigationPath
54+
)
55+
}
56+
}
57+
}
58+
.tabItem {
59+
Image(systemName: "arrow.up")
60+
}
61+
5862
SettingsView(viewModel: .init())
5963
.tabItem {
6064
Image(systemName: "gear")
@@ -86,7 +90,6 @@ enum NavigationDestination: Hashable {
8690
case buildTransaction(amount: String, address: String, fee: Int)
8791
}
8892

89-
9093
#if DEBUG
9194
#Preview {
9295
TabHomeView(viewModel: .init(bdkClient: .mock))

0 commit comments

Comments
 (0)