Skip to content

Commit 1c2b4fc

Browse files
authored
ui: fix for iphone se device
1 parent 2d08f6e commit 1c2b4fc

File tree

6 files changed

+55
-40
lines changed

6 files changed

+55
-40
lines changed

BDKSwiftExampleWallet.xcodeproj/project.pbxproj

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
AE7F67092A7451AA00CED561 /* Price.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7F67082A7451AA00CED561 /* Price.swift */; };
6767
AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7F670B2A7451D700CED561 /* CurrencyCode.swift */; };
6868
AE83EFDB2C9D07B200B41244 /* ChainPosition+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE83EFDA2C9D07B200B41244 /* ChainPosition+Extensions.swift */; };
69+
AE8D001C2D19F1760029C4C9 /* UIScreen+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */; };
6970
AE91CEED2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */; };
7071
AE91CEEF2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */; };
7172
AE96F6622A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */; };
72-
AEA1F6432CE43702004EC538 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEA1F6422CE43702004EC538 /* BitcoinDevKit */; };
7373
AEAB03112ABDDB86000C9528 /* FeeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03102ABDDB86000C9528 /* FeeViewModel.swift */; };
7474
AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03122ABDDBF4000C9528 /* AmountViewModel.swift */; };
7575
AEAF83B62B7BD4D10019B23B /* CodeScanner in Frameworks */ = {isa = PBXBuildFile; productRef = AEAF83B52B7BD4D10019B23B /* CodeScanner */; };
@@ -90,7 +90,6 @@
9090
AEE6C74C2ABCB3E200442ADD /* Transaction+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE6C74B2ABCB3E200442ADD /* Transaction+Extensions.swift */; };
9191
AEE6C74F2ABCBA4600442ADD /* WalletSyncState.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE6C74E2ABCBA4600442ADD /* WalletSyncState.swift */; };
9292
AEE83A492C07F54B00834468 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEE83A482C07F54B00834468 /* BitcoinDevKit */; };
93-
AEEA24572D136898000C1694 /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEEA24562D136898000C1694 /* BitcoinDevKit */; };
9493
/* End PBXBuildFile section */
9594

9695
/* Begin PBXContainerItemProxy section */
@@ -161,6 +160,7 @@
161160
AE7F67082A7451AA00CED561 /* Price.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Price.swift; sourceTree = "<group>"; };
162161
AE7F670B2A7451D700CED561 /* CurrencyCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyCode.swift; sourceTree = "<group>"; };
163162
AE83EFDA2C9D07B200B41244 /* ChainPosition+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChainPosition+Extensions.swift"; sourceTree = "<group>"; };
163+
AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScreen+Extensions.swift"; sourceTree = "<group>"; };
164164
AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentAndReceivedValues+Extensions.swift"; sourceTree = "<group>"; };
165165
AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CanonicalTx+Extensions.swift"; sourceTree = "<group>"; };
166166
AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSwiftExampleWalletReceiveViewModelTests.swift; sourceTree = "<group>"; };
@@ -521,6 +521,7 @@
521521
AE184EFB2BFE52C800374362 /* Amount+Extensions.swift */,
522522
AE91CEEC2C0FDB70000AAD20 /* SentAndReceivedValues+Extensions.swift */,
523523
AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */,
524+
AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */,
524525
);
525526
path = "BDK+Extensions";
526527
sourceTree = "<group>";
@@ -654,6 +655,7 @@
654655
AEB905C32A7EEBF000CD0337 /* BackupInfo.swift in Sources */,
655656
AE783A072AB4F7C7005F0CBA /* FeeView.swift in Sources */,
656657
AE2B8C1D2A9678C900815B2F /* FeeService.swift in Sources */,
658+
AE8D001C2D19F1760029C4C9 /* UIScreen+Extensions.swift in Sources */,
657659
AEC2CF5A2ABFBA19008065E4 /* BuildTransactionViewModel.swift in Sources */,
658660
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */,
659661
AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */,
@@ -1034,14 +1036,6 @@
10341036
kind = branch;
10351037
};
10361038
};
1037-
AEEA24552D136898000C1694 /* XCRemoteSwiftPackageReference "bdk-swift" */ = {
1038-
isa = XCRemoteSwiftPackageReference;
1039-
repositoryURL = "https://github.com/bitcoindevkit/bdk-swift.git";
1040-
requirement = {
1041-
kind = exactVersion;
1042-
version = "1.0.0-beta.6";
1043-
};
1044-
};
10451039
/* End XCRemoteSwiftPackageReference section */
10461040

