Skip to content

Commit

Permalink
[Fix] #319 - VC에서 토스트 띄우는 걸로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
EunsuSeo01 committed Dec 31, 2024
1 parent 3c0e69b commit 5436a15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ private extension HankkiDetailViewController {
primaryButtonText: StringLiterals.Alert.check)
}

viewModel.dismiss = {
self.navigationController?.popViewController(animated: false)
viewModel.dismiss = { [weak self] in
self?.navigationController?.popViewController(animated: false)
}

viewModel.handleDeletedHankki = { [weak self] in
self?.showBlackToast(message: StringLiterals.Toast.deleteAlready)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

import Moya
import UIKit

final class HankkiDetailViewModel {

Expand All @@ -34,6 +33,8 @@ final class HankkiDetailViewModel {
var setHankkiDetailData: (() -> Void)?
var showAlert: ((String) -> Void)?
var dismiss: (() -> Void)?
var handleMapError: (() -> Void)?
var handleDeletedHankki: (() -> Void)?

init(hankkiId: Int) {
self.hankkiId = hankkiId
Expand All @@ -47,8 +48,8 @@ extension HankkiDetailViewModel {
guard let self = self else { return }
switch result {
case .notFound:
UIApplication.showBlackToast(message: StringLiterals.Toast.deleteAlready)
self.dismiss?()
handleDeletedHankki?()
dismiss?()
default:
result.handleNetworkResult(delegate: self.delegate) { response in
self.hankkiDetailData = response.data
Expand Down Expand Up @@ -88,10 +89,8 @@ private extension HankkiDetailViewModel {
guard let detailData = hankkiDetailData else { return }
NetworkService.shared.naverMapService.getHankkiAddress(latitude: detailData.latitude, longitude: detailData.longitude) { result in
switch result {
case .badRequest:
UIApplication.showBlackToast(message: StringLiterals.Toast.serverError)
case .serverError:
UIApplication.showBlackToast(message: StringLiterals.Toast.serverError)
case .badRequest, .serverError:
self.handleMapError?()
default:
result.handleNetworkResult { response in
guard let data = response.results.first,
Expand Down

0 comments on commit 5436a15

Please sign in to comment.