Skip to content

Commit

Permalink
๐Ÿ•ถ๏ธ:: #50 from LookMonster/Future/#49-AllLogin
Browse files Browse the repository at this point in the history
LoginView ๋
  • Loading branch information
jjunhaa0211 authored Nov 7, 2023
2 parents 377d09b + 9f0692e commit e50f1fa
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// a.swift
// ShopUserInterface
// MonsterCategory.swift
// CSLogger
//
// Created by ๋ฐ•์ค€ํ•˜ on 10/11/23.
// Copyright ยฉ 2023 lookMonster.io. All rights reserved.
// Created by ๋ฐ•์ค€ํ•˜ on 11/7/23.
//

import Foundation
Expand Down
22 changes: 21 additions & 1 deletion DesignSystem/DemoApp/Sources/Button/ButtonViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,34 @@ public class ButtonViewController: UIViewController {
// basic ๐ŸŽฑ
var nextButton = MonsterButton(title: "๋‹ค์Œ", backgorundColor: .black, titleColor: .white)

// double ๐ŸŽฑ
let doubleTextButton = MonsterDoubleTextButton(title1: "๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ", title2: "์•„์ด๋”” ์ฐพ๊ธฐ", thintColor: .black, backgroundColor: .clear)


public override func viewDidLoad() {
super.viewDidLoad()

attribute()
layout()
doubleButtonAction()
}

func attribute() {
view.backgroundColor = .white
}

func doubleButtonAction() {
doubleTextButton.greetingObservable.subscribe(onNext: {
print("๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ")
}).disposed(by: doubleTextButton.disposeBag)

doubleTextButton.farewellObservable.subscribe(onNext: {
print("์•„์ด๋”” ์ฐพ๊ธฐ")
}).disposed(by: doubleTextButton.disposeBag)
}

func layout() {
[appleButton, nextButton].forEach { view.addSubview($0) }
[appleButton, nextButton, doubleTextButton].forEach { view.addSubview($0) }

appleButton.snp.makeConstraints {
$0.top.equalTo(view.safeAreaLayoutGuide)
Expand All @@ -40,6 +55,11 @@ public class ButtonViewController: UIViewController {
$0.leading.trailing.equalToSuperview().inset(24.0)
$0.height.equalTo(48.0)
}

doubleTextButton.snp.makeConstraints {
$0.top.equalTo(nextButton.snp.bottom).offset(30.0)
$0.leading.equalTo(nextButton.snp.leading)
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import ShopUserInterface
import DesignSystem
import SuperUI

fileprivate enum DesignSystemType: String, CaseIterable {
case button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import DesignSystem
import ShopUserInterface
import SuperUI

enum Item {
case subCategory
Expand Down
3 changes: 2 additions & 1 deletion DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ let project = Project(
.ThirdParty.SPM.Then,
.ResourceKit.Implement,
.ThirdParty.SPM.RxCocoa,
.ThirdParty.SPM.RxSwift
.ThirdParty.SPM.RxSwift,
.Core.SuperUI
]
)

Expand Down
80 changes: 80 additions & 0 deletions DesignSystem/Sources/MonsterButton/Monster+DoubleTextButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// Monster+DoubleTextButton.swift
// DesignSystem
//
// Created by ๋ฐ•์ค€ํ•˜ on 11/7/23.
//

import UIKit
import Then
import SnapKit
import RxSwift
import RxCocoa

public class MonsterDoubleTextButton: UIView {

private let firstButton = UIButton().then {
$0.setTitleColor(.white, for: .normal)
$0.titleLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: .black)
$0.layer.cornerRadius = 5
}

private let separatorLabel = UILabel().then {
$0.text = "|"
$0.textColor = .black
$0.font = UIFont.systemFont(ofSize: 16.0, weight: .black)
}

private let secondButton = UIButton().then {
$0.setTitleColor(.white, for: .normal)
$0.titleLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: .black)
$0.layer.cornerRadius = 5
}

public let disposeBag = DisposeBag()

public var greetingObservable: Observable<Void> {
return firstButton.rx.tap.asObservable()
}

public var farewellObservable: Observable<Void> {
return secondButton.rx.tap.asObservable()
}

public init(title1: String, title2: String, thintColor: UIColor, backgroundColor: UIColor) {
super.init(frame: .zero)
firstButton.setTitle(title1, for: .normal)
secondButton.setTitle(title2, for: .normal)
firstButton.backgroundColor = backgroundColor
secondButton.backgroundColor = backgroundColor
firstButton.setTitleColor(thintColor, for: .normal)
secondButton.setTitleColor(thintColor, for: .normal)
setupUI()
setupConstraints()
}

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

private func setupUI() {
[firstButton,separatorLabel,secondButton].forEach { self.addSubview($0) }
}

private func setupConstraints() {
firstButton.snp.makeConstraints {
$0.leading.top.bottom.equalToSuperview()
$0.trailing.equalTo(separatorLabel.snp.leading).offset(-8)
}

separatorLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.centerX.equalToSuperview()
}

secondButton.snp.makeConstraints {
$0.trailing.top.bottom.equalToSuperview()
$0.leading.equalTo(separatorLabel.snp.trailing).offset(8)
}
}
}
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

This file was deleted.

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
7 changes: 5 additions & 2 deletions Features/User/Auth/Login/LoginUserInterface/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ let project = Project.invertedDualTargetProjectWithDemoApp(
iOSTargetVersion: "15.0.0",
interfaceDependencies: [
.Core.RIBsUtil,
.TokenManager.Interface
.TokenManager.Interface,
.DesignSystem.Implement
],
implementDependencies: [
.Core.SuperUI,
Expand All @@ -21,7 +22,9 @@ let project = Project.invertedDualTargetProjectWithDemoApp(
.Features.User.Auth.Login.Domain.Implement,

.LKNetwork.Implement,
.TokenManager.Implement
.TokenManager.Implement,
.DesignSystem.Implement

],
isUserInterface: true
)

0 comments on commit e50f1fa

Please sign in to comment.