Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Feat: #28 - 회원가입 메인 UI 제작 #32

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMC/Sources/Presenter/Auth/SignIn/SignInViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ final class SignInViewController: BaseViewController {
let textField = CMCTextField(
placeHolder: "비밀번호를 입력해주세요",
textFieldSubTitle: "비밀번호",
accessoryType: .image(image: CMCAsset._24x24show.image),
accessoryType: .image(image: CMCAsset._24x24hide.image),
keyboardType: .emailAddress
)
textField.accessoryButton.setImage(CMCAsset._24x24hide.image, for: .selected)
textField.accessoryButton.setImage(CMCAsset._24x24show.image, for: .selected)
return textField
}()

Expand Down Expand Up @@ -225,7 +225,7 @@ final class SignInViewController: BaseViewController {
.observe(on: MainScheduler.instance)
.withUnretained(self)
.subscribe(onNext: { owner, state in
owner.passwordTextField.isSecureTextEntry = state
owner.passwordTextField.isSecureTextEntry = !state
})
.disposed(by: disposeBag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,209 @@
//

import Foundation

import RxCocoa
import RxGesture
import RxSwift

import DesignSystem
import SnapKit

import UIKit

final class MainSignUpView: BaseView {
// MARK: - UI

private lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.isScrollEnabled = true
return scrollView
}()

private lazy var mainContentView: UIView = {
let view = UIView()
return view
}()

private lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = "가입 정보를 입력해주세요"
label.font = DesignSystemFontFamily.Pretendard.bold.font(size: 26)
label.textColor = DesignSystemAsset.gray50.color
return label
}()

private lazy var emailTextField: CMCTextField = {
let textField = CMCTextField(
placeHolder: "이메일을 입력해주세요",
textFieldSubTitle: "이메일",
accessoryType: .button(title: "중복확인"),
keyboardType: .emailAddress
)
return textField
}()

private lazy var passwordTextField: CMCTextField = {
let textField = CMCTextField(
placeHolder: "비밀번호를 입력해주세요",
textFieldSubTitle: "비밀번호",
accessoryType: .image(image: CMCAsset._24x24hide.image),
keyboardType: .default
)
textField.accessoryButton.setImage(CMCAsset._24x24show.image, for: .selected)
return textField
}()

private lazy var confirmPasswordTextField: CMCTextField = {
let textField = CMCTextField(
placeHolder: "비밀번호를 입력해주세요",
textFieldSubTitle: "비밀번호 확인",
accessoryType: .image(image: CMCAsset._24x24hide.image),
keyboardType: .default
)
textField.accessoryButton.setImage(CMCAsset._24x24show.image, for: .selected)
return textField
}()

private lazy var nameTextField: CMCTextField = {
let textField = CMCTextField(
placeHolder: "이름을 입력해주세요",
textFieldSubTitle: "이름",
accessoryType: .none,
keyboardType: .default
)
return textField
}()


private lazy var nickNameTextField: CMCTextField = {
let textField = CMCTextField(
placeHolder: "닉네임을 입력해주세요",
textFieldSubTitle: "닉네임",
accessoryType: .none,
keyboardType: .default
)
return textField
}()

// MARK: - Properties
private var viewModel: MainSignUpViewModel
private var parentViewModel: SignUpViewModel


// MARK: - Initializers
init(
viewModel: MainSignUpViewModel,
parentViewModel: SignUpViewModel
) {
self.viewModel = viewModel
self.parentViewModel = parentViewModel
super.init(frame: .zero)
self.backgroundColor = CMCAsset.background.color
}


required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - LifeCycle

// MARK: - Methods

override func setAddSubView() {
self.addSubview(scrollView)
scrollView.addSubview(mainContentView)

mainContentView.addSubview(titleLabel)
mainContentView.addSubview(emailTextField)
mainContentView.addSubview(passwordTextField)
mainContentView.addSubview(confirmPasswordTextField)
mainContentView.addSubview(nameTextField)
mainContentView.addSubview(nickNameTextField)
}

override func setConstraint() {

scrollView.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
make.bottom.equalTo(self.layoutMarginsGuide.snp.bottom).offset(-56 - 10 - 20)
}

mainContentView.snp.makeConstraints { make in
make.edges.equalTo(scrollView.contentLayoutGuide)
make.width.equalTo(scrollView.frameLayoutGuide.snp.width)
make.height.greaterThanOrEqualTo(scrollView.frameLayoutGuide.snp.height).offset(1)
}

titleLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(30)
make.leading.equalToSuperview().offset(24)
}

emailTextField.snp.makeConstraints{ make in
make.top.equalTo(titleLabel.snp.bottom).offset(30)
make.leading.equalToSuperview().offset(24)
make.trailing.equalToSuperview().offset(-24)
make.height.equalTo(74)
}

