-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnboardingView.swift
More file actions
172 lines (147 loc) · 4.96 KB
/
OnboardingView.swift
File metadata and controls
172 lines (147 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//
// Copyright © 2023 Alexander Romanov
// OnboardingView.swift, created on 25.09.2023
//
import FactoryKit
import OversizeServices
import OversizeUI
import SwiftUI
struct OnboardingView: View {
@Injected(\.appStateService) var appStateService: AppStateService
@Environment(\.screenSize) var screenSize: ScreenSize
@Environment(\.verticalSizeClass) var verticalSizeClass: UserInterfaceSizeClass?
@Environment(\.horizontalSizeClass) var horizontalSizeClass: UserInterfaceSizeClass?
var body: some View {
if horizontalSizeClass == .compact, verticalSizeClass == .regular {
phoneRegular
} else if horizontalSizeClass == .regular, verticalSizeClass == .compact {
phoneCompact
} else {
ipad
}
}
var phoneRegular: some View {
ZStack {
VStack {
Spacer()
Image("OnbardingBackground", bundle: .main)
Spacer()
VStack(spacing: .medium) {
Text("Welcome to\nExample")
.largeTitle()
.onBackgroundPrimaryForeground()
Text("Welcome text")
.title2(.semibold)
.onBackgroundSecondaryForeground()
}
.paddingContent(.horizontal)
.multilineTextAlignment(.center)
Spacer()
Button("Contine") {
appStateService.completedOnbarding()
}
.buttonStyle(.primary)
.accent()
.paddingContent(.bottom)
.paddingContent(.horizontal)
.elevation(.z2)
}
// VStack {
//
// Spacer()
// Image("OnbardingBackground", bundle: .main)
// Spacer()
// }
}
.ignoresSafeArea(edges: .top)
.background {
Color.backgroundSecondary.ignoresSafeArea()
}
}
var phoneCompact: some View {
HStack(spacing: .zero) {
Image("OnbardingBackground", bundle: .main)
Divider()
VStack {
Spacer()
VStack(spacing: .medium) {
Text("Welcome to\nExample")
.largeTitle()
.onBackgroundPrimaryForeground()
Text("Welcome text")
.title2(.semibold)
.onBackgroundSecondaryForeground()
}
.paddingContent(.horizontal)
.multilineTextAlignment(.center)
Spacer()
HStack {
Spacer()
Button("Contine") {
appStateService.completedOnbarding()
}
.buttonStyle(.primary)
.accent()
.elevation(.z2)
.frame(maxWidth: 300)
.paddingContent(.horizontal)
.paddingContent(.bottom)
Spacer()
}
}
}
.background {
Color.backgroundSecondary.ignoresSafeArea()
}
}
var ipad: some View {
ZStack {
VStack {
VStack {}
.frame(maxHeight: screenSize.height < 1000 ? 320 : 490)
Spacer()
VStack(spacing: .medium) {
Text("Example")
.largeTitle()
.onBackgroundPrimaryForeground()
Text("Welcome text")
.title2(.semibold)
.onBackgroundSecondaryForeground()
}
.paddingContent(.horizontal)
.multilineTextAlignment(.center)
Spacer()
Button("Contine") {
appStateService.completedOnbarding()
}
.buttonStyle(.primary)
.accent()
.paddingContent(.bottom)
.paddingContent(.horizontal)
.elevation(.z2)
}
VStack {
Surface {
Image("OnbardingBackground", bundle: .main)
.offset(y: -44)
.frame(width: screenSize.height < 1000 ? 320 : 490, height: screenSize.height < 1000 ? 320 : 490)
.cornerRadius(.xLarge)
.clipped()
}
.elevation(.z2)
.surfaceContentMargins(.zero)
.controlRadius(.xLarge)
.padding(.top, .large)
Spacer()
}
}
.background {
Color.backgroundSecondary.ignoresSafeArea()
}
}
}
struct OnboardingView_Previews: PreviewProvider {
static var previews: some View {
OnboardingView()
}
}