Skip to content

Commit

Permalink
✨ Feat: #16 - 이메일 로그인 액션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
usa4060 committed Nov 15, 2023
1 parent 7be72cd commit ef6882b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
10 changes: 5 additions & 5 deletions CMC/Sources/App/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class AppCoordinator: CoordinatorType {

func setState(){
self.userActionState
.subscribe(onNext: { [weak self] state in
guard let self = self else {return}
.withUnretained(self)
.subscribe(onNext: { owner, state in
switch state{
case .auth:
let authCoordinator = AuthCoordinator(
navigationController: self.navigationController
navigationController: owner.navigationController
)
authCoordinator.delegate = self
authCoordinator.delegate = owner
authCoordinator.start()
self.childCoordinators.append(authCoordinator)
owner.childCoordinators.append(authCoordinator)
case .tabBar:
print("🍎 여기 들어가면, 메인 탭 화면으로~ 🍎")
}
Expand Down
14 changes: 8 additions & 6 deletions CMC/Sources/Presenter/Auth/Coordinators/AuthCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class AuthCoordinator: CoordinatorType {

func setState() {
self.userActionState
.observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] state in
guard let self = self else {return}
CMCIndecatorManager.shared.show()
switch state{
case .main:
let mainAuthViewController = MainAuthViewController(
Expand All @@ -52,6 +54,7 @@ class AuthCoordinator: CoordinatorType {
self.navigationController.popViewController(animated: true)
}else {
self.pushViewController(viewController: mainAuthViewController)
CMCIndecatorManager.shared.hide()
}
case .signUp:
let signUpViewController = SignUpViewController(
Expand All @@ -62,11 +65,10 @@ class AuthCoordinator: CoordinatorType {
)
)
)
if self.navigationController.viewControllers.contains(where: {$0 is SignUpViewController}) {
if self.navigationController.viewControllers.contains(where: {$0 is SignInViewController}) {
self.navigationController.popViewController(animated: true)
}else {
self.pushViewController(viewController: signUpViewController)
}
self.pushViewController(viewController: signUpViewController)
case .signIn:
let signInViewController = SignInViewController(
viewModel: SignInViewModel(
Expand All @@ -76,11 +78,11 @@ class AuthCoordinator: CoordinatorType {
)
)
)
if self.navigationController.viewControllers.contains(where: {$0 is SignInViewController}) {
if self.navigationController.viewControllers.contains(where: {$0 is SignUpViewController}) {
self.navigationController.popViewController(animated: true)
}else {
self.pushViewController(viewController: signInViewController)
}
self.pushViewController(viewController: signInViewController)
CMCIndecatorManager.shared.hide()
}
}).disposed(by: disposeBag)
}
Expand Down
28 changes: 24 additions & 4 deletions CMC/Sources/Presenter/Auth/SignIn/SignInViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,35 @@ class SignInViewModel: ViewModelType{
case .success(let model):
UserDefaultManager.shared.save(model.accessToken, for: .accessToken)
UserDefaultManager.shared.save(model.refreshToken, for: .refreshToken)
print("🍎 발급받은 악세스토큰: \(model.accessToken) 🍎")
self?.coordinator?.finish()
case .failure(let error):
print("🍎 발생한 에러: \(error) 🍎")
CMCToastManager.shared.addToast(message: "😵‍💫 로그인에 실패했습니다 ㅜ..ㅜ 😵‍💫")
case .failure(_):
CMCBottomSheetManager.shared.showBottomSheet(
title: "존재하지 않는 계정이에요",
body: "아이디 또는 비밀번호를 확인해주세요!",
buttonTitle: "확인"
)
}
})
.disposed(by: disposeBag)

input.goSignUpButtonTapped
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.coordinator?.userActionState.accept(.signUp)
})
.disposed(by: disposeBag)

input.forgetIDBtnTapped
.withUnretained(self)
.subscribe(onNext: { owner, _ in
CMCBottomSheetManager.shared.showBottomSheet(
title: "아이디 찾기는\n운영진에게 문의해주세요 :)",
body: nil,
buttonTitle: "확인"
)
})
.disposed(by: disposeBag)

input.backBtnTapped
.withUnretained(self)
.observe(on: MainScheduler.instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BaseViewController: UIViewController {
setAttribute()
setConstraint()
bind()
CMCIndecatorManager.shared.hide()
}

func setAddSubView() {}
Expand Down
2 changes: 1 addition & 1 deletion CMC/Sources/Utils/Commons/CMCIndecatorManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CMCIndecatorManager {
}

// MARK: - Methods
func setup() {
private func setup() {

let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene
Expand Down
10 changes: 9 additions & 1 deletion DesignSystem/Sources/CMCBottomSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ public final class CMCBottomSheet: UIView{
let label = UILabel()
label.font = DesignSystemFontFamily.Pretendard.bold.font(size: 18)
label.textColor = DesignSystemAsset.gray50.color
label.text = title
label.numberOfLines = 0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
let attributedString = NSAttributedString(
string: title,
attributes: [
.paragraphStyle: paragraphStyle,
]
)
label.attributedText = attributedString
label.textAlignment = .center
return label
}()
Expand Down

0 comments on commit ef6882b

Please sign in to comment.