@@ -20,17 +20,6 @@ struct SignUpView: View {
2020 @State var passwordCheckIsError : Bool = false
2121 @State var authenticationSuccess : Bool = false
2222
23- private var computedEmailError : Bool {
24- !emailTextField. isEmpty && !Validator. isValidEmail ( emailTextField)
25- }
26-
27- private var computedPasswordError : Bool {
28- !passwordTextField. isEmpty && !Validator. isValidPassword ( passwordTextField)
29- }
30-
31- private var computedPasswordCheckError : Bool {
32- !passwordCheckTextField. isEmpty && passwordTextField != passwordCheckTextField
33- }
3423
3524 var body : some View {
3625 VStack ( spacing: 0 ) {
@@ -59,7 +48,7 @@ struct SignUpView: View {
5948 text: $emailTextField,
6049 title: " ์ด๋ฉ์ผ " ,
6150 errorText: " ์ด๋ฉ์ผ ํ์์ด ๋ง์ง ์์ต๋๋ค. " ,
62- isError: computedEmailError
51+ isError: Validator . hasEmailError ( emailTextField )
6352 )
6453 . padding ( . leading, 26 )
6554 . padding ( . trailing, 8 )
@@ -84,6 +73,13 @@ struct SignUpView: View {
8473 }
8574 . padding ( . top, 72 )
8675
76+ WasherButton (
77+ text: " ์ธ์ฆ๋ฒํธ ๋ฐ์ก " ,
78+ horizontalPadding: 26
79+ )
80+ . disabled ( emailTextField. isEmpty || Validator . hasEmailError ( emailTextField) )
81+ . padding ( . top, 34 )
82+
8783 HStack ( alignment: . bottom, spacing: 10 ) {
8884 WasherTextField (
8985 " ์ธ์ฆ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์ " ,
@@ -122,7 +118,7 @@ struct SignUpView: View {
122118 text: $passwordTextField,
123119 title: " ๋น๋ฐ๋ฒํธ " ,
124120 errorText: " ๋น๋ฐ๋ฒํธ๋ 8~16์, ํน์๋ฌธ์ ํฌํจ ํ์ " ,
125- isError: computedPasswordError ,
121+ isError: Validator . hasPasswordError ( passwordTextField ) ,
126122 isSecure: true
127123 )
128124 . padding ( . top, 34 )
@@ -136,16 +132,56 @@ struct SignUpView: View {
136132 isSecure: true
137133 )
138134 . onChange ( of: passwordCheckTextField) { _ in
139- passwordCheckIsError = computedPasswordCheckError
135+ passwordCheckIsError = Validator . hasPasswordCheckError ( passwordTextField , passwordCheckTextField )
140136 }
141137 . padding ( . top, 8 )
142138 . padding ( . horizontal, 26 )
143139
144140 Spacer ( )
141+
142+ Rectangle ( )
143+ . frame ( height: 2 )
144+ . color ( . gray50)
145+
146+ WasherButton (
147+ text: " ์๋ฃ " ,
148+ horizontalPadding: 26
149+ ) { }
150+ . disabled ( !Validator. isSignUpFormValid (
151+ email: emailTextField,
152+ password: passwordTextField,
153+ passwordCheck: passwordCheckTextField
154+ ) )
155+ . padding ( . top, 10 )
156+ . padding ( . bottom, 30 )
145157 }
146158 }
147159}
148160
161+ extension Validator {
162+ static func hasEmailError( _ email: String ) -> Bool {
163+ !email. isEmpty && !isValidEmail( email)
164+ }
165+
166+ static func hasPasswordError( _ password: String ) -> Bool {
167+ !password. isEmpty && !isValidPassword( password)
168+ }
169+
170+ static func hasPasswordCheckError( _ password: String , _ passwordCheck: String ) -> Bool {
171+ !passwordCheck. isEmpty && password != passwordCheck
172+ }
173+
174+ static func isSignUpFormValid( email: String , password: String , passwordCheck: String ) -> Bool {
175+ isValidEmail ( email) &&
176+ isValidPassword ( password) &&
177+ password == passwordCheck &&
178+ !email. isEmpty &&
179+ !password. isEmpty &&
180+ !passwordCheck. isEmpty
181+ }
182+ }
183+
184+
149185#Preview {
150186 SignUpView ( authViewModel: AuthViewModel ( ) )
151187}
0 commit comments