Skip to content

Commit

Permalink
[Fix] sopt-makers#12 - 비밀번호의 조건을 맞추지 않아도 텍스트필드 색이 editing 모드로 변경되는 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Nov 30, 2022
1 parent 75219f7 commit 140d289
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public struct I18N {
public static let email = "이메일"
public static let emailTextFieldPlaceholder = "이메일을 입력해주세요."
public static let password = "비밀번호"
public static let passwordTextFieldPlaceholder = "영문, 숫자, 특수문자 포함 N자 이상 입력해주세요."
public static let passwordTextFieldPlaceholder = "영문, 숫자, 특수문자 포함 8-15자로 입력해주세요."
public static let passwordCheckTextFieldPlaceholder = "확인을 위해 비밀번호를 한 번 더 입력해주세요."
public static let register = "가입하기"
public static let duplicatedNickname = "사용 중인 이름입니다."
public static let invalidEmailForm = "잘못된 이메일 형식입니다."
public static let invalidPasswordForm = "영문, 숫자, 특수문자 포함 N자 이상이어야 합니다."
public static let invalidPasswordForm = "영문, 숫자, 특수문자 포함 8-15자로 입력해주세요."
public static let passwordNotAccord = "비밀번호가 일치하지 않습니다."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ public protocol SignUpUseCase {
func checkPassword(password: String)
func checkAccordPassword(firstPassword: String, secondPassword: String)

var isNicknameValid: PassthroughSubject<Bool, Error> { get set }
var isEmailFormValid: PassthroughSubject<Bool, Error> { get set }
var isPasswordFormValid: PassthroughSubject<Bool, Error> { get set }
var isAccordPassword: PassthroughSubject<Bool, Error> { get set }
var isNicknameValid: CurrentValueSubject<Bool, Error> { get set }
var isEmailFormValid: CurrentValueSubject<Bool, Error> { get set }
var isPasswordFormValid: CurrentValueSubject<Bool, Error> { get set }
var isAccordPassword: CurrentValueSubject<Bool, Error> { get set }
}

public class DefaultSignUpUseCase {

private let repository: SignUpRepositoryInterface
private var cancelBag = Set<AnyCancellable>()

public var isNicknameValid = PassthroughSubject<Bool, Error>()
public var isEmailFormValid = PassthroughSubject<Bool, Error>()
public var isPasswordFormValid = PassthroughSubject<Bool, Error>()
public var isAccordPassword = PassthroughSubject<Bool, Error>()
public var isNicknameValid = CurrentValueSubject<Bool, Error>(false)
public var isEmailFormValid = CurrentValueSubject<Bool, Error>(false)
public var isPasswordFormValid = CurrentValueSubject<Bool, Error>(false)
public var isAccordPassword = CurrentValueSubject<Bool, Error>(false)

public init(repository: SignUpRepositoryInterface) {
self.repository = repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ extension CustomTextFieldView {

/// textField의 state를 지정하여 자동으로 배경색과 테두리 색이 바뀌도록 설정
public func setTextFieldViewState(_ state: TextFieldViewState) {

var state = state
if state == .normal && textField.text?.count != 0 {
if state == .normal && (textField.isEditing || !textField.isEmpty) {
state = .editing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,20 @@ extension SignUpViewModel {
isEmailValid ? output.emailAlert.send("") : output.emailAlert.send(I18N.SignUp.invalidEmailForm)
}.store(in: cancelBag)

useCase.isPasswordFormValid.sink { event in
useCase.isPasswordFormValid.combineLatest(useCase.isAccordPassword).sink { event in
print("SignUpViewModel - completion: \(event)")
} receiveValue: { isPasswordValid in
isPasswordValid ? output.passwordAlert.send("") : output.passwordAlert.send(I18N.SignUp.invalidPasswordForm)
} receiveValue: { (isFormValid, isAccordValid) in
if !isFormValid && !isAccordValid {
output.passwordAlert.send(I18N.SignUp.invalidPasswordForm)
} else if !isFormValid && isAccordValid {
output.passwordAlert.send(I18N.SignUp.invalidPasswordForm)
} else if isFormValid && !isAccordValid {
output.passwordAlert.send(I18N.SignUp.passwordNotAccord)
} else {
output.passwordAlert.send("")
}
}.store(in: cancelBag)

useCase.isAccordPassword.sink { event in
print("SignUpViewModel - completion: \(event)")
} receiveValue: { isPasswordValid in
isPasswordValid ? output.passwordAlert.send("") : output.passwordAlert.send(I18N.SignUp.passwordNotAccord)
}.store(in: cancelBag)

useCase.isNicknameValid.combineLatest(
useCase.isEmailFormValid,
useCase.isPasswordFormValid,
Expand Down

0 comments on commit 140d289

Please sign in to comment.