10471041
/* Begin XCSwiftPackageProductDependency section */
@@ -1071,10 +1065,6 @@
10711065
package = AE7D5A0C2A7EE62200EAC8CE /* XCRemoteSwiftPackageReference "KeychainAccess" */;
10721066
productName = KeychainAccess;
10731067
};
1074-
AEA1F6422CE43702004EC538 /* BitcoinDevKit */ = {
1075-
isa = XCSwiftPackageProductDependency;
1076-
productName = BitcoinDevKit;
1077-
};
10781068
AEAF83B52B7BD4D10019B23B /* CodeScanner */ = {
10791069
isa = XCSwiftPackageProductDependency;
10801070
package = AEAF83B42B7BD4D10019B23B /* XCRemoteSwiftPackageReference "CodeScanner" */;
@@ -1089,11 +1079,6 @@
10891079
isa = XCSwiftPackageProductDependency;
10901080
productName = BitcoinDevKit;
10911081
};
1092-
AEEA24562D136898000C1694 /* BitcoinDevKit */ = {
1093-
isa = XCSwiftPackageProductDependency;
1094-
package = AEEA24552D136898000C1694 /* XCRemoteSwiftPackageReference "bdk-swift" */;
1095-
productName = BitcoinDevKit;
1096-
};
10971082
/* End XCSwiftPackageProductDependency section */
10981083
};
10991084
rootObject = AE4984702A1BBBD6009951E2 /* Project object */;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// UIScreen+Extensions.swift
3+
// BDKSwiftExampleWallet
4+
//
5+
// Created by Matthew Ramsden on 12/23/24.
6+
//
7+
8+
import Foundation
9+
import UIKit
10+
11+
extension UIScreen {
12+
static let iPhoneSEHeight: CGFloat = 667
13+
14+
var isPhoneSE: Bool {
15+
self.bounds.height <= UIScreen.iPhoneSEHeight
16+
}
17+
}

