Skip to content

Commit

Permalink
๐ŸฅŠ:: [#49] ๋กœ๊ทธ์ธ ์ฝ”๋“œ ๋ฆฌํŽ™ํ† ๋ง
Browse files Browse the repository at this point in the history
  • Loading branch information
jjunhaa0211 committed Nov 7, 2023
1 parent b57c081 commit 9f0692e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ final class LoginInteractor: PresentableInteractor<LoginPresentable>,

}

//๋กœ์ง ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
extension LoginInteractor {

func loginButtonDidTap(email: String, password: String) {
Expand Down Expand Up @@ -67,12 +66,10 @@ extension LoginInteractor {
} else {
textfield.passwordErrorType = .notMatch
print("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
// fatalError("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
}
}
}

//๋กœ์ง ํ•จ์ˆ˜
extension LoginInteractor {

func checkGmailFormat(emailText: String?) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import SnapKit
import Then
import RxCocoa
import RxSwift
import Kingfisher
import LoginUserInterface
import SuperUI
import DesignSystem
Expand All @@ -27,16 +26,16 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
$0.isSecureTextEntry = true
}

public lazy var doubleButton = MonsterDoubleTextButton(title1: "๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ", title2: "์•„์ด๋”” ์ฐพ๊ธฐ", thintColor: .black, backgroundColor: .clear)

public lazy var nextButton = MonsterButton(title: "๋‹ค์Œ", backgorundColor: .gray, titleColor: .white)

public var uiviewController: UIViewController {
return self
}

public let loginView = LoginView()

public init() {
super.init(nibName: nil, bundle: nil)
public override init() {
super.init()
self.textFieldBind()
self.buttonBind()
self.keyboardBind()
Expand All @@ -57,7 +56,8 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
titleLabel,
idTextField,
passwordTextField,
nextButton
nextButton,
doubleButton
].forEach { view.addSubview($0) }

titleLabel.snp.makeConstraints {
Expand Down Expand Up @@ -88,6 +88,11 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
$0.right.left.equalToSuperview().inset(20.0)
$0.height.equalTo(48.0)
}

doubleButton.snp.makeConstraints {
$0.leading.equalTo(passwordTextField.snp.leading)
$0.bottom.equalTo(nextButton.snp.top).offset(-20.0)
}
}

private func attrebute() {
Expand All @@ -96,15 +101,17 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
}

private func textFieldBind() {
let idTextFieldObservable = idTextField.rx.text.orEmpty
let passwordTextFieldObservable = passwordTextField.rx.text.orEmpty

let inputTextObservable = idTextField.rx.text.orEmpty

inputTextObservable
.map { !$0.isEmpty }
Observable.combineLatest(idTextFieldObservable, passwordTextFieldObservable)
.map { idText, passwordText in
return !idText.isEmpty && !passwordText.isEmpty
}
.bind(to: nextButton.rx.isEnabled)
.disposed(by: disposeBag)
inputTextObservable

idTextFieldObservable
.map { text in
text.isEmpty ? UIColor.gray : UIColor.black
}
Expand All @@ -113,16 +120,16 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
self?.nextButton.backgroundColor = backgroundColor
})
.disposed(by: disposeBag)

idTextField.rx.controlEvent(.editingChanged)
.subscribe(onNext: { [weak self] in
if let text = self?.idTextField.text, text.count > 30 {
self?.idTextField.deleteBackward()
}
})
.disposed(by: disposeBag)
inputTextObservable

idTextFieldObservable
.subscribe(onNext: { [weak self] text in
self?.listener?.checkGmailTextField(textfield: self?.idTextField ?? MonsterTextField())
})
Expand All @@ -139,8 +146,9 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
Observable.merge(keyboardWillShowObservable)
.subscribe(onNext: { [weak self] height in
self?.nextButton.snp.updateConstraints {
$0.left.right.equalToSuperview()
$0.bottom.equalToSuperview().offset(-height)
$0.left.equalToSuperview()
$0.right.equalToSuperview()
}
self?.nextButton.layer.cornerRadius = 0
UIView.animate(withDuration: 0.3) {
Expand All @@ -153,19 +161,17 @@ public final class LoginViewContoller: BaseViewController, LoginPresentable, Log
.subscribe(onNext: { [weak self] _ in
self?.nextButton.snp.updateConstraints {
$0.bottom.equalToSuperview().inset(48.0)
$0.right.left.equalToSuperview().inset(20.0)
$0.left.equalToSuperview().inset(20.0)
$0.right.equalToSuperview().inset(20.0)
}
self?.nextButton.layer.cornerRadius = 8.0

UIView.animate(withDuration: 0.3) {
self?.view.layoutIfNeeded()
}
})
.disposed(by: disposeBag)
}



private func buttonBind() {
nextButton.rx.tap
.subscribe(onNext: { [weak self] _ in
Expand Down

0 comments on commit 9f0692e

Please sign in to comment.