From 9815fca10ab54ece57df93ef30befa750d28d549 Mon Sep 17 00:00:00 2001 From: Joseph Cha Date: Tue, 20 Aug 2024 17:19:26 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8#297:=20Share=20Extension=20=ED=86=B5?= =?UTF-8?q?=EC=8B=A0=20=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EC=97=90=EB=9F=AC=20=ED=8C=9D=EC=97=85=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 정상 동작을 위한 재기동을 위해 팝업 확인 버튼 클릭 시, Share Extension 종료 --- .../View/ShareViewController.swift | 19 ++++++++++++++++++- .../ViewModel/ShareViewModel.swift | 13 ++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) 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)