@@ -14,10 +14,12 @@ struct BitcoinView: View {
1414 @State private var isCopied = false
1515 @State private var showCheckmark = false
1616 @State private var showingBitcoinViewErrorAlert = false
17- @State private var showReceiveViewWithOption : ReceiveOption ?
1817 @State private var showToast = false
1918 @State private var showingNodeIDView = false
2019 @State private var displayBalanceType = DisplayBalanceType . userDefaults
20+ @State private var isReceiveSheetPresented = false
21+ @State private var isSendSheetManualPresented = false
22+ @State private var isSendSheetCameraPresented = false
2123 @StateObject var viewModel : BitcoinViewModel
2224 @StateObject private var eventService = EventService ( )
2325 @Binding var sendNavigationPath : NavigationPath
@@ -28,9 +30,6 @@ struct BitcoinView: View {
2830 BalanceHeader ( displayBalanceType: $displayBalanceType, viewModel: viewModel)
2931 . padding ( . vertical, 40 )
3032
31- TransactionButtons ( viewModel: viewModel)
32- . padding ( . horizontal, 40 )
33-
3433 PaymentsListView (
3534 payments: $viewModel. payments,
3635 displayBalanceType: $displayBalanceType,
@@ -59,13 +58,46 @@ struct BitcoinView: View {
5958 }
6059 }
6160 }
61+
62+ ToolbarItemGroup ( placement: . bottomBar) {
63+ Button {
64+ isSendSheetManualPresented = true
65+ } label: {
66+ Image ( systemName: " arrow.up " )
67+ }
68+ . disabled ( viewModel. unifiedBalance == 0 )
69+
70+ Spacer ( )
71+
72+ Button {
73+ isSendSheetCameraPresented = true
74+ } label: {
75+ Label ( " Scan QR " , systemImage: " qrcode.viewfinder " )
76+ . labelStyle ( . iconOnly)
77+ }
78+ . disabled ( viewModel. unifiedBalance == 0 )
79+
80+ Spacer ( )
81+
82+ Button {
83+ isReceiveSheetPresented = true
84+ } label: {
85+ Image ( systemName: " arrow.down " )
86+ }
87+ . sensoryFeedback ( . increase, trigger: isReceiveSheetPresented)
88+ }
6289 }
6390 . dynamicTypeSize ( ... DynamicTypeSize . accessibility2) // Sets max dynamic size for all Text
6491 . onAppear { viewModel. update ( ) }
6592 . onChange (
6693 of: eventService. lastEvent,
6794 { _, _ in
6895 showToast = eventService. lastEvent != nil
96+ withAnimation {
97+ isReceiveSheetPresented = false
98+ isSendSheetManualPresented = false
99+ isSendSheetCameraPresented = false
100+ }
69101 }
70102 )
71103 . onReceive ( viewModel. $bitcoinViewError) { errorMessage in
@@ -100,12 +132,51 @@ struct BitcoinView: View {
100132 . padding ( . horizontal, 40 )
101133 }
102134 . sheet (
103- item: $showReceiveViewWithOption,
104- onDismiss: { viewModel. update ( ) }
105- ) { receiveOption in
106- ReceiveView (
107- viewModel: . init( lightningClient: viewModel. lightningClient)
135+ isPresented: $isSendSheetManualPresented,
136+ onDismiss: {
137+ Task {
138+ viewModel. update ( )
139+ }
140+ }
141+ ) {
142+ SendView (
143+ viewModel: SendViewModel . init (
144+ lightningClient: viewModel. lightningClient,
145+ sendViewState: . manualEntry,
146+ price: viewModel. price,
147+ balances: viewModel. balances
148+ )
149+ )
150+ . presentationDetents ( [ . large] )
151+ }
152+ . sheet (
153+ isPresented: $isSendSheetCameraPresented,
154+ onDismiss: {
155+ Task {
156+ viewModel. update ( )
157+ }
158+ }
159+ ) {
160+ SendView (
161+ viewModel: SendViewModel . init (
162+ lightningClient: viewModel. lightningClient,
163+ sendViewState: . scanAddress,
164+ price: viewModel. price,
165+ balances: viewModel. balances
166+ )
108167 )
168+ . presentationDetents ( [ . large] )
169+ }
170+ . sheet (
171+ isPresented: $isReceiveSheetPresented,
172+ onDismiss: {
173+ Task {
174+ viewModel. update ( )
175+ }
176+ }
177+ ) {
178+ ReceiveView ( viewModel: . init( lightningClient: viewModel. lightningClient) )
179+ . presentationDetents ( [ . large] )
109180 }
110181 }
111182
@@ -197,119 +268,6 @@ struct BalanceHeader: View {
197268 }
198269}
199270
200- struct TransactionButtons : View {
201- @ObservedObject var viewModel : BitcoinViewModel
202- @State private var isReceiveSheetPresented = false
203- @State private var isSendSheetManualPresented = false
204- @State private var isSendSheetCameraPresented = false
205- @StateObject private var eventService = EventService ( )
206-
207- var body : some View {
208- HStack ( alignment: . center) {
209-
210- // Send button
211- Button {
212- isSendSheetManualPresented = true
213- } label: {
214- Text ( " Send " )
215- } . buttonStyle (
216- BitcoinFilled (
217- width: 120 ,
218- tintColor: . accent,
219- isCapsule: true
220- )
221- ) . disabled ( viewModel. unifiedBalance == 0 )
222-
223- Spacer ( )
224-
225- // Scan QR button
226- Button {
227- isSendSheetCameraPresented = true
228- } label: {
229- Label ( " Scan QR " , systemImage: " qrcode.viewfinder " )
230- . font ( . title)
231- . frame ( height: 60 , alignment: . center)
232- . labelStyle ( . iconOnly)
233- . foregroundColor ( . accentColor)
234- . padding ( )
235- } . disabled ( viewModel. unifiedBalance == 0 )
236-
237- Spacer ( )
238-
239- // Receive button
240- Button ( " Receive " ) {
241- isReceiveSheetPresented = true
242- }
243- . sensoryFeedback ( . increase, trigger: isReceiveSheetPresented)
244- . buttonStyle (
245- BitcoinFilled (
246- width: 120 ,
247- tintColor: . accent,
248- isCapsule: true
249- )
250- )
251- . sheet (
252- isPresented: $isSendSheetManualPresented,
253- onDismiss: {
254- Task {
255- viewModel. update ( )
256- }
257- }
258- ) {
259- SendView (
260- viewModel: SendViewModel . init (
261- lightningClient: viewModel. lightningClient,
262- sendViewState: . manualEntry,
263- price: viewModel. price,
264- balances: viewModel. balances
265- )
266- )
267- . presentationDetents ( [ . large] )
268- }
269- . sheet (
270- isPresented: $isSendSheetCameraPresented,
271- onDismiss: {
272- Task {
273- viewModel. update ( )
274- }
275- }
276- ) {
277- SendView (
278- viewModel: SendViewModel . init (
279- lightningClient: viewModel. lightningClient,
280- sendViewState: . scanAddress,
281- price: viewModel. price,
282- balances: viewModel. balances
283- )
284- )
285- . presentationDetents ( [ . large] )
286- }
287- . sheet (
288- isPresented: $isReceiveSheetPresented,
289- onDismiss: {
290- Task {
291- viewModel. update ( )
292- }
293- }
294- ) {
295- ReceiveView ( viewModel: . init( lightningClient: viewModel. lightningClient) )
296- . presentationDetents ( [ . large] )
297- }
298-
299- } . onChange (
300- of: eventService. lastEvent,
301- { _, _ in
302- withAnimation {
303- isReceiveSheetPresented = false
304- isSendSheetManualPresented = false
305- isSendSheetCameraPresented = false
306- }
307- }
308- )
309- }
310-
311- }
312-
313271public enum DisplayBalanceType : String {
314272 case fiatSats
315273 case fiatBtc
0 commit comments