diff --git a/LDKNodeMonday/App/LDKNodeMondayApp.swift b/LDKNodeMonday/App/LDKNodeMondayApp.swift index 75e6eb2..8726350 100644 --- a/LDKNodeMonday/App/LDKNodeMondayApp.swift +++ b/LDKNodeMonday/App/LDKNodeMondayApp.swift @@ -11,13 +11,19 @@ import SwiftUI struct LDKNodeMondayApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @AppStorage("isOnboarding") var isOnboarding: Bool = true + @State private var navigationPath = NavigationPath() var body: some Scene { WindowGroup { - if isOnboarding { - OnboardingView(viewModel: .init()) - } else { - StartView(viewModel: .init()) + NavigationStack(path: $navigationPath) { + if isOnboarding { + OnboardingView(viewModel: .init()) + } else { + StartView(viewModel: .init()) + } + } + .onChange(of: isOnboarding) { oldValue, newValue in + navigationPath = NavigationPath() } } } diff --git a/LDKNodeMonday/Extensions/PaymentKind+Extensions.swift b/LDKNodeMonday/Extensions/PaymentKind+Extensions.swift index 6d75a25..625d331 100644 --- a/LDKNodeMonday/Extensions/PaymentKind+Extensions.swift +++ b/LDKNodeMonday/Extensions/PaymentKind+Extensions.swift @@ -18,9 +18,9 @@ extension PaymentKind { return preimage case .spontaneous(_, let preimage): return preimage - case .bolt12Offer(hash: _, let preimage, secret: _, offerId: _): + case .bolt12Offer(hash: _, let preimage, secret: _, offerId: _, payerNote: _, quantity: _): return preimage - case .bolt12Refund(hash: _, let preimage, secret: _): + case .bolt12Refund(hash: _, let preimage, secret: _, payerNote: _, quantity: _): return preimage } } diff --git a/LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift b/LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift index 323b624..ffa9c51 100644 --- a/LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift +++ b/LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift @@ -161,6 +161,9 @@ func handleNodeError(_ error: NodeError) -> MondayError { case .InvalidUri(let message): return .init(title: "InvalidUri", detail: message) + case .InvalidQuantity(let message): + return .init(title: "InvalidQuantity", detail: message) + } } diff --git a/LDKNodeMonday/View Model/Profile/Channel/ChannelAddViewModel.swift b/LDKNodeMonday/View Model/Profile/Channel/ChannelAddViewModel.swift index 2d5b192..25699f8 100644 --- a/LDKNodeMonday/View Model/Profile/Channel/ChannelAddViewModel.swift +++ b/LDKNodeMonday/View Model/Profile/Channel/ChannelAddViewModel.swift @@ -16,15 +16,14 @@ class ChannelAddViewModel: ObservableObject { @Published var nodeId: PublicKey = "" @Published var isOpenChannelFinished: Bool = false @Published var isProgressViewShowing: Bool = false - private let channelConfig = ChannelConfig() - - init() { - self.channelConfig.setForwardingFeeProportionalMillionths(value: UInt32(0)) - self.channelConfig.setForwardingFeeBaseMsat(feeMsat: UInt32(1000)) - self.channelConfig.setCltvExpiryDelta(value: UInt16(72)) - self.channelConfig.setMaxDustHtlcExposureFromFixedLimit(limitMsat: UInt64(50_000_000)) - self.channelConfig.setForceCloseAvoidanceMaxFeeSatoshis(valueSat: UInt64(1000)) - } + private let channelConfig = ChannelConfig( + forwardingFeeProportionalMillionths: UInt32(0), + forwardingFeeBaseMsat: UInt32(1000), + cltvExpiryDelta: UInt16(72), + maxDustHtlcExposure: .feeRateMultiplier(multiplier: UInt64(50_000_000)), + forceCloseAvoidanceMaxFeeSatoshis: UInt64(1000), + acceptUnderpayingHtlcs: false + ) func openChannel( nodeId: PublicKey, diff --git a/LDKNodeMonday/View/Home/BitcoinView.swift b/LDKNodeMonday/View/Home/BitcoinView.swift index 6a054de..f5a33cd 100644 --- a/LDKNodeMonday/View/Home/BitcoinView.swift +++ b/LDKNodeMonday/View/Home/BitcoinView.swift @@ -24,204 +24,258 @@ struct BitcoinView: View { var body: some View { - NavigationStack(path: $sendNavigationPath) { + ZStack { + Color(uiColor: UIColor.systemBackground) + .ignoresSafeArea(.all) - ZStack { - Color(uiColor: UIColor.systemBackground) - .ignoresSafeArea(.all) + VStack { - VStack { + List { - List { + VStack(spacing: 20) { - VStack(spacing: 20) { - - VStack { - HStack(spacing: 15) { - Spacer() - Image(systemName: "bitcoinsign") - .font(.title) - .fontWeight(.thin) - Text(viewModel.totalBalance.formattedSatoshis()) - .contentTransition(.numericText()) - .font(.largeTitle) - .fontWeight(.semibold) - .fontDesign(.rounded) - .redacted( - reason: viewModel.isTotalBalanceFinished - ? [] : .placeholder - ) - Text("sats") - .font(.title) - .fontWeight(.thin) - Spacer() - } - .minimumScaleFactor(0.5) - .lineLimit(1) - .foregroundColor(.primary) - - if let status = viewModel.status, - let timestamp = status.latestOnchainWalletSyncTimestamp - { - let date = Date( - timeIntervalSince1970: TimeInterval( - timestamp - ) + VStack { + HStack(spacing: 15) { + Spacer() + Image(systemName: "bitcoinsign") + .font(.title) + .fontWeight(.thin) + Text(viewModel.totalBalance.formattedSatoshis()) + .contentTransition(.numericText()) + .font(.largeTitle) + .fontWeight(.semibold) + .fontDesign(.rounded) + .redacted( + reason: viewModel.isTotalBalanceFinished + ? [] : .placeholder ) - Text(date.formattedDate()) - .lineLimit(1) - .font(.caption2) - .foregroundColor(.secondary) - .padding(.bottom, 20.0) - .minimumScaleFactor(0.5) - } - + Text("sats") + .font(.title) + .fontWeight(.thin) + Spacer() } - - VStack { - HStack(spacing: 15) { - Spacer() - Image(systemName: "bolt") - .font(.title) - .fontWeight(.thin) - Text(viewModel.totalLightningBalance.formattedSatoshis()) - .contentTransition(.numericText()) - .font(.largeTitle) - .fontWeight(.semibold) - .fontDesign(.rounded) - .redacted( - reason: viewModel.isTotalLightningBalanceFinished - ? [] : .placeholder - ) - Text("sats") - .font(.title) - .fontWeight(.thin) - Spacer() - } - .minimumScaleFactor(0.5) - .lineLimit(1) - .foregroundColor(.primary) - - if let status = viewModel.status, - let timestamp = status.latestOnchainWalletSyncTimestamp - { - let date = Date( - timeIntervalSince1970: TimeInterval( - timestamp - ) + .minimumScaleFactor(0.5) + .lineLimit(1) + .foregroundColor(.primary) + + if let status = viewModel.status, + let timestamp = status.latestOnchainWalletSyncTimestamp + { + let date = Date( + timeIntervalSince1970: TimeInterval( + timestamp ) - Text(date.formattedDate()) - .lineLimit(1) - .font(.caption2) - .foregroundColor(.secondary) - .padding(.bottom, 20.0) - .minimumScaleFactor(0.5) - } + ) + Text(date.formattedDate()) + .lineLimit(1) + .font(.caption2) + .foregroundColor(.secondary) + .padding(.bottom, 20.0) + .minimumScaleFactor(0.5) } - HStack { + } + + VStack { + HStack(spacing: 15) { Spacer() - Text(viewModel.totalUSDValue) + Image(systemName: "bolt") + .font(.title) + .fontWeight(.thin) + Text(viewModel.totalLightningBalance.formattedSatoshis()) .contentTransition(.numericText()) + .font(.largeTitle) .fontWeight(.semibold) .fontDesign(.rounded) - .redacted(reason: viewModel.isPriceFinished ? [] : .placeholder) + .redacted( + reason: viewModel.isTotalLightningBalanceFinished + ? [] : .placeholder + ) + Text("sats") + .font(.title) + .fontWeight(.thin) Spacer() } + .minimumScaleFactor(0.5) .lineLimit(1) - .animation(.spring(), value: viewModel.isPriceFinished) - .font(.subheadline) - .foregroundColor(.secondary) + .foregroundColor(.primary) + + if let status = viewModel.status, + let timestamp = status.latestOnchainWalletSyncTimestamp + { + let date = Date( + timeIntervalSince1970: TimeInterval( + timestamp + ) + ) + Text(date.formattedDate()) + .lineLimit(1) + .font(.caption2) + .foregroundColor(.secondary) + .padding(.bottom, 20.0) + .minimumScaleFactor(0.5) + } + } + HStack { + Spacer() + Text(viewModel.totalUSDValue) + .contentTransition(.numericText()) + .fontWeight(.semibold) + .fontDesign(.rounded) + .redacted(reason: viewModel.isPriceFinished ? [] : .placeholder) Spacer() - } - .listRowSeparator(.hidden) + .lineLimit(1) + .animation(.spring(), value: viewModel.isPriceFinished) + .font(.subheadline) + .foregroundColor(.secondary) + + Spacer() } - .listStyle(.plain) - .padding(.top, 120.0) - .padding(.horizontal, -20) - .refreshable { - await viewModel.getTotalOnchainBalanceSats() - await viewModel.getTotalLightningBalanceSats() - await viewModel.getPrices() - await viewModel.getSpendableOnchainBalanceSats() - await viewModel.getStatus() - } + .listRowSeparator(.hidden) - Spacer() + } + .listStyle(.plain) + .padding(.top, 220.0) + .padding(.horizontal, -20) + .refreshable { + await viewModel.getTotalOnchainBalanceSats() + await viewModel.getTotalLightningBalanceSats() + await viewModel.getPrices() + await viewModel.getSpendableOnchainBalanceSats() + await viewModel.getStatus() + } - Button { - isPaymentsPresented = true - } label: { - HStack { - Image(systemName: "bolt.fill") - Text("View Payments") - } - } - .tint(viewModel.networkColor) - .padding() + Spacer() + Button { + isPaymentsPresented = true + } label: { HStack { + Image(systemName: "bolt.fill") + Text("View Payments") + } + } + .tint(viewModel.networkColor) + .padding() - Button(action: { - isReceiveSheetPresented = true - }) { - Image(systemName: "qrcode") - .font(.title) - .foregroundColor(.primary) - } + HStack { - Spacer() + Button(action: { + isReceiveSheetPresented = true + }) { + Image(systemName: "qrcode") + .font(.title) + .foregroundColor(.primary) + } - Button(action: { - sendNavigationPath.append(NavigationDestination.address) - }) { - Image(systemName: "qrcode.viewfinder") - .font(.title) - .foregroundColor(.primary) - } + Spacer() + NavigationLink(value: NavigationDestination.address) { + Image(systemName: "qrcode.viewfinder") + .font(.title) + .foregroundColor(.primary) } - .padding([.horizontal, .bottom]) } - .padding() - .tint(viewModel.networkColor) - .toolbar { - ToolbarItemGroup(placement: .navigationBarTrailing) { - Button(action: { - showingNodeIDView = true - }) { - Image(systemName: "person.crop.circle.dashed.circle") - .font(.title) - .foregroundColor(.primary) - } + .padding([.horizontal, .bottom]) + + } + .padding() + .padding(.bottom, 20.0) + .tint(viewModel.networkColor) + .toolbar { + ToolbarItemGroup(placement: .navigationBarTrailing) { + Button(action: { + showingNodeIDView = true + }) { + Image(systemName: "person.crop.circle.dashed.circle") + .font(.title) + .foregroundColor(.primary) } } - .onAppear { + } + .onAppear { + Task { + await viewModel.getTotalOnchainBalanceSats() + await viewModel.getTotalLightningBalanceSats() + await viewModel.getPrices() + viewModel.getColor() + await viewModel.getSpendableOnchainBalanceSats() + await viewModel.getStatus() + } + } + .onChange( + of: eventService.lastMessage, + { oldValue, newValue in + showToast = eventService.lastMessage != nil + } + ) + .onReceive(viewModel.$bitcoinViewError) { errorMessage in + if errorMessage != nil { + showingBitcoinViewErrorAlert = true + } + } + .onReceive(eventService.$lastMessage) { _ in + Task { + await viewModel.getTotalOnchainBalanceSats() + await viewModel.getTotalLightningBalanceSats() + await viewModel.getPrices() + await viewModel.getSpendableOnchainBalanceSats() + await viewModel.getStatus() + } + } + .sheet( + isPresented: $showingNodeIDView, + onDismiss: { Task { await viewModel.getTotalOnchainBalanceSats() await viewModel.getTotalLightningBalanceSats() await viewModel.getPrices() - viewModel.getColor() await viewModel.getSpendableOnchainBalanceSats() await viewModel.getStatus() } } - .onChange( - of: eventService.lastMessage, - { oldValue, newValue in - showToast = eventService.lastMessage != nil + ) { + NodeIDView(viewModel: .init()) + } + .alert(isPresented: $showingBitcoinViewErrorAlert) { + Alert( + title: Text(viewModel.bitcoinViewError?.title ?? "Unknown"), + message: Text(viewModel.bitcoinViewError?.detail ?? ""), + dismissButton: .default(Text("OK")) { + viewModel.bitcoinViewError = nil } ) - .onReceive(viewModel.$bitcoinViewError) { errorMessage in - if errorMessage != nil { - showingBitcoinViewErrorAlert = true - } - } - .onReceive(eventService.$lastMessage) { _ in + } + .simpleToast( + isPresented: $showToast, + options: .init( + hideAfter: 5.0, + animation: .spring, + modifierType: .slide + ) + ) { + Text(eventService.lastMessage ?? "") + .padding() + .background( + Capsule() + .foregroundColor( + Color( + uiColor: + colorScheme == .dark + ? .secondarySystemBackground : .systemGray6 + ) + ) + ) + .foregroundColor(Color.primary) + .font(.caption2) + } + .sheet( + isPresented: $isReceiveSheetPresented, + onDismiss: { Task { await viewModel.getTotalOnchainBalanceSats() await viewModel.getTotalLightningBalanceSats() @@ -230,111 +284,53 @@ struct BitcoinView: View { await viewModel.getStatus() } } - .sheet( - isPresented: $showingNodeIDView, - onDismiss: { - Task { - await viewModel.getTotalOnchainBalanceSats() - await viewModel.getTotalLightningBalanceSats() - await viewModel.getPrices() - await viewModel.getSpendableOnchainBalanceSats() - await viewModel.getStatus() - } - } - ) { - NodeIDView(viewModel: .init()) - } - .alert(isPresented: $showingBitcoinViewErrorAlert) { - Alert( - title: Text(viewModel.bitcoinViewError?.title ?? "Unknown"), - message: Text(viewModel.bitcoinViewError?.detail ?? ""), - dismissButton: .default(Text("OK")) { - viewModel.bitcoinViewError = nil - } - ) - } - .simpleToast( - isPresented: $showToast, - options: .init( - hideAfter: 5.0, - animation: .spring, - modifierType: .slide - ) - ) { - Text(eventService.lastMessage ?? "") - .padding() - .background( - Capsule() - .foregroundColor( - Color( - uiColor: - colorScheme == .dark - ? .secondarySystemBackground : .systemGray6 - ) - ) - ) - .foregroundColor(Color.primary) - .font(.caption2) - } - .sheet( - isPresented: $isReceiveSheetPresented, - onDismiss: { - Task { - await viewModel.getTotalOnchainBalanceSats() - await viewModel.getTotalLightningBalanceSats() - await viewModel.getPrices() - await viewModel.getSpendableOnchainBalanceSats() - await viewModel.getStatus() - } - } - ) { - ReceiveView() - .presentationDetents([.large]) - } - .sheet( - isPresented: $isPaymentsPresented, - onDismiss: { - Task { - await viewModel.getTotalOnchainBalanceSats() - await viewModel.getTotalLightningBalanceSats() - await viewModel.getPrices() - await viewModel.getSpendableOnchainBalanceSats() - await viewModel.getStatus() - } + ) { + ReceiveView() + .presentationDetents([.large]) + } + .sheet( + isPresented: $isPaymentsPresented, + onDismiss: { + Task { + await viewModel.getTotalOnchainBalanceSats() + await viewModel.getTotalLightningBalanceSats() + await viewModel.getPrices() + await viewModel.getSpendableOnchainBalanceSats() + await viewModel.getStatus() } - ) { - PaymentsView(viewModel: .init()) - .presentationDetents([.medium, .large]) } - + ) { + PaymentsView(viewModel: .init()) + .presentationDetents([.medium, .large]) } - .navigationDestination(for: NavigationDestination.self) { destination in - switch destination { - case .address: - AddressView( - navigationPath: $sendNavigationPath, - spendableBalance: viewModel.spendableBalance - ) - case .amount(let address, let amount, let payment): - AmountView( - viewModel: .init(), - address: address, - numpadAmount: amount, - payment: payment, - spendableBalance: viewModel.spendableBalance, - navigationPath: $sendNavigationPath - ) - .onDisappear { - Task { - await viewModel.getTotalOnchainBalanceSats() - await viewModel.getTotalLightningBalanceSats() - await viewModel.getPrices() - await viewModel.getSpendableOnchainBalanceSats() - await viewModel.getStatus() - } - } + } + .navigationDestination(for: NavigationDestination.self) { destination in + switch destination { + case .address: + AddressView( + navigationPath: $sendNavigationPath, + spendableBalance: viewModel.spendableBalance + ) + case .amount(let address, let amount, let payment): + AmountView( + viewModel: .init(), + address: address, + numpadAmount: amount, + payment: payment, + spendableBalance: viewModel.spendableBalance, + navigationPath: $sendNavigationPath + ) + .onDisappear { + Task { + await viewModel.getTotalOnchainBalanceSats() + await viewModel.getTotalLightningBalanceSats() + await viewModel.getPrices() + await viewModel.getSpendableOnchainBalanceSats() + await viewModel.getStatus() + } } + } } @@ -349,7 +345,7 @@ enum NavigationDestination: Hashable { } #if DEBUG -#Preview { - BitcoinView(viewModel: .init(priceClient: .mock)) -} + #Preview { + BitcoinView(viewModel: .init(priceClient: .mock)) + } #endif diff --git a/LDKNodeMonday/View/Home/OnboardingView.swift b/LDKNodeMonday/View/Home/OnboardingView.swift index 0c57bf4..b365cdd 100644 --- a/LDKNodeMonday/View/Home/OnboardingView.swift +++ b/LDKNodeMonday/View/Home/OnboardingView.swift @@ -152,7 +152,7 @@ struct OnboardingView: View { } #if DEBUG -#Preview { - OnboardingView(viewModel: .init()) -} + #Preview { + OnboardingView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Home/Payments/PaymentsListView.swift b/LDKNodeMonday/View/Home/Payments/PaymentsListView.swift index afb9acf..76cea8a 100644 --- a/LDKNodeMonday/View/Home/Payments/PaymentsListView.swift +++ b/LDKNodeMonday/View/Home/Payments/PaymentsListView.swift @@ -130,34 +130,34 @@ struct PaymentDetailView: View { } #if DEBUG -#Preview { - PaymentsListView( - payments: [ - .init( - id: .localizedName(of: .ascii), - kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), - amountMsat: nil, - direction: .inbound, - status: .succeeded, - latestUpdateTimestamp: 1_718_841_600 - ), - .init( - id: .localizedName(of: .ascii), - kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), - amountMsat: nil, - direction: .inbound, - status: .pending, - latestUpdateTimestamp: 1_718_841_600 - ), - .init( - id: .localizedName(of: .ascii), - kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), - amountMsat: nil, - direction: .inbound, - status: .failed, - latestUpdateTimestamp: 1_718_841_600 - ), - ] - ) -} + #Preview { + PaymentsListView( + payments: [ + .init( + id: .localizedName(of: .ascii), + kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), + amountMsat: nil, + direction: .inbound, + status: .succeeded, + latestUpdateTimestamp: 1_718_841_600 + ), + .init( + id: .localizedName(of: .ascii), + kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), + amountMsat: nil, + direction: .inbound, + status: .pending, + latestUpdateTimestamp: 1_718_841_600 + ), + .init( + id: .localizedName(of: .ascii), + kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil), + amountMsat: nil, + direction: .inbound, + status: .failed, + latestUpdateTimestamp: 1_718_841_600 + ), + ] + ) + } #endif diff --git a/LDKNodeMonday/View/Home/Payments/PaymentsView.swift b/LDKNodeMonday/View/Home/Payments/PaymentsView.swift index 0aff6a9..da0214d 100644 --- a/LDKNodeMonday/View/Home/Payments/PaymentsView.swift +++ b/LDKNodeMonday/View/Home/Payments/PaymentsView.swift @@ -51,7 +51,7 @@ struct PaymentsView: View { } #if DEBUG -#Preview { - PaymentsView(viewModel: .init()) -} + #Preview { + PaymentsView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Home/Receive/BIP21View.swift b/LDKNodeMonday/View/Home/Receive/BIP21View.swift index aa45f88..14d9e2e 100644 --- a/LDKNodeMonday/View/Home/Receive/BIP21View.swift +++ b/LDKNodeMonday/View/Home/Receive/BIP21View.swift @@ -225,7 +225,7 @@ func parseUnifiedQR(_ unifiedQR: String) -> UnifiedQRComponents? { } #if DEBUG -#Preview { - BIP21View(viewModel: .init()) -} + #Preview { + BIP21View(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Home/Receive/JITInvoiceView.swift b/LDKNodeMonday/View/Home/Receive/JITInvoiceView.swift index 71a141b..03acdae 100644 --- a/LDKNodeMonday/View/Home/Receive/JITInvoiceView.swift +++ b/LDKNodeMonday/View/Home/Receive/JITInvoiceView.swift @@ -145,7 +145,7 @@ struct JITInvoiceView: View { } #if DEBUG -#Preview { - JITInvoiceView(viewModel: .init()) -} + #Preview { + JITInvoiceView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Home/Receive/ReceiveView.swift b/LDKNodeMonday/View/Home/Receive/ReceiveView.swift index 8b79730..1a37186 100644 --- a/LDKNodeMonday/View/Home/Receive/ReceiveView.swift +++ b/LDKNodeMonday/View/Home/Receive/ReceiveView.swift @@ -129,7 +129,7 @@ struct InvoiceRowView: View { } #if DEBUG -#Preview { - ReceiveView() -} + #Preview { + ReceiveView() + } #endif diff --git a/LDKNodeMonday/View/Home/Send/AmountView.swift b/LDKNodeMonday/View/Home/Send/AmountView.swift index 16cd77b..1c5bdef 100644 --- a/LDKNodeMonday/View/Home/Send/AmountView.swift +++ b/LDKNodeMonday/View/Home/Send/AmountView.swift @@ -209,11 +209,11 @@ struct NumpadButton: View { } #if DEBUG -#Preview { - AmountView( - viewModel: .init(), - spendableBalance: UInt64(21000), - navigationPath: .constant(.init()) - ) -} + #Preview { + AmountView( + viewModel: .init(), + spendableBalance: UInt64(21000), + navigationPath: .constant(.init()) + ) + } #endif diff --git a/LDKNodeMonday/View/Home/StartView.swift b/LDKNodeMonday/View/Home/StartView.swift index 1ead14a..879b4ba 100644 --- a/LDKNodeMonday/View/Home/StartView.swift +++ b/LDKNodeMonday/View/Home/StartView.swift @@ -89,7 +89,7 @@ struct StartView: View { } #if DEBUG -#Preview { - StartView(viewModel: .init()) -} + #Preview { + StartView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Profile/Channel/ChannelAddView.swift b/LDKNodeMonday/View/Profile/Channel/ChannelAddView.swift index 85b4c03..2766cd7 100644 --- a/LDKNodeMonday/View/Profile/Channel/ChannelAddView.swift +++ b/LDKNodeMonday/View/Profile/Channel/ChannelAddView.swift @@ -298,7 +298,7 @@ extension ChannelAddView { } #if DEBUG -#Preview { - ChannelAddView(viewModel: .init()) -} + #Preview { + ChannelAddView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift b/LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift index ef6e4e7..ca5492d 100644 --- a/LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift +++ b/LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift @@ -127,41 +127,48 @@ struct ChannelDetailView: View { } #if DEBUG -#Preview { - ChannelDetailView( - viewModel: .init( - channel: ChannelDetails( - channelId: ChannelId(stringLiteral: "channelID"), - counterpartyNodeId: PublicKey(stringLiteral: "counterpartyNodeId"), - fundingTxo: nil, - channelValueSats: UInt64(1_000_000), - unspendablePunishmentReserve: nil, - userChannelId: UserChannelId(stringLiteral: "userChannelId"), - feerateSatPer1000Weight: UInt32(20000), - outboundCapacityMsat: UInt64(500000), - inboundCapacityMsat: UInt64(400000), - confirmationsRequired: nil, - confirmations: nil, - isOutbound: false, - isChannelReady: true, - isUsable: true, - isPublic: true, - cltvExpiryDelta: nil, - counterpartyUnspendablePunishmentReserve: UInt64(1000), - counterpartyOutboundHtlcMinimumMsat: nil, - counterpartyOutboundHtlcMaximumMsat: nil, - counterpartyForwardingInfoFeeBaseMsat: nil, - counterpartyForwardingInfoFeeProportionalMillionths: nil, - counterpartyForwardingInfoCltvExpiryDelta: nil, - nextOutboundHtlcLimitMsat: UInt64(1000), - nextOutboundHtlcMinimumMsat: UInt64(1000), - forceCloseSpendDelay: nil, - inboundHtlcMinimumMsat: UInt64(1000), - inboundHtlcMaximumMsat: nil, - config: .init() - ) - ), - refreshFlag: .constant(false) - ) -} + #Preview { + ChannelDetailView( + viewModel: .init( + channel: ChannelDetails( + channelId: ChannelId(stringLiteral: "channelID"), + counterpartyNodeId: PublicKey(stringLiteral: "counterpartyNodeId"), + fundingTxo: nil, + channelValueSats: UInt64(1_000_000), + unspendablePunishmentReserve: nil, + userChannelId: UserChannelId(stringLiteral: "userChannelId"), + feerateSatPer1000Weight: UInt32(20000), + outboundCapacityMsat: UInt64(500000), + inboundCapacityMsat: UInt64(400000), + confirmationsRequired: nil, + confirmations: nil, + isOutbound: false, + isChannelReady: true, + isUsable: true, + isPublic: true, + cltvExpiryDelta: nil, + counterpartyUnspendablePunishmentReserve: UInt64(1000), + counterpartyOutboundHtlcMinimumMsat: nil, + counterpartyOutboundHtlcMaximumMsat: nil, + counterpartyForwardingInfoFeeBaseMsat: nil, + counterpartyForwardingInfoFeeProportionalMillionths: nil, + counterpartyForwardingInfoCltvExpiryDelta: nil, + nextOutboundHtlcLimitMsat: UInt64(1000), + nextOutboundHtlcMinimumMsat: UInt64(1000), + forceCloseSpendDelay: nil, + inboundHtlcMinimumMsat: UInt64(1000), + inboundHtlcMaximumMsat: nil, + config: .init( + forwardingFeeProportionalMillionths: UInt32(21), + forwardingFeeBaseMsat: UInt32(21), + cltvExpiryDelta: UInt16(2), + maxDustHtlcExposure: .feeRateMultiplier(multiplier: UInt64(21)), + forceCloseAvoidanceMaxFeeSatoshis: UInt64(21), + acceptUnderpayingHtlcs: false + ) + ) + ), + refreshFlag: .constant(false) + ) + } #endif diff --git a/LDKNodeMonday/View/Profile/Channel/ChannelsListView.swift b/LDKNodeMonday/View/Profile/Channel/ChannelsListView.swift index 3db909d..af2d5dc 100644 --- a/LDKNodeMonday/View/Profile/Channel/ChannelsListView.swift +++ b/LDKNodeMonday/View/Profile/Channel/ChannelsListView.swift @@ -95,7 +95,7 @@ struct ChannelsRefactorView: View { } #if DEBUG -#Preview { - ChannelsRefactorView(viewModel: .init(nodeInfoClient: .mock)) -} + #Preview { + ChannelsRefactorView(viewModel: .init(nodeInfoClient: .mock)) + } #endif diff --git a/LDKNodeMonday/View/Profile/Danger/SeedView.swift b/LDKNodeMonday/View/Profile/Danger/SeedView.swift index 20feb3a..355f9fd 100644 --- a/LDKNodeMonday/View/Profile/Danger/SeedView.swift +++ b/LDKNodeMonday/View/Profile/Danger/SeedView.swift @@ -76,7 +76,7 @@ struct SeedView: View { } #if DEBUG -#Preview { - SeedView(viewModel: .init()) -} + #Preview { + SeedView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Profile/NodeIDView.swift b/LDKNodeMonday/View/Profile/NodeIDView.swift index 8557008..2bd47e3 100644 --- a/LDKNodeMonday/View/Profile/NodeIDView.swift +++ b/LDKNodeMonday/View/Profile/NodeIDView.swift @@ -10,6 +10,7 @@ import SwiftUI struct NodeIDView: View { @ObservedObject var viewModel: NodeIDViewModel + @Environment(\.dismiss) private var dismiss @State private var isCopied = false @State private var showCheckmark = false @State private var showingNodeIDErrorAlert = false @@ -136,7 +137,10 @@ struct NodeIDView: View { "Are you sure you want to reset preferences (and delete the seed)?", isPresented: $showingResetAppConfirmation ) { - Button("Yes", role: .destructive) { viewModel.onboarding() } + Button("Yes", role: .destructive) { + viewModel.onboarding() + dismiss() + } Button("No", role: .cancel) {} } @@ -147,7 +151,10 @@ struct NodeIDView: View { "Are you sure you want to delete the seed (and reset preferences)?", isPresented: $showingDeleteSeedConfirmation ) { - Button("Yes", role: .destructive) { viewModel.delete() } + Button("Yes", role: .destructive) { + viewModel.delete() + dismiss() + } Button("No", role: .cancel) {} } } @@ -208,7 +215,7 @@ struct NodeIDView: View { } #if DEBUG -#Preview { - NodeIDView(viewModel: .init()) -} + #Preview { + NodeIDView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Profile/Peers/DisconnectView.swift b/LDKNodeMonday/View/Profile/Peers/DisconnectView.swift index 5062483..1a707b5 100644 --- a/LDKNodeMonday/View/Profile/Peers/DisconnectView.swift +++ b/LDKNodeMonday/View/Profile/Peers/DisconnectView.swift @@ -80,11 +80,11 @@ struct DisconnectView: View { } #if DEBUG -#Preview { - DisconnectView( - viewModel: .init( - nodeId: "03e39c737a691931dac0f9f9ee803f2ab08f7fd3bbb25ec08d9b8fdb8f51d3a8db" + #Preview { + DisconnectView( + viewModel: .init( + nodeId: "03e39c737a691931dac0f9f9ee803f2ab08f7fd3bbb25ec08d9b8fdb8f51d3a8db" + ) ) - ) -} + } #endif diff --git a/LDKNodeMonday/View/Profile/Peers/PeerView.swift b/LDKNodeMonday/View/Profile/Peers/PeerView.swift index 380f9c0..6a9c446 100644 --- a/LDKNodeMonday/View/Profile/Peers/PeerView.swift +++ b/LDKNodeMonday/View/Profile/Peers/PeerView.swift @@ -249,7 +249,7 @@ extension PeerView { } #if DEBUG -#Preview { - PeerView(viewModel: .init()) -} + #Preview { + PeerView(viewModel: .init()) + } #endif diff --git a/LDKNodeMonday/View/Profile/Peers/PeersListView.swift b/LDKNodeMonday/View/Profile/Peers/PeersListView.swift index 760d542..e453e52 100644 --- a/LDKNodeMonday/View/Profile/Peers/PeersListView.swift +++ b/LDKNodeMonday/View/Profile/Peers/PeersListView.swift @@ -121,7 +121,7 @@ struct PeersListView: View { } #if DEBUG -#Preview { - PeersListView(viewModel: .init()) -} + #Preview { + PeersListView(viewModel: .init()) + } #endif