Skip to content

ui: remove tabview #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2024
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
16 changes: 8 additions & 8 deletions BDKSwiftExampleWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
AE29ED112BBE318A00EB9C4F /* TransactionItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE29ED102BBE318A00EB9C4F /* TransactionItemView.swift */; };
AE29ED152BBE36C500EB9C4F /* TransactionListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE29ED142BBE36C500EB9C4F /* TransactionListViewModel.swift */; };
AE2ADD742B61E8F500C2A823 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD732B61E8F500C2A823 /* SettingsView.swift */; };
AE2ADD762B61EFEB00C2A823 /* TabHomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */; };
AE2ADD762B61EFEB00C2A823 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */; };
AE2ADD782B61EFFF00C2A823 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2ADD772B61EFFE00C2A823 /* SettingsViewModel.swift */; };
AE2B8C1D2A9678C900815B2F /* FeeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2B8C1C2A9678C900815B2F /* FeeService.swift */; };
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2B8C1E2A96797300815B2F /* RecommendedFees.swift */; };
AE2F255D2BED0BFB002A9AC6 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2F255C2BED0BFB002A9AC6 /* AppError.swift */; };
AE34DDAC2B6B31ED00F04AD4 /* SeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE34DDAB2B6B31ED00F04AD4 /* SeedView.swift */; };
AE34DDAE2B6B320F00F04AD4 /* SeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE34DDAD2B6B320F00F04AD4 /* SeedViewModel.swift */; };
AE3646262BEDB01200B04E25 /* FileManager+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3646252BEDB01200B04E25 /* FileManager+Extensions.swift */; };
AE3902A42A3B4CD900BEC318 /* TabHomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */; };
AE3902A42A3B4CD900BEC318 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3902A32A3B4CD900BEC318 /* HomeView.swift */; };
AE49847C2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE49847B2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift */; };
AE4984802A1BBBD7009951E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE49847F2A1BBBD7009951E2 /* Assets.xcassets */; };
AE4984832A1BBBD7009951E2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE4984822A1BBBD7009951E2 /* Preview Assets.xcassets */; };
Expand Down Expand Up @@ -119,15 +119,15 @@
AE29ED102BBE318A00EB9C4F /* TransactionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionItemView.swift; sourceTree = "<group>"; };
AE29ED142BBE36C500EB9C4F /* TransactionListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionListViewModel.swift; sourceTree = "<group>"; };
AE2ADD732B61E8F500C2A823 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabHomeViewModel.swift; sourceTree = "<group>"; };
AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
AE2ADD772B61EFFE00C2A823 /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
AE2B8C1C2A9678C900815B2F /* FeeService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeeService.swift; sourceTree = "<group>"; };
AE2B8C1E2A96797300815B2F /* RecommendedFees.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendedFees.swift; sourceTree = "<group>"; };
AE2F255C2BED0BFB002A9AC6 /* AppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = "<group>"; };
AE34DDAB2B6B31ED00F04AD4 /* SeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedView.swift; sourceTree = "<group>"; };
AE34DDAD2B6B320F00F04AD4 /* SeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedViewModel.swift; sourceTree = "<group>"; };
AE3646252BEDB01200B04E25 /* FileManager+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+Extensions.swift"; sourceTree = "<group>"; };
AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabHomeView.swift; sourceTree = "<group>"; };
AE3902A32A3B4CD900BEC318 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
AE4984782A1BBBD6009951E2 /* BDKSwiftExampleWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDKSwiftExampleWallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
AE49847B2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSwiftExampleWalletApp.swift; sourceTree = "<group>"; };
AE49847F2A1BBBD7009951E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,7 +211,7 @@
isa = PBXGroup;
children = (
AE0C30F82A804B65008F1EAE /* OnboardingViewModel.swift */,
AE2ADD752B61EFEB00C2A823 /* TabHomeViewModel.swift */,
AE2ADD752B61EFEB00C2A823 /* HomeViewModel.swift */,
AE0C30FA2A804B95008F1EAE /* WalletViewModel.swift */,
AE2381BA2C61256000F6B00C /* Activity */,
AE2381BB2C61256E00F6B00C /* Receive */,
Expand Down Expand Up @@ -239,7 +239,7 @@
isa = PBXGroup;
children = (
AED4CC0B2A1D3A9400CE1831 /* OnboardingView.swift */,
AE3902A32A3B4CD900BEC318 /* TabHomeView.swift */,
AE3902A32A3B4CD900BEC318 /* HomeView.swift */,
AED4CC0F2A1D522100CE1831 /* WalletView.swift */,
AE2381B62C61253200F6B00C /* Activity */,
AE2381B92C61255100F6B00C /* Receive */,
Expand Down Expand Up @@ -640,7 +640,7 @@
AEC2CF5A2ABFBA19008065E4 /* BuildTransactionViewModel.swift in Sources */,
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */,
AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */,
AE2ADD762B61EFEB00C2A823 /* TabHomeViewModel.swift in Sources */,
AE2ADD762B61EFEB00C2A823 /* HomeViewModel.swift in Sources */,
AE783A032AB4ECC2005F0CBA /* AddressView.swift in Sources */,
AE7F67052A7446B600CED561 /* PriceService.swift in Sources */,
AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */,
Expand Down Expand Up @@ -685,7 +685,7 @@
AE29ED112BBE318A00EB9C4F /* TransactionItemView.swift in Sources */,
AE34DDAE2B6B320F00F04AD4 /* SeedViewModel.swift in Sources */,
AE0C30F92A804B65008F1EAE /* OnboardingViewModel.swift in Sources */,
AE3902A42A3B4CD900BEC318 /* TabHomeView.swift in Sources */,
AE3902A42A3B4CD900BEC318 /* HomeView.swift in Sources */,
AE0C30FD2A804BC1008F1EAE /* ReceiveViewModel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion BDKSwiftExampleWallet/App/BDKSwiftExampleWalletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct BDKSwiftExampleWalletApp: App {
if isOnboarding {
OnboardingView(viewModel: .init(bdkClient: .live))
} else {
TabHomeView(viewModel: .init(bdkClient: .live))
HomeView(viewModel: .init(bdkClient: .live))
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions BDKSwiftExampleWallet/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@
},
"Full Scan" : {

},
"HomeView Error" : {

},
"Navigation Title" : {

Expand Down Expand Up @@ -609,6 +612,7 @@
}
},
"TabView Error" : {
"extractionState" : "stale",
"localizations" : {
"fr" : {
"stringUnit" : {
Expand Down
38 changes: 38 additions & 0 deletions BDKSwiftExampleWallet/View Model/HomeViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// HomeViewModel.swift
// BDKSwiftExampleWallet
//
// Created by Matthew Ramsden on 1/24/24.
//

import BitcoinDevKit
import Foundation

@MainActor
@Observable
class HomeViewModel: ObservableObject {
let bdkClient: BDKClient

var homeViewError: AppError?
var showingHomeViewErrorAlert = false

init(bdkClient: BDKClient = .live) {
self.bdkClient = bdkClient
}

func loadWallet() {
do {
try bdkClient.loadWallet()
} catch let error as DescriptorError {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
} catch let error as LoadWithPersistError {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
} catch {
self.homeViewError = .generic(message: error.localizedDescription)
self.showingHomeViewErrorAlert = true
}
}

}
38 changes: 0 additions & 38 deletions BDKSwiftExampleWallet/View Model/TabHomeViewModel.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
//
// TabHomeView.swift
// HomeView.swift
// BDKSwiftExampleWallet
//
// Created by Matthew Ramsden on 6/15/23.
//

import SwiftUI

struct TabHomeView: View {
@Bindable var viewModel: TabHomeViewModel
struct HomeView: View {
@Bindable var viewModel: HomeViewModel

var body: some View {

ZStack {
Color(uiColor: UIColor.systemBackground)

TabView {
WalletView(
viewModel: .init(
priceClient: .live,
bdkClient: .live
)
WalletView(
viewModel: .init(
priceClient: .live,
bdkClient: .live
)
.tabItem {
Image(systemName: "bitcoinsign")
}

}
)
.tint(.primary)
.onAppear {
viewModel.loadWallet()
}

}
.alert(isPresented: $viewModel.showingTabViewErrorAlert) {
.alert(isPresented: $viewModel.showingHomeViewErrorAlert) {
Alert(
title: Text("TabView Error"),
message: Text(viewModel.tabViewError?.description ?? "Unknown"),
title: Text("HomeView Error"),
message: Text(viewModel.homeViewError?.description ?? "Unknown"),
dismissButton: .default(Text("OK")) {
viewModel.tabViewError = nil
viewModel.homeViewError = nil
}
)
}
Expand All @@ -56,10 +50,10 @@ enum NavigationDestination: Hashable {

#if DEBUG
#Preview {
TabHomeView(viewModel: .init(bdkClient: .mock))
HomeView(viewModel: .init(bdkClient: .mock))
}
#Preview {
TabHomeView(viewModel: .init())
HomeView(viewModel: .init())
.environment(\.dynamicTypeSize, .accessibility5)
}
#endif
Loading