Skip to content

Commit 9f15beb

Browse files
committed
๐Ÿ’„ :: [#13] ํšŒ์›๊ฐ€์ž… ์ธ์ฆ์ฝ”๋“œ ๋ฐœ์†ก ๋ฒ„ํŠผ ์ถ”๊ฐ€
1 parent 3e6ef5a commit 9f15beb

2 files changed

Lines changed: 52 additions & 18 deletions

File tree

โ€ŽProjects/App/Sources/Feature/AuthFeature/InfoInputFeature/View/InfoInputView.swiftโ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import SwiftUI
1010

11-
import SwiftUI
12-
1311
struct InfoInputView: View {
1412
@StateObject var authViewModel: AuthViewModel
1513
@State var nameTextField: String = ""
@@ -63,7 +61,7 @@ struct InfoInputView: View {
6361
"ํ•™๋ฒˆ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”",
6462
text: $schoolNumberTextField,
6563
title: "ํ•™๋ฒˆ",
66-
errorText: "ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. (์˜ˆ: 2312)",
64+
errorText: "ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. (์˜ˆ: 3314)",
6765
isError: schoolNumberIsError
6866
)
6967
.onChange(of: schoolNumberTextField) { newValue in
@@ -77,7 +75,7 @@ struct InfoInputView: View {
7775
"๊ธฐ์ˆ™์‚ฌ ํ˜ธ์‹ค์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”",
7876
text: $domitoryRoomTextField,
7977
title: "ํ˜ธ์‹ค",
80-
errorText: "ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. (์˜ˆ: 315)",
78+
errorText: "ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. (์˜ˆ: 415)",
8179
isError: domitoryRoomIsError
8280
)
8381
.onChange(of: domitoryRoomTextField) { newValue in

โ€ŽProjects/App/Sources/Feature/AuthFeature/SignUpFeature/View/SignUpView.swiftโ€Ž

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
ย (0)