diff --git a/StreetDrop/ShareExtension/View/ShareViewController.swift b/StreetDrop/ShareExtension/View/ShareViewController.swift index b1f7730..051057b 100644 --- a/StreetDrop/ShareExtension/View/ShareViewController.swift +++ b/StreetDrop/ShareExtension/View/ShareViewController.swift @@ -15,7 +15,7 @@ import RxRelay import RxGesture import SnapKit -final class ShareViewController: UIViewController { +final class ShareViewController: UIViewController, Alertable { enum Constant { static let commentPlaceHolder: String = "노래, 현재 감정, 상황, 관련 에피소드, 거리, 가수 등 떠오르는 말을 적어보세요." static let communityButtonTitle: String = "커뮤니티 가이드" @@ -458,6 +458,23 @@ private extension ShareViewController { failedLoadingMusicView.isHidden = false view.layoutIfNeeded() }) + + output.errorAlertShow + .bind(with: self) { owner, errorMessage in + owner.showAlert( + type: .alert( + onConfirm: { [weak self] in + self?.extensionContext?.completeRequest( + returningItems: nil, + completionHandler: nil + ) + } + ), + state: .primary, + title: "에러 발생", + subText: errorMessage, + buttonTitle: "확인" + ) } .disposed(by: disposeBag) } diff --git a/StreetDrop/ShareExtension/ViewModel/ShareViewModel.swift b/StreetDrop/ShareExtension/ViewModel/ShareViewModel.swift index 61b8e56..a052472 100644 --- a/StreetDrop/ShareExtension/ViewModel/ShareViewModel.swift +++ b/StreetDrop/ShareExtension/ViewModel/ShareViewModel.swift @@ -66,6 +66,10 @@ final class ShareViewModel: NSObject, ShareViewModelType { var goFailedLoadingMusicView: Observable { goFailedLoadingMusicViewRelay.asObservable() } + fileprivate let errorAlertShowRelay: PublishRelay = .init() + var errorAlertShow: Observable { + errorAlertShowRelay.asObservable() + } } func convert(input: Input, disposedBag: DisposeBag) -> Output { @@ -113,17 +117,17 @@ final class ShareViewModel: NSObject, ShareViewModelType { input.dropButtonClickEvent .bind(with: self) { owner, _ in guard let selectedMusic = owner.selectedMusic else { - // TODO: 요셉, 선택한 음악정보 없다는 에러팝업 + owner.output.errorAlertShowRelay.accept("선택한 음악 정보가 없습니다.") return } guard let comment = owner.comment else { - // TODO: 코멘트 없다는 에러팝업 + owner.output.errorAlertShowRelay.accept("코멘트가 없습니다.") return } guard let currentLocation = owner.currentLocation else { - // TODO: 현재 위치정보 없다는 에러팝업 + owner.output.errorAlertShowRelay.accept("현재 위치정보가 없습니다.") return } @@ -139,8 +143,7 @@ final class ShareViewModel: NSObject, ShareViewModelType { (selectedMusic, currentLocation.address, comment) ) } onFailure: { owner, error in - // TODO: 드랍 실패 팝업 - print(error.localizedDescription) + owner.output.errorAlertShowRelay.accept("드랍에 실패 했습니다.") } .disposed(by: disposedBag)