Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LDKNodeMonday.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_UISupportsDocumentBrowser = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -877,6 +878,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_UISupportsDocumentBrowser = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
184 changes: 68 additions & 116 deletions LDKNodeMonday/View/Home/BitcoinView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ struct BitcoinView: View {
@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
Expand All @@ -28,9 +31,6 @@ struct BitcoinView: View {
BalanceHeader(displayBalanceType: $displayBalanceType, viewModel: viewModel)
.padding(.vertical, 40)

TransactionButtons(viewModel: viewModel)
.padding(.horizontal, 40)

PaymentsListView(
payments: $viewModel.payments,
displayBalanceType: $displayBalanceType,
Expand Down Expand Up @@ -59,13 +59,50 @@ struct BitcoinView: View {
}
}
}
ToolbarItemGroup(placement: .bottomBar) {
// Send button
Button {
isSendSheetManualPresented = true
} label: {
Label("Send", systemImage: "arrow.up")
}.disabled(viewModel.unifiedBalance == 0)
.glassEffect()

Spacer()

// Scan QR button
Button {
isSendSheetCameraPresented = true
} label: {
Label("Scan QR", systemImage: "qrcode.viewfinder")
}
.font(.title)
.disabled(viewModel.unifiedBalance == 0)
.glassEffect()

Spacer()

// Receive button
Button {
isReceiveSheetPresented = true
} label: {
Label("Receive", systemImage: "arrow.down")
}
.sensoryFeedback(.increase, trigger: isReceiveSheetPresented)
.glassEffect()
}
}
.dynamicTypeSize(...DynamicTypeSize.accessibility2) // Sets max dynamic size for all Text
.onAppear { viewModel.update() }
.onChange(
of: eventService.lastEvent,
{ _, _ in
showToast = eventService.lastEvent != nil
withAnimation {
isReceiveSheetPresented = false
isSendSheetManualPresented = false
isSendSheetCameraPresented = false
}
}
)
.onReceive(viewModel.$bitcoinViewError) { errorMessage in
Expand Down Expand Up @@ -107,6 +144,34 @@ struct BitcoinView: View {
viewModel: .init(lightningClient: viewModel.lightningClient)
)
}
.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])
}
}

}
Expand Down Expand Up @@ -197,119 +262,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
Expand Down
Loading