Skip to content

Commit c6de6e9

Browse files
committed
[#234] MyReviewViewController에서 서버 연결 실패 시 popNavigationController 설계
1 parent f9e298e commit c6de6e9

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

EATSSU/App/Sources/Presentation/MyPage/ViewController/MyPageViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ final class MyPageViewController: BaseViewController {
140140

141141
/// - Note: 로그아웃 알림창을 화면에 표시하고, 로그아웃 시에는 DB 초기화 및 로그인화면으로 전환합니다.
142142
private func showLogoutAlert() {
143-
AlertUtility.showConfirmAlert(
143+
ESAlertUtility.showConfirmAlert(
144144
title: "로그아웃",
145145
message: "정말 로그아웃 하시겠습니까?",
146146
confirmTitle: "로그아웃",

EATSSU/App/Sources/Presentation/MyPage/ViewController/MyReviewViewController.swift

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//
22
// MyReviewViewController.swift
3-
// EatSSU-iOS
3+
// EATSSU
44
//
5-
// Created by 최지우 on 2023/07/27.
5+
// Edited by Jiwoong CHOI on 1/31/25.
66
//
77

88
import UIKit
99

10+
import EATSSUKit
11+
1012
import Moya
1113
import SnapKit
1214
import Then
@@ -152,10 +154,20 @@ extension MyReviewViewController {
152154
self.checkReviewCount()
153155
self.myReviewView.myReviewTableView.reloadData()
154156
} catch let err {
155-
print(err.localizedDescription)
157+
#if DEBUG
158+
print(err.localizedDescription)
159+
#endif
160+
ESAlertUtility.showConfirmOnlyAlert(title: "알림", message: "서버 문제가 발생했습니다.", in: self) { [weak self] in
161+
self?.navigationController?.popViewController(animated: true)
162+
}
156163
}
157164
case let .failure(err):
158-
print(err.localizedDescription)
165+
#if DEBUG
166+
print(err.localizedDescription)
167+
#endif
168+
ESAlertUtility.showConfirmOnlyAlert(title: "알림", message: "서버 문제가 발생했습니다.", in: self) { [weak self] in
169+
self?.navigationController?.popViewController(animated: true)
170+
}
159171
}
160172
}
161173
}

EATSSUKit/EATSSUKit/Sources/AlertUtility.swift renamed to EATSSUKit/EATSSUKit/Sources/ESAlertUtility.swift

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// AlertUtility.swift
2+
// ESAlertUtility.swift
33
// EATSSUKit
44
//
55
// Created by JIWOONG CHOI on 1/31/25.
@@ -8,15 +8,10 @@
88
import UIKit
99

1010
/// - Note: 앱 전반에서 재사용할 수 있는 알림창(팝업) 유틸리티 클래스입니다.
11-
public enum AlertUtility {
11+
public enum ESAlertUtility {
1212
// MARK: - Common Alert
1313

1414
/// - Note: 일반적인 알림 창을 생성하는 함수입니다.
15-
/// - Parameters:
16-
/// - title: 알림 제목
17-
/// - message: 알림 내용
18-
/// - confirmTitle: 확인 버튼 텍스트 (기본값: "확인")
19-
/// - viewController: 알림을 표시할 뷰 컨트롤러
2015
public static func showAlert(
2116
title: String?,
2217
message: String?,
@@ -32,13 +27,6 @@ public enum AlertUtility {
3227
// MARK: - Confirm Alert
3328

3429
/// - Note: 사용자의 확인이 필요한 알림 창을 생성하는 함수입니다.
35-
/// - Parameters:
36-
/// - title: 알림 제목
37-
/// - message: 알림 내용
38-
/// - confirmTitle: 확인 버튼 텍스트
39-
/// - cancelTitle: 취소 버튼 텍스트
40-
/// - viewController: 알림을 표시할 뷰 컨트롤러
41-
/// - confirmHandler: 확인 버튼을 눌렀을 때 실행할 클로저
4230
public static func showConfirmAlert(
4331
title: String?,
4432
message: String?,
@@ -58,14 +46,26 @@ public enum AlertUtility {
5846
viewController.present(alert, animated: true, completion: nil)
5947
}
6048

49+
/// - Note: 취소 버튼 없이 확인 버튼만 있는 알림 창을 생성하는 함수입니다.
50+
public static func showConfirmOnlyAlert(
51+
title: String?,
52+
message: String?,
53+
confirmTitle: String = "확인",
54+
in viewController: UIViewController,
55+
confirmHandler: (() -> Void)? = nil
56+
) {
57+
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
58+
let confirmAction = UIAlertAction(title: confirmTitle, style: .default) { _ in
59+
confirmHandler?()
60+
}
61+
62+
alert.addAction(confirmAction)
63+
viewController.present(alert, animated: true, completion: nil)
64+
}
65+
6166
// MARK: - Action Sheet
6267

6368
/// - Note: 사용자에게 여러 선택지를 제공하는 액션 시트를 생성하는 함수입니다.
64-
/// - Parameters:
65-
/// - title: 액션 시트 제목
66-
/// - message: 설명 메시지
67-
/// - actions: 각 액션 시트 버튼의 제목과 핸들러를 배열로 전달
68-
/// - viewController: 액션 시트를 표시할 뷰 컨트롤러
6969
public static func showActionSheet(
7070
title: String?,
7171
message: String?,

0 commit comments

Comments
 (0)