From 013ee6679de5e814388926f736e9818d1160f386 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 2 Oct 2025 11:30:18 -0500 Subject: [PATCH] ui: buttons bitcoinview --- LDKNodeMonday/View/Home/BitcoinView.swift | 202 +++++++++------------- 1 file changed, 80 insertions(+), 122 deletions(-) diff --git a/LDKNodeMonday/View/Home/BitcoinView.swift b/LDKNodeMonday/View/Home/BitcoinView.swift index 234b5d3..a762b82 100644 --- a/LDKNodeMonday/View/Home/BitcoinView.swift +++ b/LDKNodeMonday/View/Home/BitcoinView.swift @@ -14,10 +14,12 @@ struct BitcoinView: View { @State private var isCopied = false @State private var showCheckmark = false @State private var showingBitcoinViewErrorAlert = false - @State private var showReceiveViewWithOption: ReceiveOption? @State private var showToast = false @State private var showingNodeIDView = false @State private var displayBalanceType = DisplayBalanceType.userDefaults + @State private var isReceiveSheetPresented = false + @State private var isSendSheetManualPresented = false + @State private var isSendSheetCameraPresented = false @StateObject var viewModel: BitcoinViewModel @StateObject private var eventService = EventService() @Binding var sendNavigationPath: NavigationPath @@ -28,9 +30,6 @@ struct BitcoinView: View { BalanceHeader(displayBalanceType: $displayBalanceType, viewModel: viewModel) .padding(.vertical, 40) - TransactionButtons(viewModel: viewModel) - .padding(.horizontal, 40) - PaymentsListView( payments: $viewModel.payments, displayBalanceType: $displayBalanceType, @@ -59,6 +58,34 @@ struct BitcoinView: View { } } } + + ToolbarItemGroup(placement: .bottomBar) { + Button { + isSendSheetManualPresented = true + } label: { + Image(systemName: "arrow.up") + } + .disabled(viewModel.unifiedBalance == 0) + + Spacer() + + Button { + isSendSheetCameraPresented = true + } label: { + Label("Scan QR", systemImage: "qrcode.viewfinder") + .labelStyle(.iconOnly) + } + .disabled(viewModel.unifiedBalance == 0) + + Spacer() + + Button { + isReceiveSheetPresented = true + } label: { + Image(systemName: "arrow.down") + } + .sensoryFeedback(.increase, trigger: isReceiveSheetPresented) + } } .dynamicTypeSize(...DynamicTypeSize.accessibility2) // Sets max dynamic size for all Text .onAppear { viewModel.update() } @@ -66,6 +93,11 @@ struct BitcoinView: View { of: eventService.lastEvent, { _, _ in showToast = eventService.lastEvent != nil + withAnimation { + isReceiveSheetPresented = false + isSendSheetManualPresented = false + isSendSheetCameraPresented = false + } } ) .onReceive(viewModel.$bitcoinViewError) { errorMessage in @@ -100,12 +132,51 @@ struct BitcoinView: View { .padding(.horizontal, 40) } .sheet( - item: $showReceiveViewWithOption, - onDismiss: { viewModel.update() } - ) { receiveOption in - ReceiveView( - viewModel: .init(lightningClient: viewModel.lightningClient) + isPresented: $isSendSheetManualPresented, + onDismiss: { + Task { + viewModel.update() + } + } + ) { + SendView( + viewModel: SendViewModel.init( + lightningClient: viewModel.lightningClient, + sendViewState: .manualEntry, + price: viewModel.price, + balances: viewModel.balances + ) + ) + .presentationDetents([.large]) + } + .sheet( + isPresented: $isSendSheetCameraPresented, + onDismiss: { + Task { + viewModel.update() + } + } + ) { + SendView( + viewModel: SendViewModel.init( + lightningClient: viewModel.lightningClient, + sendViewState: .scanAddress, + price: viewModel.price, + balances: viewModel.balances + ) ) + .presentationDetents([.large]) + } + .sheet( + isPresented: $isReceiveSheetPresented, + onDismiss: { + Task { + viewModel.update() + } + } + ) { + ReceiveView(viewModel: .init(lightningClient: viewModel.lightningClient)) + .presentationDetents([.large]) } } @@ -197,119 +268,6 @@ struct BalanceHeader: View { } } -struct TransactionButtons: View { - @ObservedObject var viewModel: BitcoinViewModel - @State private var isReceiveSheetPresented = false - @State private var isSendSheetManualPresented = false - @State private var isSendSheetCameraPresented = false - @StateObject private var eventService = EventService() - - var body: some View { - HStack(alignment: .center) { - - // Send button - Button { - isSendSheetManualPresented = true - } label: { - Text("Send") - }.buttonStyle( - BitcoinFilled( - width: 120, - tintColor: .accent, - isCapsule: true - ) - ).disabled(viewModel.unifiedBalance == 0) - - Spacer() - - // Scan QR button - Button { - isSendSheetCameraPresented = true - } label: { - Label("Scan QR", systemImage: "qrcode.viewfinder") - .font(.title) - .frame(height: 60, alignment: .center) - .labelStyle(.iconOnly) - .foregroundColor(.accentColor) - .padding() - }.disabled(viewModel.unifiedBalance == 0) - - Spacer() - - // Receive button - Button("Receive") { - isReceiveSheetPresented = true - } - .sensoryFeedback(.increase, trigger: isReceiveSheetPresented) - .buttonStyle( - BitcoinFilled( - width: 120, - tintColor: .accent, - isCapsule: true - ) - ) - .sheet( - isPresented: $isSendSheetManualPresented, - onDismiss: { - Task { - viewModel.update() - } - } - ) { - SendView( - viewModel: SendViewModel.init( - lightningClient: viewModel.lightningClient, - sendViewState: .manualEntry, - price: viewModel.price, - balances: viewModel.balances - ) - ) - .presentationDetents([.large]) - } - .sheet( - isPresented: $isSendSheetCameraPresented, - onDismiss: { - Task { - viewModel.update() - } - } - ) { - SendView( - viewModel: SendViewModel.init( - lightningClient: viewModel.lightningClient, - sendViewState: .scanAddress, - price: viewModel.price, - balances: viewModel.balances - ) - ) - .presentationDetents([.large]) - } - .sheet( - isPresented: $isReceiveSheetPresented, - onDismiss: { - Task { - viewModel.update() - } - } - ) { - ReceiveView(viewModel: .init(lightningClient: viewModel.lightningClient)) - .presentationDetents([.large]) - } - - }.onChange( - of: eventService.lastEvent, - { _, _ in - withAnimation { - isReceiveSheetPresented = false - isSendSheetManualPresented = false - isSendSheetCameraPresented = false - } - } - ) - } - -} - public enum DisplayBalanceType: String { case fiatSats case fiatBtc