Skip to content

Commit 48a7549

Browse files
authored
ui: remove tabview
1 parent cc04fb7 commit 48a7549

File tree

6 files changed

+65
-67
lines changed

6 files changed

+65
-67
lines changed

BDKSwiftExampleWallet.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
AE29ED112BBE318A00EB9C4F /* TransactionItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE29ED102BBE318A00EB9C4F /* TransactionItemView.swift */; };
2929
AE29ED152BBE36C500EB9C4F /* TransactionListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE29ED142BBE36C500EB9C4F /* TransactionListViewModel.swift */; };
3030
AE2ADD742B61E8F500C2A823 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD732B61E8F500C2A823 /* SettingsView.swift */; };
31-
AE2ADD762B61EFEB00C2A823 /* TabHomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */; };
31+
AE2ADD762B61EFEB00C2A823 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */; };
3232
AE2ADD782B61EFFF00C2A823 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD772B61EFFE00C2A823 /* SettingsViewModel.swift */; };
3333
AE2B8C1D2A9678C900815B2F /* FeeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2B8C1C2A9678C900815B2F /* FeeService.swift */; };
3434
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2B8C1E2A96797300815B2F /* RecommendedFees.swift */; };
3535
AE2F255D2BED0BFB002A9AC6 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2F255C2BED0BFB002A9AC6 /* AppError.swift */; };
3636
AE34DDAC2B6B31ED00F04AD4 /* SeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE34DDAB2B6B31ED00F04AD4 /* SeedView.swift */; };
3737
AE34DDAE2B6B320F00F04AD4 /* SeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE34DDAD2B6B320F00F04AD4 /* SeedViewModel.swift */; };
3838
AE3646262BEDB01200B04E25 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3646252BEDB01200B04E25 /* FileManager+Extensions.swift */; };
39-
AE3902A42A3B4CD900BEC318 /* TabHomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */; };
39+
AE3902A42A3B4CD900BEC318 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3902A32A3B4CD900BEC318 /* HomeView.swift */; };
4040
AE49847C2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49847B2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift */; };
4141
AE4984802A1BBBD7009951E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE49847F2A1BBBD7009951E2 /* Assets.xcassets */; };
4242
AE4984832A1BBBD7009951E2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE4984822A1BBBD7009951E2 /* Preview Assets.xcassets */; };
@@ -119,15 +119,15 @@
119119
AE29ED102BBE318A00EB9C4F /* TransactionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionItemView.swift; sourceTree = "<group>"; };
120120
AE29ED142BBE36C500EB9C4F /* TransactionListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionListViewModel.swift; sourceTree = "<group>"; };
121121
AE2ADD732B61E8F500C2A823 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
122-
AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabHomeViewModel.swift; sourceTree = "<group>"; };
122+
AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
123123
AE2ADD772B61EFFE00C2A823 /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
124124
AE2B8C1C2A9678C900815B2F /* FeeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeeService.swift; sourceTree = "<group>"; };
125125
AE2B8C1E2A96797300815B2F /* RecommendedFees.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendedFees.swift; sourceTree = "<group>"; };
126126
AE2F255C2BED0BFB002A9AC6 /* AppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = "<group>"; };
127127
AE34DDAB2B6B31ED00F04AD4 /* SeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedView.swift; sourceTree = "<group>"; };
128128
AE34DDAD2B6B320F00F04AD4 /* SeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedViewModel.swift; sourceTree = "<group>"; };
129129
AE3646252BEDB01200B04E25 /* FileManager+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+Extensions.swift"; sourceTree = "<group>"; };
130-
AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabHomeView.swift; sourceTree = "<group>"; };
130+
AE3902A32A3B4CD900BEC318 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
131131
AE4984782A1BBBD6009951E2 /* BDKSwiftExampleWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDKSwiftExampleWallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
132132
AE49847B2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSwiftExampleWalletApp.swift; sourceTree = "<group>"; };
133133
AE49847F2A1BBBD7009951E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -211,7 +211,7 @@
211211
isa = PBXGroup;
212212
children = (
213213
AE0C30F82A804B65008F1EAE /* OnboardingViewModel.swift */,
214-
AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */,
214+
AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */,
215215
AE0C30FA2A804B95008F1EAE /* WalletViewModel.swift */,
216216
AE2381BA2C61256000F6B00C /* Activity */,
217217
AE2381BB2C61256E00F6B00C /* Receive */,
@@ -239,7 +239,7 @@
239239
isa = PBXGroup;
240240
children = (
241241
AED4CC0B2A1D3A9400CE1831 /* OnboardingView.swift */,
242-
AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */,
242+
AE3902A32A3B4CD900BEC318 /* HomeView.swift */,
243243
AED4CC0F2A1D522100CE1831 /* WalletView.swift */,
244244
AE2381B62C61253200F6B00C /* Activity */,
245245
AE2381B92C61255100F6B00C /* Receive */,
@@ -640,7 +640,7 @@
640640
AEC2CF5A2ABFBA19008065E4 /* BuildTransactionViewModel.swift in Sources */,
641641
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */,
642642
AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */,
643-
AE2ADD762B61EFEB00C2A823 /* TabHomeViewModel.swift in Sources */,
643+
AE2ADD762B61EFEB00C2A823 /* HomeViewModel.swift in Sources */,
644644
AE783A032AB4ECC2005F0CBA /* AddressView.swift in Sources */,
645645
AE7F67052A7446B600CED561 /* PriceService.swift in Sources */,
646646
AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */,
@@ -685,7 +685,7 @@
685685
AE29ED112BBE318A00EB9C4F /* TransactionItemView.swift in Sources */,
686686
AE34DDAE2B6B320F00F04AD4 /* SeedViewModel.swift in Sources */,
687687
AE0C30F92A804B65008F1EAE /* OnboardingViewModel.swift in Sources */,
688-
AE3902A42A3B4CD900BEC318 /* TabHomeView.swift in Sources */,
688+
AE3902A42A3B4CD900BEC318 /* HomeView.swift in Sources */,
689689
AE0C30FD2A804BC1008F1EAE /* ReceiveViewModel.swift in Sources */,
690690
);
691691
runOnlyForDeploymentPostprocessing = 0;