passwordTextField.snp.makeConstraints{ make in
make.top.equalTo(emailTextField.snp.bottom).offset(30)
make.leading.equalToSuperview().offset(24)
make.trailing.equalToSuperview().offset(-24)
make.height.equalTo(74)
}

confirmPasswordTextField.snp.makeConstraints{ make in
make.top.equalTo(passwordTextField.snp.bottom).offset(30)
make.leading.equalToSuperview().offset(24)
make.trailing.equalToSuperview().offset(-24)
make.height.equalTo(74)
}

nameTextField.snp.makeConstraints{ make in
make.top.equalTo(confirmPasswordTextField.snp.bottom).offset(30)
make.leading.equalToSuperview().offset(24)
make.trailing.equalToSuperview().offset(-24)
make.height.equalTo(74)
}

nickNameTextField.snp.makeConstraints{ make in
make.top.equalTo(nameTextField.snp.bottom).offset(30)
make.leading.equalToSuperview().offset(24)
make.trailing.equalToSuperview().offset(-24)
make.bottom.equalToSuperview()
make.height.equalTo(74)
}

}

override func bind() {
scrollView.rx.tapGesture()
.when(.recognized)
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.endEditing(true)
})
.disposed(by: disposeBag)

passwordTextField.accessoryState
.observe(on: MainScheduler.instance)
.withUnretained(self)
.subscribe(onNext: { owner, state in
owner.passwordTextField.isSecureTextEntry = !state
})
.disposed(by: disposeBag)

confirmPasswordTextField.accessoryState
.observe(on: MainScheduler.instance)
.withUnretained(self)
.subscribe(onNext: { owner, state in
owner.passwordTextField.isSecureTextEntry = !state
})
.disposed(by: disposeBag)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,25 @@
//

import Foundation

import RxCocoa
import RxSwift

import UIKit

final class MainSignUpViewModel: ViewModelType {

struct Input {
}

struct Output {
}

var disposeBag: DisposeBag = DisposeBag()

func transform(input: Input) -> Output {

return Output()
}

}
25 changes: 21 additions & 4 deletions CMC/Sources/Presenter/Auth/SignUp/SignUpViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class SignUpViewController: BaseViewController {
return view
}()

private lazy var emailCheckView: UIView = {
let view = UIView()
view.backgroundColor = .red
private lazy var mainSignUpView: MainSignUpView = {
let view = MainSignUpView(
viewModel: MainSignUpViewModel(),
parentViewModel: viewModel
)
return view
}()

Expand All @@ -51,7 +53,7 @@ class SignUpViewController: BaseViewController {
private lazy var cmcPager: CMCProgressPager = {
let progressPager = CMCProgressPager(pages: [
termsAndConditionsView,
emailCheckView,
mainSignUpView,
completeSignUpView
])
return progressPager
Expand Down Expand Up @@ -111,6 +113,21 @@ class SignUpViewController: BaseViewController {

override func bind() {

// NotificationManager.shared.keyboardHeightSubject
// .debug()
// .observe(on: MainScheduler.instance)
// .withUnretained(self)
// .subscribe(onNext: { owner, keyboardHeight in
// let realHeight = keyboardHeight > 0 ? keyboardHeight : 0
// owner.cmcPager.snp.updateConstraints { make in
// make.bottom.equalToSuperview().offset(-realHeight)
// }
// UIView.animate(withDuration: 0.3) {
// owner.view.layoutIfNeeded()
// }
// })
// .disposed(by: disposeBag)

let input = SignUpViewModel.Input(
backButtonTapped: navigationBar.backButton.rx.tapped().asObservable(),
nextButtonTapped: nextButton.rx.tap.asObservable(),
Expand Down
10 changes: 6 additions & 4 deletions DesignSystem/Sources/CMCTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public final class CMCTextField: UIView{

accessoryCMCButton.snp.makeConstraints {
$0.height.equalTo(34)
$0.width.equalTo(76)
$0.trailing.equalToSuperview().offset(-18)
$0.centerY.equalToSuperview()
}
Expand Down Expand Up @@ -214,12 +215,12 @@ public final class CMCTextField: UIView{

switch accessoryType {
case .button:
accessoryButton.isHidden = colorSet.accessoryHidden
accessoryButton.removeFromSuperview()
case .image:
accessoryCMCButton.isHidden = colorSet.accessoryHidden
accessoryCMCButton.removeFromSuperview()
case .none:
accessoryButton.isHidden = true
accessoryCMCButton.isHidden = true
accessoryButton.removeFromSuperview()
accessoryCMCButton.removeFromSuperview()
}
}

Expand Down Expand Up @@ -353,6 +354,7 @@ extension CMCTextField: UITextFieldDelegate {
}
return true
}

}


Expand Down