@@ -10,7 +10,6 @@ import SwiftUI
1010// MARK: - Onboarding
1111
1212struct Onboarding : View {
13-
1413 @Environment ( \. presentationMode) var presentationMode : Binding < PresentationMode >
1514 @State var SlideGesture = CGSize . zero
1615 @State var SlideOne = false
@@ -22,154 +21,156 @@ struct Onboarding: View {
2221 var type : Int
2322
2423 var body : some View {
25- VStack {
26- NavigationLink ( destination: SearchAddress ( ) , isActive: $isEndOnboarding) {
27- EmptyView ( )
28- }
29- HStack {
24+ NavigationView {
25+ VStack {
26+ NavigationLink ( destination: SearchAddress ( ) , isActive: $isEndOnboarding) {
27+ EmptyView ( )
28+ }
29+ HStack {
30+ Spacer ( )
31+ Button ( action: {
32+ isEndOnboarding = true
33+ } , label: {
34+ Text ( " 건너뛰기 " )
35+ } ) . padding ( . trailing, 16 )
36+ . padding ( . top, 16 )
37+ . font ( . custom( " AppleSDGothicNeo " , size: 14 ) )
38+ . foregroundColor ( Color . GrayScale. _500)
39+ . isHidden ( type != 0 )
40+ }
3041 Spacer ( )
31- Button ( action: {
32- isEndOnboarding = true
33- } , label: {
34- Text ( " 건너뛰기 " )
35- } ) . padding ( . trailing, 16 )
36- . padding ( . top, 16 )
37- . font ( . custom( " AppleSDGothicNeo " , size: 14 ) )
38- . foregroundColor ( Color . GrayScale. _500)
39- . isHidden ( type != 0 )
40- }
41- Spacer ( )
42- ZStack {
43- Onboarding3 ( )
44- . offset ( x: SlideGesture . width)
45- . offset ( x: SlideTwo ? 0 : 500 )
46- . animation ( . spring( ) )
47-
48- . gesture (
49- DragGesture ( ) . onChanged { value in
50- self . SlideGesture = value. translation
51- }
52- . onEnded { _ in
53- if self . SlideGesture. width > 150 {
54- self . SlideTwo = false
55- self . SlideTwoPrevious = true
42+ ZStack {
43+ Onboarding3 ( )
44+ . offset ( x: SlideGesture . width)
45+ . offset ( x: SlideTwo ? 0 : 500 )
46+ . animation ( . spring( ) )
47+
48+ . gesture (
49+ DragGesture ( ) . onChanged { value in
50+ self . SlideGesture = value. translation
5651 }
57- self . SlideGesture = . zero
58- let impactMed = UIImpactFeedbackGenerator ( style: . medium)
59- impactMed. impactOccurred ( )
60- }
61- )
62-
63- Onboarding2 ( )
64- . offset ( x: SlideGesture . width)
65- . offset ( x: SlideOne ? 0 : 500 )
66- . offset ( x: SlideOnePrevious ? 500 : 0 )
67- . offset ( x: SlideTwo ? - 500 : 0 )
68- . animation ( . spring( ) )
69-
70- . gesture (
71- DragGesture ( ) . onChanged { value in
72- self . SlideGesture = value. translation
73- }
74- . onEnded { _ in
75- if self . SlideGesture. width < - 150 {
76- self . SlideOne = true
77- self . SlideTwo = true
52+ . onEnded { _ in
53+ if self . SlideGesture. width > 150 {
54+ self . SlideTwo = false
55+ self . SlideTwoPrevious = true
56+ }
57+ self . SlideGesture = . zero
58+ let impactMed = UIImpactFeedbackGenerator ( style: . medium)
59+ impactMed. impactOccurred ( )
7860 }
79-
80- if self . SlideGesture. width > 150 {
81- self . SlideOnePrevious = true
82- self . SlideOne = false
61+ )
62+
63+ Onboarding2 ( )
64+ . offset ( x: SlideGesture . width)
65+ . offset ( x: SlideOne ? 0 : 500 )
66+ . offset ( x: SlideOnePrevious ? 500 : 0 )
67+ . offset ( x: SlideTwo ? - 500 : 0 )
68+ . animation ( . spring( ) )
69+
70+ . gesture (
71+ DragGesture ( ) . onChanged { value in
72+ self . SlideGesture = value. translation
8373 }
84- self . SlideGesture = . zero
85- let impactMed = UIImpactFeedbackGenerator ( style: . medium)
86- impactMed. impactOccurred ( )
87- }
88- )
74+ . onEnded { _ in
75+ if self . SlideGesture. width < - 150 {
76+ self . SlideOne = true
77+ self . SlideTwo = true
78+ }
79+
80+ if self . SlideGesture. width > 150 {
81+ self . SlideOnePrevious = true
82+ self . SlideOne = false
83+ }
84+ self . SlideGesture = . zero
85+ let impactMed = UIImpactFeedbackGenerator ( style: . medium)
86+ impactMed. impactOccurred ( )
87+ }
88+ )
8989
90- Onboarding1 ( )
91- . offset ( x: SlideGesture . width)
92- . offset ( x: SlideOne ? - 500 : 0 )
90+ Onboarding1 ( )
91+ . offset ( x: SlideGesture . width)
92+ . offset ( x: SlideOne ? - 500 : 0 )
9393
94- . animation ( . spring( ) )
94+ . animation ( . spring( ) )
9595
96- . gesture (
97- DragGesture ( ) . onChanged { value in
98- self . SlideGesture = value. translation
99- }
100- . onEnded { _ in
101- if self . SlideGesture. width < - 150 {
102- self . SlideOne = true
103- self . SlideOnePrevious = false
96+ . gesture (
97+ DragGesture ( ) . onChanged { value in
98+ self . SlideGesture = value. translation
99+ }
100+ . onEnded { _ in
101+ if self . SlideGesture. width < - 150 {
102+ self . SlideOne = true
103+ self . SlideOnePrevious = false
104+ }
105+ self . SlideGesture = . zero
106+ let impactMed = UIImpactFeedbackGenerator ( style: . medium)
107+ impactMed. impactOccurred ( )
104108 }
105- self . SlideGesture = . zero
106- let impactMed = UIImpactFeedbackGenerator ( style: . medium)
107- impactMed. impactOccurred ( )
109+ )
110+ }
111+ Spacer ( )
112+ HStack {
113+ Circle ( )
114+ . frame ( width: 8 , height: 8 )
115+ . foregroundColor ( SlideOne ? Color . GrayScale. _200 : Color . Palette. primary)
116+ Circle ( )
117+ . frame ( width: 8 , height: 8 )
118+ . foregroundColor ( SlideOne && !SlideTwo ? Color . Palette. primary : Color . GrayScale. _200)
119+ Circle ( )
120+ . frame ( width: 8 , height: 8 )
121+ . foregroundColor ( SlideTwo ? Color . Palette. primary : Color . GrayScale. _200)
122+ }
123+ . padding ( . bottom, 28 )
124+ ZStack {
125+ Button ( action: {
126+ if type == 0 {
127+ self . isEndOnboarding = true
128+ } else {
129+ NotificationCenter . default. post ( name: . endAboutSticky, object: nil )
108130 }
109- )
110- }
111- Spacer ( )
112- HStack {
113- Circle ( )
114- . frame ( width: 8 , height: 8 )
115- . foregroundColor ( SlideOne ? Color . GrayScale. _200 : Color . Palette. primary)
116- Circle ( )
117- . frame ( width: 8 , height: 8 )
118- . foregroundColor ( SlideOne && !SlideTwo ? Color . Palette. primary : Color . GrayScale. _200)
119- Circle ( )
120- . frame ( width: 8 , height: 8 )
121- . foregroundColor ( SlideTwo ? Color . Palette. primary : Color . GrayScale. _200)
122- }
123- . padding ( . bottom, 28 )
124- ZStack {
125- Button ( action: {
126- if type == 0 {
127- self . isEndOnboarding = true
128- } else {
129- NotificationCenter . default. post ( name: . endAboutSticky, object: nil )
130- }
131- } , label: {
132- Text ( type == 0 ? " 시작하기 " : " 완료 " )
133- . font ( . custom( " AppleSDGothicNeo " , size: 17 ) )
134- . foregroundColor ( Color . white)
135- } )
136- . frame ( width: 160 , height: 60 )
137- . background ( Color . Palette. primary)
138- . cornerRadius ( 20 )
139- . animation ( . spring( ) )
140- . offset ( x: SlideTwo ? 0 : 500 )
141- . shadow ( color: Color ( " shadow " ) , radius: 24 , x: 0 , y: 4 )
142-
143- Button ( action: {
144- if !SlideOne {
145- self . SlideOne = true
146- self . SlideOnePrevious = false
147- } else if !SlideTwo {
148- self . SlideOne = true
149- self . SlideTwo = true
150- }
151- let impactMed = UIImpactFeedbackGenerator ( style: . medium)
152- impactMed. impactOccurred ( )
153- } , label: {
154- Text ( " 다음 " )
155- . font ( . custom( " AppleSDGothicNeo " , size: 17 ) )
156- . foregroundColor ( Color . Palette. primary)
157-
158- } )
159- . frame ( width: 160 , height: 60 )
160- . background ( Color . white)
161- . cornerRadius ( 20 )
162- . animation ( . spring( ) )
163- . offset ( x: SlideTwo ? - 500 : 0 )
164- . shadow ( color: Color ( " shadow " ) , radius: 24 , x: 0 , y: 4 )
131+ } , label: {
132+ Text ( type == 0 ? " 시작하기 " : " 완료 " )
133+ . font ( . custom( " AppleSDGothicNeo " , size: 17 ) )
134+ . foregroundColor ( Color . white)
135+ } )
136+ . frame ( width: 160 , height: 60 )
137+ . background ( Color . Palette. primary)
138+ . cornerRadius ( 20 )
139+ . animation ( . spring( ) )
140+ . offset ( x: SlideTwo ? 0 : 500 )
141+ . shadow ( color: Color ( " shadow " ) , radius: 24 , x: 0 , y: 4 )
142+
143+ Button ( action: {
144+ if !SlideOne {
145+ self . SlideOne = true
146+ self . SlideOnePrevious = false
147+ } else if !SlideTwo {
148+ self . SlideOne = true
149+ self . SlideTwo = true
150+ }
151+ let impactMed = UIImpactFeedbackGenerator ( style: . medium)
152+ impactMed. impactOccurred ( )
153+ } , label: {
154+ Text ( " 다음 " )
155+ . font ( . custom( " AppleSDGothicNeo " , size: 17 ) )
156+ . foregroundColor ( Color . Palette. primary)
157+
158+ } )
159+ . frame ( width: 160 , height: 60 )
160+ . background ( Color . white)
161+ . cornerRadius ( 20 )
162+ . animation ( . spring( ) )
163+ . offset ( x: SlideTwo ? - 500 : 0 )
164+ . shadow ( color: Color ( " shadow " ) , radius: 24 , x: 0 , y: 4 )
165+ }
166+ . padding ( . bottom, 32 )
165167 }
166- . padding ( . bottom, 32 )
167- }
168- . navigationBarHidden ( true )
169- . onReceive ( NotificationCenter . default. publisher ( for: . endAboutSticky) , perform: { _ in
168+ . navigationBarHidden ( true )
169+ . onReceive ( NotificationCenter . default. publisher ( for: . endAboutSticky) , perform: { _ in
170170
171- presentationMode. wrappedValue. dismiss ( )
172- } )
171+ presentationMode. wrappedValue. dismiss ( )
172+ } )
173+ }
173174 }
174175}
175176
0 commit comments