BDKSwiftExampleWallet/App/BDKSwiftExampleWalletApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct BDKSwiftExampleWalletApp: App {
1717
if isOnboarding {
1818
OnboardingView(viewModel: .init(bdkClient: .live))
1919
} else {
20-
TabHomeView(viewModel: .init(bdkClient: .live))
20+
HomeView(viewModel: .init(bdkClient: .live))
2121
}
2222
}
2323
}

BDKSwiftExampleWallet/Resources/Localizable.xcstrings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@
386386
},
387387
"Full Scan" : {
388388

389+
},
390+
"HomeView Error" : {
391+
389392
},
390393
"Navigation Title" : {
391394

@@ -609,6 +612,7 @@
609612
}
610613
},
611614
"TabView Error" : {
615+
"extractionState" : "stale",
612616
"localizations" : {
613617
"fr" : {
614618
"stringUnit" : {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// HomeViewModel.swift
3+
// BDKSwiftExampleWallet
4+
//
5+
// Created by Matthew Ramsden on 1/24/24.
6+
//
7+
8+
import BitcoinDevKit
9+
import Foundation
10+
11+
@MainActor
12+
@Observable
13+
class HomeViewModel: ObservableObject {
14+
let bdkClient: BDKClient
15+
16+
var homeViewError: AppError?
17+
var showingHomeViewErrorAlert = false
18+
19+
init(bdkClient: BDKClient = .live) {
20+
self.bdkClient = bdkClient
21+
}
22+
23+
func loadWallet() {
24+
do {
25+
try bdkClient.loadWallet()
26+
} catch let error as DescriptorError {
27+
self.homeViewError = .generic(message: error.localizedDescription)
28+
self.showingHomeViewErrorAlert = true
29+
} catch let error as LoadWithPersistError {
30+
self.homeViewError = .generic(message: error.localizedDescription)
31+
self.showingHomeViewErrorAlert = true
32+
} catch {
33+
self.homeViewError = .generic(message: error.localizedDescription)
34+
self.showingHomeViewErrorAlert = true
35+
}
36+
}
37+
38+
}

BDKSwiftExampleWallet/View Model/TabHomeViewModel.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
//
2-
// TabHomeView.swift
2+
// HomeView.swift
33
// BDKSwiftExampleWallet
44
//
55
// Created by Matthew Ramsden on 6/15/23.
66
//
77

88
import SwiftUI
99

10-
struct TabHomeView: View {
11-
@Bindable var viewModel: TabHomeViewModel
10+
struct HomeView: View {
11+
@Bindable var viewModel: HomeViewModel
1212

1313
var body: some View {
1414

1515
ZStack {
1616
Color(uiColor: UIColor.systemBackground)
1717

18-
TabView {
19-
WalletView(
20-
viewModel: .init(
21-
priceClient: .live,
22-
bdkClient: .live
23-
)
18+
WalletView(
19+
viewModel: .init(
20+
priceClient: .live,
21+
bdkClient: .live
2422
)
25-
.tabItem {
26-
Image(systemName: "bitcoinsign")
27-
}
28-
29-
}
23+
)
3024
.tint(.primary)
3125
.onAppear {
3226
viewModel.loadWallet()
3327
}
3428

3529
}
36-
.alert(isPresented: $viewModel.showingTabViewErrorAlert) {
30+
.alert(isPresented: $viewModel.showingHomeViewErrorAlert) {
3731
Alert(
38-
title: Text("TabView Error"),
39-
message: Text(viewModel.tabViewError?.description ?? "Unknown"),
32+
title: Text("HomeView Error"),
33+
message: Text(viewModel.homeViewError?.description ?? "Unknown"),
4034
dismissButton: .default(Text("OK")) {
41-
viewModel.tabViewError = nil
35+
viewModel.homeViewError = nil
4236
}
4337
)
4438
}
@@ -56,10 +50,10 @@ enum NavigationDestination: Hashable {
5650

5751
#if DEBUG
5852
#Preview {
59-
TabHomeView(viewModel: .init(bdkClient: .mock))
53+
HomeView(viewModel: .init(bdkClient: .mock))
6054
}
6155
#Preview {
62-
TabHomeView(viewModel: .init())
56+
HomeView(viewModel: .init())
6357
.environment(\.dynamicTypeSize, .accessibility5)
6458
}
6559
#endif

0 commit comments

Comments
 (0)