Skip to content

Commit

Permalink
[#88] 에러 시 토스트 대신 alert 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyuni committed Oct 3, 2021
1 parent 847ecd4 commit 67f07ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ class TextFieldCaseTestBaseViewController: UIViewController {
})
.disposed(by: bag)

viewModel.shouldShowToastMessage
viewModel.shouldPresentAlert
.filter { $0 }
.subscribe(onNext: { _ in
YDSToast.makeToast(text: "중복 닉네임입니다.", duration: .short)
.subscribe(onNext: { [weak self] _ in
self?.showAlert(title: nil, message: "중복 닉네임입니다.")
})
.disposed(by: bag)

Expand Down Expand Up @@ -162,3 +162,14 @@ extension TextFieldCaseTestBaseViewController {
self.view.endEditing(true)
}
}

// MARK: - Alert
extension TextFieldCaseTestBaseViewController {
private func showAlert(title: String?, message: String?) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let action = UIAlertAction(title: "확인", style: .default, handler: nil)
alert.addAction(action)
alert.view.tintColor = YDSColor.buttonPoint
present(alert, animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TextFieldCaseTestViewModel {
func confirmButtonDidTap() {
textFieldIsNegative.onNext(true)
confirmButtonIsDisabled.onNext(true)
shouldShowToastMessage.onNext(true)
shouldPresentAlert.onNext(true)

switch caseType {
case .withHaptic:
Expand All @@ -48,7 +48,7 @@ class TextFieldCaseTestViewModel {
let textFieldIsNegative = BehaviorSubject<Bool>(value: false)
let textFieldShoudShake = PublishSubject<Bool>()
let textFieldShoudShakeWithHaptic = PublishSubject<Bool>()
let shouldShowToastMessage = PublishSubject<Bool>()
let shouldPresentAlert = PublishSubject<Bool>()

// MARK: - Private Observable
private let text = PublishSubject<String?>()
Expand Down

0 comments on commit 67f07ee

Please sign in to comment.