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

♻️ :: #130 리펙토링 #134

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Mukgen/Modules/Core/Sources/Base/BaseStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ open class BaseSV: BaseVC {
$0.width.equalToSuperview().inset(20.0)
$0.height.equalTo(55.0)
}

secondButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(firstButton.snp.bottom).offset(24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import SnapKit
import Then

extension UIViewController {
func showAlert(labelText: String ,buttonLabelText: String, Botton Action:@escaping ()->Void ) {
func showAlert(labelText: String, buttonLabelText: String, bottonAction: @escaping () -> Void) {
guard let window = UIApplication.shared.windows.first else { return }

let alertView = CustomAlertView(labelText: labelText, buttonLabelText: buttonLabelText, buttonAction: Action)
let alertView = CustomAlertView(labelText: labelText, buttonLabelText: buttonLabelText, buttonAction: bottonAction)

window.addSubview(alertView)

Expand Down
15 changes: 15 additions & 0 deletions Mukgen/Modules/Presentation/Sources/Auth/Login/LoginModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SnapKit
import MukgenKit

class LoginModel {

var id = ""
var password = ""

convenience init(id: String, password: String) {
self.init()
self.id = id
self.password = password
}
}

108 changes: 108 additions & 0 deletions Mukgen/Modules/Presentation/Sources/Auth/Login/LoginView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import UIKit
import SnapKit
import Then
import Core
import MukgenKit
import RxSwift
import RxCocoa

public class LoginView: BaseVC {
public var factory: ModuleFactoryInterface!

let disposeBag = DisposeBag()

private lazy var inputIdPasswordUILabel = UILabel().then {
$0.numberOfLines = 2
$0.text = "로그인을 위한\n정보를 입력해주세요."
$0.backgroundColor = .white
$0.font = .systemFont(ofSize: 24, weight: .semibold)
}

public lazy var textFields: [CustomTextField] = {
let textField1 = CustomTextField()
textField1.placeholder = "아이디"
let textField2 = CustomTextField()
textField2.isSecureTextEntry = true
textField2.placeholder = "비밀번호"
return [textField1, textField2]

textFields[0].rx.text.orEmpty
.subscribe(onNext: { text in
print("You've typed in ID field: \(text)")
})
.disposed(by: disposeBag)

textFields[1].rx.text.orEmpty
.subscribe(onNext: { text in
print("You've typed in Password field: \(text)")
})
.disposed(by: disposeBag)
}()

private lazy var lines: [UIView] = {
let line1 = createLineView()
let line2 = createLineView()
return [line1, line2]
}()


private lazy var nextPageButton = CustomButton(
title: "다음",
backgroundColor: .red,
titleColor: .white,
font: UIFont.systemFont(ofSize: 16, weight: .semibold)
).then {
$0.rx.tap
.subscribe(onNext: {
self.nextPageButtonDidTap()
}).disposed(by: disposeBag)
}

public override func layout() {
[
inputIdPasswordUILabel,
nextPageButton,
].forEach( {view.addSubview($0)} )

inputIdPasswordUILabel.snp.makeConstraints() {
$0.top.equalToSuperview().offset(123)
$0.leading.equalToSuperview().offset(20)
$0.trailing.equalToSuperview().offset(-20)
$0.width.equalToSuperview()
$0.height.equalTo(58)
}

inputIdPasswordUILabel.snp.makeConstraints {
$0.center.equalToSuperview()
}

nextPageButton.snp.makeConstraints() {
$0.bottom.equalTo(view.safeAreaLayoutGuide)
$0.centerX.equalToSuperview()
$0.width.equalToSuperview().inset(20.0)
$0.height.equalTo(55)
}
}

private func createLineView() -> UIView {
let lineView = UIView()
lineView.backgroundColor = MukgenKitAsset.Colors.primaryLight2.color
return lineView
}



private func nextPageButtonDidTap() {
guard let accountId = textFields[0].text, let password = textFields[1].text else {
print("Please enter Account ID and Password.")
return
}
}

private func animate(line: UIView) {
line.alpha = 0.3
UIView.animate(withDuration: 1) {
line.alpha = 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import Then
import Core
import MukgenKit
import AuthService
import RxSwift
import RxCocoa

public class LoginViewController: BaseVC {
public class LoginViewController1: BaseVC {

public var factory: ModuleFactoryInterface!
let authService = AuthService()
Expand All @@ -15,7 +17,7 @@ public class LoginViewController: BaseVC {
.font: UIFont.systemFont(ofSize: 20, weight: .semibold)
]

private lazy var inputIdPasswordLabel = UILabel().then {
private lazy var inputIdPasswordUILabel = UILabel().then {
$0.numberOfLines = 2
$0.text = "로그인을 위한\n정보를 입력해주세요."
$0.backgroundColor = .white
Expand Down Expand Up @@ -61,12 +63,12 @@ public class LoginViewController: BaseVC {
textFields.forEach { view.addSubview($0) }
lines.forEach { view.addSubview($0) }
[
inputIdPasswordLabel,
inputIdPasswordUILabel,
showPWButton,
nextPageButton
].forEach { view.addSubview($0) }

inputIdPasswordLabel.snp.makeConstraints() {
inputIdPasswordUILabel.snp.makeConstraints() {
$0.top.equalToSuperview().offset(123)
$0.leading.equalToSuperview().offset(20)
$0.trailing.equalToSuperview().offset(-20)
Expand All @@ -83,7 +85,7 @@ public class LoginViewController: BaseVC {
for i in 0..<textFields.count {
textFields[i].snp.makeConstraints() {
if i == 0 {
$0.top.equalTo(inputIdPasswordLabel.snp.bottom).offset(24)
$0.top.equalTo(inputIdPasswordUILabel.snp.bottom).offset(24)
} else {
$0.top.equalTo(textFields[i - 1].snp.bottom).offset(24)
}
Expand All @@ -108,6 +110,7 @@ public class LoginViewController: BaseVC {
}
}


public override func attribute() {
super.attribute()
view.backgroundColor = .white
Expand Down Expand Up @@ -175,46 +178,6 @@ public class LoginViewController: BaseVC {
print("Please enter Account ID and Password.")
return
}
//
// authService.login(accountId: accountId, password: password) { [weak self] result in
// DispatchQueue.main.async {
// switch result {
// case .success(let loginResponse):
// self?.textFields[1].isCorrectIdPW()
//
// self?.darkeningView.frame = self?.view.bounds ?? .zero
// self?.darkeningView.alpha = 0
// self?.view.addSubview(self?.darkeningView ?? UIView())
//
// UIView.animate(withDuration: 0.3) {
// self?.darkeningView.alpha = 1
// }
//
// let customAlert = CustomAlertView(
// labelText: "\(accountId) 님\n환영합니다!",
// buttonLabelText: "확인",
// buttonAction: { [weak self] in
// print("알림 버튼이 눌렸습니다.")
// self?.removeDarkeningView()
// }
// )
// self?.view.addSubview(customAlert)
// customAlert.snp.makeConstraints {
// $0.center.equalToSuperview()
// }
// print("Login successful. Welcome, \(loginResponse.message)!")
// print("accessToken: \(loginResponse.tokenResponse.accessToken)")
// print("refreshToken: \(loginResponse.tokenResponse.refreshToken)")
//
// self?.authService.setRefreshToken(token: loginResponse.tokenResponse.refreshToken)
//
// case .failure(let error):
// self?.textFields[1].isIncorrectIdPW()
// print("Login failed. Error: \(error.localizedDescription)")
// }
// }
// }
// self.navigationController?.pushViewController(TapBarV(), animated: true)
}

@objc func giveMeSaveToken() {
Expand All @@ -240,7 +203,9 @@ public class LoginViewController: BaseVC {
}
}

extension LoginViewController: UITextFieldDelegate {
extension LoginViewController1: UITextFieldDelegate {


public func textFieldDidBeginEditing(_ textField: UITextField) {

switch textField {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import SnapKit
import Then
import RxSwift

//protocol ValidationViewm {
// <#requirements#>
//}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public protocol ModuleFactoryInterface {

func selectMealVC() -> SelectMealViewController

func loginVC() -> LoginViewController
func loginVC() -> LoginViewController1

// func mugkenPickVC() -> MukgenPickPageVC
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class BoardContentsView: UIView {
$0.layer.cornerRadius = 30
$0.addTarget(self, action: #selector(plusButtonTapped), for: .touchUpInside)
}

func layout() {
self.addSubview(BoardContentsCollectionView)
self.addSubview(plusButton)

BoardContentsCollectionView.snp.makeConstraints {
$0.top.equalToSuperview().offset(14.0)
$0.height.equalTo(570.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension BoardTitleView: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}

//cell에 관련된 것을 정의합니다.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BoardTitleCell.id, for: indexPath) as! BoardTitleCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(windowScene: windowScene)

let moduleFactory = ModuleFactory.shared
let rootViewController = moduleFactory.DeliveryVC()
let rootViewController = moduleFactory.loginVC()
// let navigationController = UINavigationController(rootViewController: rootViewController)

window?.rootViewController = rootViewController
Expand Down
4 changes: 2 additions & 2 deletions Mukgen/Mukgen-iOS/Sources/ModuleFactory/ModuleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ extension ModuleFactory: ModuleFactoryInterface {
return vc
}

public func loginVC() -> Presentation.LoginViewController {
let vc = LoginViewController()
public func loginVC() -> Presentation.LoginViewController1 {
let vc = LoginViewController1()
return vc
}

Expand Down
Loading