Skip to content

Commit 5af5ed4

Browse files
authored
ui: onboarding
1 parent ca5a22f commit 5af5ed4

File tree

1 file changed

+63
-45
lines changed

1 file changed

+63
-45
lines changed

BDKSwiftExampleWallet/View/OnboardingView.swift

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ struct OnboardingView: View {
1919
var isSmallDevice: Bool {
2020
UIScreen.main.isPhoneSE
2121
}
22+
@State private var animateContent = false
2223

2324
var body: some View {
24-
2525
ZStack {
2626
Color(uiColor: .systemBackground)
2727
.ignoresSafeArea()
2828

2929
VStack {
30-
3130
HStack(alignment: .center, spacing: 40) {
32-
3331
Spacer()
3432

3533
if viewModel.words.isEmpty {
@@ -41,6 +39,12 @@ struct OnboardingView: View {
4139
}
4240
.tint(.secondary)
4341
.font(.title)
42+
.opacity(animateContent ? 1 : 0)
43+
.offset(x: animateContent ? 0 : 100)
44+
.animation(
45+
.spring(response: 0.6, dampingFraction: 0.7).delay(1.2),
46+
value: animateContent
47+
)
4448

4549
Button {
4650
if let clipboardContent = UIPasteboard.general.string {
@@ -52,6 +56,12 @@ struct OnboardingView: View {
5256
}
5357
.tint(.secondary)
5458
.font(.title)
59+
.opacity(animateContent ? 1 : 0)
60+
.offset(x: animateContent ? 0 : 100)
61+
.animation(
62+
.spring(response: 0.6, dampingFraction: 0.7).delay(1.3),
63+
value: animateContent
64+
)
5565
} else {
5666
Button {
5767
viewModel.words = ""
@@ -67,28 +77,26 @@ struct OnboardingView: View {
6777

6878
Spacer()
6979

70-
VStack(
71-
spacing: isSmallDevice ? 5 : 25
72-
) {
80+
VStack(spacing: isSmallDevice ? 5 : 25) {
7381
Image(systemName: "bitcoinsign.circle")
7482
.resizable()
75-
.foregroundStyle(
76-
.secondary
77-
)
83+
.foregroundStyle(.secondary)
7884
.frame(
7985
width: isSmallDevice ? 40 : 100,
8086
height: isSmallDevice ? 40 : 100,
8187
alignment: .center
8288
)
89+
.scaleEffect(animateContent ? 1 : 0)
90+
.opacity(animateContent ? 1 : 0)
91+
.animation(
92+
.spring(response: 0.6, dampingFraction: 0.5, blendDuration: 0.6),
93+
value: animateContent
94+
)
95+
8396
Text("powered by Bitcoin Dev Kit")
8497
.foregroundStyle(
8598
LinearGradient(
86-
gradient: Gradient(
87-
colors: [
88-
.secondary,
89-
.primary,
90-
]
91-
),
99+
gradient: Gradient(colors: [.secondary, .primary]),
92100
startPoint: .topLeading,
93101
endPoint: .bottomTrailing
94102
)
@@ -97,39 +105,41 @@ struct OnboardingView: View {
97105
.fontWeight(.medium)
98106
.multilineTextAlignment(.center)
99107
.padding()
108+
.opacity(animateContent ? 1 : 0)
109+
.animation(.easeOut(duration: 0.5).delay(0.6), value: animateContent)
100110
}
101111
.padding()
102112

103-
Picker(
104-
"Network",
105-
selection: $viewModel.selectedNetwork
106-
) {
107-
Text("Signet").tag(Network.signet)
108-
Text("Testnet").tag(Network.testnet)
109-
}
110-
.pickerStyle(.automatic)
111-
.tint(.primary)
112-
.accessibilityLabel("Select Bitcoin Network")
113-
114-
Picker(
115-
"Esplora Server",
116-
selection: $viewModel.selectedURL
117-
) {
118-
ForEach(viewModel.availableURLs, id: \.self) { url in
119-
Text(
120-
url.replacingOccurrences(
121-
of: "https://",
122-
with: ""
123-
).replacingOccurrences(
124-
of: "http://",
125-
with: ""
113+
Group {
114+
Picker("Network", selection: $viewModel.selectedNetwork) {
115+
Text("Signet").tag(Network.signet)
116+
Text("Testnet").tag(Network.testnet)
117+
}
118+
.pickerStyle(.automatic)
119+
.tint(.primary)
120+
.accessibilityLabel("Select Bitcoin Network")
121+
.opacity(animateContent ? 1 : 0)
122+
.animation(.easeOut(duration: 0.5).delay(1.5), value: animateContent)
123+
124+
Picker("Esplora Server", selection: $viewModel.selectedURL) {
125+
ForEach(viewModel.availableURLs, id: \.self) { url in
126+
Text(
127+
url.replacingOccurrences(
128+
of: "https://",
129+
with: ""
130+
).replacingOccurrences(
131+
of: "http://",
132+
with: ""
133+
)
126134
)
127-
)
128-
.tag(url)
135+
.tag(url)
136+
}
129137
}
138+
.pickerStyle(.automatic)
139+
.tint(.primary)
140+
.opacity(animateContent ? 1 : 0)
141+
.animation(.easeOut(duration: 0.5).delay(1.5), value: animateContent)
130142
}
131-
.pickerStyle(.automatic)
132-
.tint(.primary)
133143

134144
if !viewModel.words.isEmpty {
135145
if viewModel.isDescriptor || viewModel.isXPub {
@@ -165,9 +175,13 @@ struct OnboardingView: View {
165175
)
166176
)
167177
.padding()
168-
178+
.opacity(animateContent ? 1 : 0)
179+
.offset(y: animateContent ? 0 : 50)
180+
.animation(
181+
.spring(response: 0.6, dampingFraction: 0.7).delay(1.2),
182+
value: animateContent
183+
)
169184
}
170-
171185
}
172186
.alert(isPresented: $showingOnboardingViewErrorAlert) {
173187
Alert(
@@ -196,7 +210,11 @@ struct OnboardingView: View {
196210
pasteAction: {}
197211
)
198212
}
199-
213+
.onAppear {
214+
withAnimation {
215+
animateContent = true
216+
}
217+
}
200218
}
201219
}
202220

0 commit comments

Comments
 (0)