Skip to content
Merged
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
8 changes: 6 additions & 2 deletions BDKSwiftExampleWallet/App/BDKSwiftExampleWalletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ struct BDKSwiftExampleWalletApp: App {
var body: some Scene {
WindowGroup {
NavigationStack(path: $navigationPath) {
if isOnboarding {
let value = try? KeyClient.live.getBackupInfo()
if isOnboarding && (value == nil) {
OnboardingView(viewModel: .init(bdkClient: .live))
} else if !isOnboarding && (value == nil) {
OnboardingView(viewModel: .init(bdkClient: .live))
} else {
HomeView(viewModel: .init(bdkClient: .live))
HomeView(viewModel: .init(bdkClient: .live), navigationPath: $navigationPath)
}
}
.onChange(of: isOnboarding) { oldValue, newValue in
BDKClient.live.setNeedsFullScan(true)
navigationPath = NavigationPath()
}
}
Expand Down
3 changes: 3 additions & 0 deletions BDKSwiftExampleWallet/View Model/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class HomeViewModel: ObservableObject {
} catch let error as LoadWithPersistError {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
} catch let error as KeyServiceError {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
} catch {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
Expand Down
4 changes: 3 additions & 1 deletion BDKSwiftExampleWallet/View Model/OnboardingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ class OnboardingViewModel: ObservableObject {
func createWallet() {
do {
try bdkClient.createWallet(words)
isOnboarding = false
DispatchQueue.main.async {
self.isOnboarding = false
}
} catch let error as CreateWithPersistError {
DispatchQueue.main.async {
self.createWithPersistError = error
Expand Down
9 changes: 7 additions & 2 deletions BDKSwiftExampleWallet/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct HomeView: View {
@Bindable var viewModel: HomeViewModel
@Binding var navigationPath: NavigationPath

var body: some View {

Expand All @@ -19,7 +20,8 @@ struct HomeView: View {
viewModel: .init(
priceClient: .live,
bdkClient: .live
)
),
sendNavigationPath: $navigationPath
)
.tint(.primary)
.onAppear {
Expand Down Expand Up @@ -50,6 +52,9 @@ enum NavigationDestination: Hashable {

#if DEBUG
#Preview {
HomeView(viewModel: .init(bdkClient: .mock))
HomeView(
viewModel: .init(bdkClient: .mock),
navigationPath: .constant(.init())
)
}
#endif
8 changes: 6 additions & 2 deletions BDKSwiftExampleWallet/View/Send/AddressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ struct CustomScannerView: View {
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .top) {
CodeScannerView(codeTypes: codeTypes, completion: completion)
.edgesIgnoringSafeArea(.all)
CodeScannerView(
codeTypes: codeTypes,
shouldVibrateOnSuccess: true,
completion: completion
)
.edgesIgnoringSafeArea(.all)

VStack {
HStack {
Expand Down
5 changes: 3 additions & 2 deletions BDKSwiftExampleWallet/View/WalletView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct WalletView: View {
@State private var showAllTransactions = false
@State private var showReceiveView = false
@State private var showSettingsView = false
@State private var sendNavigationPath = NavigationPath()
@Binding var sendNavigationPath: NavigationPath

var body: some View {

Expand Down Expand Up @@ -299,7 +299,8 @@ struct WalletView: View {
bdkClient: .mock,
walletSyncState: .synced,
transactions: [.mock]
)
),
sendNavigationPath: .constant(.init())
)
}
#endif
Loading