Skip to content

Commit

Permalink
✨[FEAT] : #139 닉네임프로필뷰 실제 로직 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Oct 9, 2021
1 parent 215b47a commit 5cea0e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/JoinVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ class JoinVC: UIViewController {
self.showView(number: 4)
self.moveCar(toPage: 4)
}

profileView.stickyNextButton.nextPageClosure = {
self.showView(number: 4)
self.moveCar(toPage: 4)
if self.profileView.isNicknamePassed {
self.showView(number: 4)
self.moveCar(toPage: 4)
}
}

contractView.nextButton.nextPageClosure = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit

class JoinProfileView: UIView, UITextFieldDelegate {

var isNicknamePassed = false

//MARK: - UI Variables
var profileLabel = JoinTitleLabel(type: .boldTitle, title: "프로필 사진")
Expand Down Expand Up @@ -87,6 +88,7 @@ class JoinProfileView: UIView, UITextFieldDelegate {
$0.leading.trailing.equalTo(profileLabel)
}

makeButtonsGray()

self.dismissKeyboardWhenTappedAround()

Expand All @@ -108,11 +110,15 @@ class JoinProfileView: UIView, UITextFieldDelegate {
private func makeButtonsBlue() {
nextButton.backgroundColor = .mainBlue
stickyNextButton.backgroundColor = .mainBlue
nextButton.isEnabled = true
stickyNextButton.isEnabled = true
}

private func makeButtonsGray() {
nextButton.backgroundColor = .gray30
stickyNextButton.backgroundColor = .gray30
nextButton.isEnabled = false
stickyNextButton.isEnabled = false
}

private func isOnlyHanguel(text: String) -> Bool {
Expand Down Expand Up @@ -140,17 +146,27 @@ class JoinProfileView: UIView, UITextFieldDelegate {
func textFieldDidEndEditing(_ textField: UITextField) {
//이것도 Rx로 해야할까나 ...
if textField.text == "" {
isNicknamePassed = false
self.makeButtonsGray()
nicknameView.setOrangeTFLabelColorWithText(text: "닉네임을 작성해주세요.")
} else if textField.text!.count > 5 {
isNicknamePassed = false
self.makeButtonsGray()
nicknameView.setOrangeTFLabelColorWithText(text: "5자 이내로 작성해주세요.")
} else if !isOnlyHanguel(text: textField.text!) {
isNicknamePassed = false
self.makeButtonsGray()
nicknameView.setOrangeTFLabelColorWithText(text: "한글만 사용해주세요.")
}
else {
self.IsDuplicatedNickname(nickname: (self.nicknameView.inputTextField?.text!)!)
}
}

func textFieldDidChangeSelection(_ textField: UITextField) {
isNicknamePassed = false
}


//MARK: - 서버 연결 함수
private func IsDuplicatedNickname(nickname: String) {
Expand All @@ -159,8 +175,9 @@ class JoinProfileView: UIView, UITextFieldDelegate {
switch(response)
{
case .success(_):
self.nicknameView.setBlueTFLabelColorWithText(text: "사용 가능한 닉네임입니다.")
self.isNicknamePassed = true
self.makeButtonsBlue()
self.nicknameView.setBlueTFLabelColorWithText(text: "사용 가능한 닉네임입니다.")
case .requestErr(let message) :
print("requestERR", message)
case .pathErr :
Expand Down

0 comments on commit 5cea0e2

Please sign in to comment.