BDKSwiftExampleWallet/View/OnboardingView.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ struct OnboardingView: View {
1616
@State private var showingImportView = false
1717
@State private var showingScanner = false
1818
let pasteboard = UIPasteboard.general
19+
var isSmallDevice: Bool {
20+
UIScreen.main.isPhoneSE
21+
}
1922

2023
var body: some View {
2124

@@ -25,7 +28,7 @@ struct OnboardingView: View {
2528

2629
VStack {
2730

28-
HStack {
31+
HStack(alignment: .center, spacing: 40) {
2932

3033
Spacer()
3134

@@ -38,7 +41,6 @@ struct OnboardingView: View {
3841
}
3942
.tint(.secondary)
4043
.font(.title)
41-
.padding()
4244

4345
Button {
4446
if let clipboardContent = UIPasteboard.general.string {
@@ -50,7 +52,6 @@ struct OnboardingView: View {
5052
}
5153
.tint(.secondary)
5254
.font(.title)
53-
.padding()
5455
} else {
5556
Button {
5657
viewModel.words = ""
@@ -60,19 +61,25 @@ struct OnboardingView: View {
6061
}
6162
.tint(.primary)
6263
.font(.title)
63-
.padding()
6464
}
6565
}
66+
.padding()
6667

6768
Spacer()
6869

69-
VStack(spacing: 25) {
70+
VStack(
71+
spacing: isSmallDevice ? 5 : 25
72+
) {
7073
Image(systemName: "bitcoinsign.circle")
7174
.resizable()
7275
.foregroundStyle(
7376
.secondary
7477
)
75-
.frame(width: 100, height: 100, alignment: .center)
78+
.frame(
79+
width: isSmallDevice ? 40 : 100,
80+
height: isSmallDevice ? 40 : 100,
81+
alignment: .center
82+
)
7683
Text("powered by Bitcoin Dev Kit")
7784
.foregroundStyle(
7885
LinearGradient(
@@ -138,7 +145,9 @@ struct OnboardingView: View {
138145
usePaging: true,
139146
wordsPerPage: 4
140147
)
141-
.frame(height: 200)
148+
.frame(
149+
height: isSmallDevice ? 150 : 200
150+
)
142151
.padding()
143152
}
144153
}

BDKSwiftExampleWallet/View/Receive/ReceiveView.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ struct ReceiveView: View {
1313
@Bindable var viewModel: ReceiveViewModel
1414
@State private var isCopied = false
1515
@State private var showCheckmark = false
16+
var isSmallDevice: Bool {
17+
UIScreen.main.isPhoneSE
18+
}
1619

1720
var body: some View {
1821

@@ -37,12 +40,12 @@ struct ReceiveView: View {
3740
VStack(spacing: 8) {
3841
Image("bitcoinsign.arrow.down")
3942
.symbolRenderingMode(.hierarchical)
40-
.font(.title)
43+
.font(isSmallDevice ? .caption : .title)
4144
Text("Receive")
4245
.fontWeight(.semibold)
4346
}
4447
.font(.caption)
45-
.padding(.top, 40.0)
48+
.padding(.top, isSmallDevice ? 20.0 : 40.0)
4649

4750
Spacer()
4851

@@ -59,18 +62,11 @@ struct ReceiveView: View {
5962
AddressFormattedView(
6063
address: viewModel.address,
6164
columns: 4,
62-
spacing: 20.0,
65+
spacing: isSmallDevice ? 5.0 : 20.0,
6366
gridItemSize: 60.0
6467
)
6568
.padding()
6669

67-
// Button {
68-
// viewModel.startNFCSession()
69-
// } label: {
70-
// Image(systemName: "wave.3.right")
71-
// .foregroundColor(.primary)
72-
// }
73-
7470
HStack {
7571
Button {
7672
UIPasteboard.general.string = viewModel.address

BDKSwiftExampleWallet/View/Send/AmountView.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ struct AmountView: View {
1313
@Binding var navigationPath: NavigationPath
1414
@State var numpadAmount = "0"
1515
let address: String
16+
var isSmallDevice: Bool {
17+
UIScreen.main.isPhoneSE
18+
}
1619

1720
var body: some View {
1821

@@ -47,16 +50,18 @@ struct AmountView: View {
4750
}
4851

4952
GeometryReader { geometry in
50-
let buttonSize = geometry.size.width / 4
51-
VStack(spacing: buttonSize / 10) {
53+
let buttonDivider: CGFloat = isSmallDevice ? 5 : 4
54+
let buttonSize = geometry.size.width / buttonDivider
55+
let spacingDivider: CGFloat = isSmallDevice ? 12 : 10
56+
VStack(spacing: buttonSize / spacingDivider) {
5257
numpadRow(["1", "2", "3"], buttonSize: buttonSize)
5358
numpadRow(["4", "5", "6"], buttonSize: buttonSize)
5459
numpadRow(["7", "8", "9"], buttonSize: buttonSize)
5560
numpadRow([" ", "0", "<"], buttonSize: buttonSize)
5661
}
5762
.frame(maxWidth: .infinity)
5863
}
59-
.frame(height: 300)
64+
.frame(height: isSmallDevice ? 200 : 300)
6065

6166
Spacer()
6267

BDKSwiftExampleWallet/View/Settings/SettingsView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ struct SettingsView: View {
1515
@State private var isSeedPresented = false
1616
@State private var showingDeleteSeedConfirmation = false
1717
@State private var showingShowSeedConfirmation = false
18+
var isSmallDevice: Bool {
19+
UIScreen.main.isPhoneSE
20+
}
1821

1922
var body: some View {
2023

@@ -108,7 +111,7 @@ struct SettingsView: View {
108111
}
109112
.sheet(isPresented: $isSeedPresented) {
110113
WalletRecoveryView(viewModel: .init())
111-
.presentationDetents([.medium, .large])
114+
.presentationDetents(isSmallDevice ? [.large] : [.medium, .large])
112115
.presentationDragIndicator(.visible)
113116
}
114117
.alert(

0 commit comments

Comments
 (0)