diff --git a/BDKSwiftExampleWallet.xcodeproj/project.pbxproj b/BDKSwiftExampleWallet.xcodeproj/project.pbxproj index c67ca016..308abc00 100644 --- a/BDKSwiftExampleWallet.xcodeproj/project.pbxproj +++ b/BDKSwiftExampleWallet.xcodeproj/project.pbxproj @@ -66,10 +66,10 @@ AE7F67092A7451AA00CED561 /* Price.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7F67082A7451AA00CED561 /* Price.swift */; }; AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7F670B2A7451D700CED561 /* CurrencyCode.swift */; }; AE83EFDB2C9D07B200B41244 /* ChainPosition+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE83EFDA2C9D07B200B41244 /* ChainPosition+Extensions.swift */; }; + AE8D001C2D19F1760029C4C9 /* UIScreen+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */; }; AE91CEED2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */; }; AE91CEEF2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */; }; AE96F6622A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */; }; - AEA1F6432CE43702004EC538 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEA1F6422CE43702004EC538 /* BitcoinDevKit */; }; AEAB03112ABDDB86000C9528 /* FeeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03102ABDDB86000C9528 /* FeeViewModel.swift */; }; AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03122ABDDBF4000C9528 /* AmountViewModel.swift */; }; AEAF83B62B7BD4D10019B23B /* CodeScanner in Frameworks */ = {isa = PBXBuildFile; productRef = AEAF83B52B7BD4D10019B23B /* CodeScanner */; }; @@ -90,7 +90,6 @@ AEE6C74C2ABCB3E200442ADD /* Transaction+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE6C74B2ABCB3E200442ADD /* Transaction+Extensions.swift */; }; AEE6C74F2ABCBA4600442ADD /* WalletSyncState.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE6C74E2ABCBA4600442ADD /* WalletSyncState.swift */; }; AEE83A492C07F54B00834468 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEE83A482C07F54B00834468 /* BitcoinDevKit */; }; - AEEA24572D136898000C1694 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEEA24562D136898000C1694 /* BitcoinDevKit */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -161,6 +160,7 @@ AE7F67082A7451AA00CED561 /* Price.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Price.swift; sourceTree = ""; }; AE7F670B2A7451D700CED561 /* CurrencyCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyCode.swift; sourceTree = ""; }; AE83EFDA2C9D07B200B41244 /* ChainPosition+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChainPosition+Extensions.swift"; sourceTree = ""; }; + AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScreen+Extensions.swift"; sourceTree = ""; }; AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentAndReceivedValues+Extensions.swift"; sourceTree = ""; }; AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CanonicalTx+Extensions.swift"; sourceTree = ""; }; AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSwiftExampleWalletReceiveViewModelTests.swift; sourceTree = ""; }; @@ -521,6 +521,7 @@ AE184EFB2BFE52C800374362 /* Amount+Extensions.swift */, AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */, AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */, + AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */, ); path = "BDK+Extensions"; sourceTree = ""; @@ -654,6 +655,7 @@ AEB905C32A7EEBF000CD0337 /* BackupInfo.swift in Sources */, AE783A072AB4F7C7005F0CBA /* FeeView.swift in Sources */, AE2B8C1D2A9678C900815B2F /* FeeService.swift in Sources */, + AE8D001C2D19F1760029C4C9 /* UIScreen+Extensions.swift in Sources */, AEC2CF5A2ABFBA19008065E4 /* BuildTransactionViewModel.swift in Sources */, AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */, AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */, @@ -1034,14 +1036,6 @@ kind = branch; }; }; - AEEA24552D136898000C1694 /* XCRemoteSwiftPackageReference "bdk-swift" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/bitcoindevkit/bdk-swift.git"; - requirement = { - kind = exactVersion; - version = "1.0.0-beta.6"; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1071,10 +1065,6 @@ package = AE7D5A0C2A7EE62200EAC8CE /* XCRemoteSwiftPackageReference "KeychainAccess" */; productName = KeychainAccess; }; - AEA1F6422CE43702004EC538 /* BitcoinDevKit */ = { - isa = XCSwiftPackageProductDependency; - productName = BitcoinDevKit; - }; AEAF83B52B7BD4D10019B23B /* CodeScanner */ = { isa = XCSwiftPackageProductDependency; package = AEAF83B42B7BD4D10019B23B /* XCRemoteSwiftPackageReference "CodeScanner" */; @@ -1089,11 +1079,6 @@ isa = XCSwiftPackageProductDependency; productName = BitcoinDevKit; }; - AEEA24562D136898000C1694 /* BitcoinDevKit */ = { - isa = XCSwiftPackageProductDependency; - package = AEEA24552D136898000C1694 /* XCRemoteSwiftPackageReference "bdk-swift" */; - productName = BitcoinDevKit; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = AE4984702A1BBBD6009951E2 /* Project object */; diff --git a/BDKSwiftExampleWallet/Extensions/BDK+Extensions/UIScreen+Extensions.swift b/BDKSwiftExampleWallet/Extensions/BDK+Extensions/UIScreen+Extensions.swift new file mode 100644 index 00000000..b3f3f262 --- /dev/null +++ b/BDKSwiftExampleWallet/Extensions/BDK+Extensions/UIScreen+Extensions.swift @@ -0,0 +1,17 @@ +// +// UIScreen+Extensions.swift +// BDKSwiftExampleWallet +// +// Created by Matthew Ramsden on 12/23/24. +// + +import Foundation +import UIKit + +extension UIScreen { + static let iPhoneSEHeight: CGFloat = 667 + + var isPhoneSE: Bool { + self.bounds.height <= UIScreen.iPhoneSEHeight + } +} diff --git a/BDKSwiftExampleWallet/View/OnboardingView.swift b/BDKSwiftExampleWallet/View/OnboardingView.swift index 8c9bf618..c04e9558 100644 --- a/BDKSwiftExampleWallet/View/OnboardingView.swift +++ b/BDKSwiftExampleWallet/View/OnboardingView.swift @@ -16,6 +16,9 @@ struct OnboardingView: View { @State private var showingImportView = false @State private var showingScanner = false let pasteboard = UIPasteboard.general + var isSmallDevice: Bool { + UIScreen.main.isPhoneSE + } var body: some View { @@ -25,7 +28,7 @@ struct OnboardingView: View { VStack { - HStack { + HStack(alignment: .center, spacing: 40) { Spacer() @@ -38,7 +41,6 @@ struct OnboardingView: View { } .tint(.secondary) .font(.title) - .padding() Button { if let clipboardContent = UIPasteboard.general.string { @@ -50,7 +52,6 @@ struct OnboardingView: View { } .tint(.secondary) .font(.title) - .padding() } else { Button { viewModel.words = "" @@ -60,19 +61,25 @@ struct OnboardingView: View { } .tint(.primary) .font(.title) - .padding() } } + .padding() Spacer() - VStack(spacing: 25) { + VStack( + spacing: isSmallDevice ? 5 : 25 + ) { Image(systemName: "bitcoinsign.circle") .resizable() .foregroundStyle( .secondary ) - .frame(width: 100, height: 100, alignment: .center) + .frame( + width: isSmallDevice ? 40 : 100, + height: isSmallDevice ? 40 : 100, + alignment: .center + ) Text("powered by Bitcoin Dev Kit") .foregroundStyle( LinearGradient( @@ -138,7 +145,9 @@ struct OnboardingView: View { usePaging: true, wordsPerPage: 4 ) - .frame(height: 200) + .frame( + height: isSmallDevice ? 150 : 200 + ) .padding() } } diff --git a/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift b/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift index cb958c32..931e6bcd 100644 --- a/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift +++ b/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift @@ -13,6 +13,9 @@ struct ReceiveView: View { @Bindable var viewModel: ReceiveViewModel @State private var isCopied = false @State private var showCheckmark = false + var isSmallDevice: Bool { + UIScreen.main.isPhoneSE + } var body: some View { @@ -37,12 +40,12 @@ struct ReceiveView: View { VStack(spacing: 8) { Image("bitcoinsign.arrow.down") .symbolRenderingMode(.hierarchical) - .font(.title) + .font(isSmallDevice ? .caption : .title) Text("Receive") .fontWeight(.semibold) } .font(.caption) - .padding(.top, 40.0) + .padding(.top, isSmallDevice ? 20.0 : 40.0) Spacer() @@ -59,18 +62,11 @@ struct ReceiveView: View { AddressFormattedView( address: viewModel.address, columns: 4, - spacing: 20.0, + spacing: isSmallDevice ? 5.0 : 20.0, gridItemSize: 60.0 ) .padding() - // Button { - // viewModel.startNFCSession() - // } label: { - // Image(systemName: "wave.3.right") - // .foregroundColor(.primary) - // } - HStack { Button { UIPasteboard.general.string = viewModel.address diff --git a/BDKSwiftExampleWallet/View/Send/AmountView.swift b/BDKSwiftExampleWallet/View/Send/AmountView.swift index fb02e2d6..09070c14 100644 --- a/BDKSwiftExampleWallet/View/Send/AmountView.swift +++ b/BDKSwiftExampleWallet/View/Send/AmountView.swift @@ -13,6 +13,9 @@ struct AmountView: View { @Binding var navigationPath: NavigationPath @State var numpadAmount = "0" let address: String + var isSmallDevice: Bool { + UIScreen.main.isPhoneSE + } var body: some View { @@ -47,8 +50,10 @@ struct AmountView: View { } GeometryReader { geometry in - let buttonSize = geometry.size.width / 4 - VStack(spacing: buttonSize / 10) { + let buttonDivider: CGFloat = isSmallDevice ? 5 : 4 + let buttonSize = geometry.size.width / buttonDivider + let spacingDivider: CGFloat = isSmallDevice ? 12 : 10 + VStack(spacing: buttonSize / spacingDivider) { numpadRow(["1", "2", "3"], buttonSize: buttonSize) numpadRow(["4", "5", "6"], buttonSize: buttonSize) numpadRow(["7", "8", "9"], buttonSize: buttonSize) @@ -56,7 +61,7 @@ struct AmountView: View { } .frame(maxWidth: .infinity) } - .frame(height: 300) + .frame(height: isSmallDevice ? 200 : 300) Spacer() diff --git a/BDKSwiftExampleWallet/View/Settings/SettingsView.swift b/BDKSwiftExampleWallet/View/Settings/SettingsView.swift index 9fb0fef3..df1aab97 100644 --- a/BDKSwiftExampleWallet/View/Settings/SettingsView.swift +++ b/BDKSwiftExampleWallet/View/Settings/SettingsView.swift @@ -15,6 +15,9 @@ struct SettingsView: View { @State private var isSeedPresented = false @State private var showingDeleteSeedConfirmation = false @State private var showingShowSeedConfirmation = false + var isSmallDevice: Bool { + UIScreen.main.isPhoneSE + } var body: some View { @@ -108,7 +111,7 @@ struct SettingsView: View { } .sheet(isPresented: $isSeedPresented) { WalletRecoveryView(viewModel: .init()) - .presentationDetents([.medium, .large]) + .presentationDetents(isSmallDevice ? [.large] : [.medium, .large]) .presentationDragIndicator(.visible) } .alert(