-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
176 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
iOS/Layover/Layover/Scenes/SingUpScene/SignUpConfigurator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// SignUpConfigurator.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/15. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
final class SignUpConfigurator: Configurator { | ||
typealias T = SignUpViewController | ||
|
||
static let sharedInstance = SignUpConfigurator() | ||
|
||
private init() { } | ||
|
||
func configure(_ viewController: SignUpViewController) { | ||
let viewController = viewController | ||
let interactor = SignUpInteractor() | ||
let presenter = SignUpPresenter() | ||
viewController.interactor = interactor | ||
interactor.presenter = presenter | ||
presenter.viewController = viewController | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
iOS/Layover/Layover/Scenes/SingUpScene/SignUpInteractor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// SignUpInteractor.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/15. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol SignUpBusinessLogic { | ||
func validateNickname(with request: SignUpModels.ValidateNickname.Request) | ||
} | ||
|
||
protocol SignUpDataStore { } | ||
|
||
class SignUpInteractor: SignUpBusinessLogic, SignUpDataStore { | ||
|
||
// MARK: - Properties | ||
|
||
typealias Models = SignUpModels | ||
|
||
var presenter: SignUpPresentationLogic? | ||
|
||
// MARK: - UseCase: 닉네임 유효성 검사 | ||
|
||
func validateNickname(with request: SignUpModels.ValidateNickname.Request) { | ||
let response = check(nickname: request.nickname) | ||
presenter?.presentNicknameValidation(with: response) | ||
} | ||
|
||
private func check(nickname: String) -> SignUpModels.ValidateNickname.Response { | ||
if nickname.count < 2 || nickname.count > 8 { | ||
return .init(nicknameState: .lessThan2GreaterThan8) | ||
} else if nickname.wholeMatch(of: /^[a-zA-Z0-9ㄱ-ㅎㅏ-ㅣ가-힣]+/) == nil { | ||
return .init(nicknameState: .invalidCharacter) | ||
} | ||
return .init(nicknameState: .valid) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SignUpModels.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/15. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
enum SignUpModels { | ||
|
||
// MARK: - Use Cases | ||
|
||
enum ValidateNickname { | ||
struct Request { | ||
var nickname: String | ||
} | ||
struct Response { | ||
var nicknameState: NicknameState | ||
} | ||
struct ViewModel { | ||
var canCheckDuplication: Bool | ||
var alertDescription: String? | ||
} | ||
} | ||
|
||
// MARK: - State Type | ||
enum NicknameState { | ||
case valid | ||
case lessThan2GreaterThan8 | ||
case invalidCharacter | ||
|
||
var alertDescription: String? { | ||
switch self { | ||
case .valid: | ||
return nil | ||
case .lessThan2GreaterThan8: | ||
return "2자 이상 8자 이하로 입력해주세요." | ||
case .invalidCharacter: | ||
return "입력할 수 없는 문자입니다." | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
iOS/Layover/Layover/Scenes/SingUpScene/SignUpPresenter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// SignUpPresenter.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/15. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol SignUpPresentationLogic { | ||
func presentNicknameValidation(with response: SignUpModels.ValidateNickname.Response) | ||
} | ||
|
||
class SignUpPresenter: SignUpPresentationLogic { | ||
|
||
// MARK: - Properties | ||
|
||
typealias Models = SignUpModels | ||
weak var viewController: SignUpDisplayLogic? | ||
|
||
// MARK: - UseCase: 닉네임 유효성 검사 | ||
|
||
func presentNicknameValidation(with response: SignUpModels.ValidateNickname.Response) { | ||
let viewModel = Models.ValidateNickname.ViewModel(canCheckDuplication: response.nicknameState == .valid, | ||
alertDescription: response.nicknameState.alertDescription) | ||
viewController?.displayNicknameValidation(response: viewModel) | ||
} | ||
|
||
} |