From 7d22a2951720c0d613f1dfe3984396c1f091bf86 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Mon, 28 Jul 2025 20:02:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=81=EB=8B=A8=EC=97=90=20=EC=B5=9C?= =?UTF-8?q?=EA=B7=BC=20=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/MyPage/MyPageView.swift | 38 ++++++++++++------- SodaLive/Sources/MyPage/MyPageViewModel.swift | 26 +++++++++++++ .../Sources/Settings/Notice/NoticeApi.swift | 7 ++++ .../Settings/Notice/NoticeRepository.swift | 4 ++ 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/SodaLive/Sources/MyPage/MyPageView.swift b/SodaLive/Sources/MyPage/MyPageView.swift index 8531337..cf6ee74 100644 --- a/SodaLive/Sources/MyPage/MyPageView.swift +++ b/SodaLive/Sources/MyPage/MyPageView.swift @@ -97,6 +97,10 @@ struct MyPageView: View { CategoryButtonsView( isShowAuthView: $viewModel.isShowAuthView, isAuthenticated: viewModel.isAuth, + showMessage: { + viewModel.errorMessage = $0 + viewModel.isShowPopup = true + }, refresh: { viewModel.getMypage() } @@ -126,6 +130,7 @@ struct MyPageView: View { if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { viewModel.getMypage() } + viewModel.getLatestNotice() } } } @@ -172,7 +177,7 @@ struct MyPageHeaderView: View { if isShowButton { HStack(spacing: 24) { // Settings Icon - Image(systemName: "ic_settings") + Image("ic_settings") .foregroundColor(.white) .frame(width: 24, height: 24) .onTapGesture { @@ -183,7 +188,6 @@ struct MyPageHeaderView: View { } .padding(.horizontal, 24) .padding(.vertical, 20) - .background(Color.black) } } @@ -359,22 +363,30 @@ struct CategoryButtonsView: View { @Binding var isShowAuthView: Bool let isAuthenticated: Bool + let showMessage: (String) -> Void let refresh: () -> Void var body: some View { - LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: 14) { + LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 4), spacing: 16) { CategoryButtonItem(icon: "ic_my_storage", title: "보관함") { AppState.shared.setAppStep(step: .myBox(currentTab: .orderlist)) } + CategoryButtonItem(icon: "ic_my_block", title: "차단목록") { AppState.shared.setAppStep(step: .blockList) } - if isAuthenticated { - CategoryButtonItem( - icon: "ic_my_coupon", - title: "쿠폰등록" - ) { + + CategoryButtonItem( + icon: "ic_my_coupon", + title: "쿠폰등록" + ) { + if isAuthenticated { AppState.shared.setAppStep(step: .canCoupon(refresh: refresh)) + } else { + showMessage("본인인증 후 등록합니다.") + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + isShowAuthView = true + } } } @@ -390,11 +402,11 @@ struct CategoryButtonsView: View { AppState.shared.setAppStep(step: .serviceCenter) } - if !isAuthenticated { - CategoryButtonItem( - icon: "ic_my_auth", - title: "본인인증" - ) { + CategoryButtonItem( + icon: "ic_my_auth", + title: isAuthenticated ? "인증완료" : "본인인증" + ) { + if !isAuthenticated { isShowAuthView = true } } diff --git a/SodaLive/Sources/MyPage/MyPageViewModel.swift b/SodaLive/Sources/MyPage/MyPageViewModel.swift index 51e5739..fdf24c0 100644 --- a/SodaLive/Sources/MyPage/MyPageViewModel.swift +++ b/SodaLive/Sources/MyPage/MyPageViewModel.swift @@ -125,4 +125,30 @@ final class MyPageViewModel: ObservableObject { isShowPopup = true } } + + func getLatestNotice() { + noticeRepository.getLatestNotice() + .sink { result in + switch result { + case .finished: + DEBUG_LOG("finish") + case .failure(let error): + ERROR_LOG(error.localizedDescription) + } + } receiveValue: {[unowned self] response in + self.isLoading = false + let responseData = response.data + + do { + let jsonDecoder = JSONDecoder() + let decoded = try jsonDecoder.decode(ApiResponse.self, from: responseData) + + if let data = decoded.data, decoded.success { + self.latestNotice = data + } + } catch { + } + } + .store(in: &subscription) + } } diff --git a/SodaLive/Sources/Settings/Notice/NoticeApi.swift b/SodaLive/Sources/Settings/Notice/NoticeApi.swift index d07c611..c3b76dd 100644 --- a/SodaLive/Sources/Settings/Notice/NoticeApi.swift +++ b/SodaLive/Sources/Settings/Notice/NoticeApi.swift @@ -10,6 +10,7 @@ import Moya enum NoticeApi { case getNotices + case getLatestNotice } extension NoticeApi: TargetType { @@ -21,6 +22,9 @@ extension NoticeApi: TargetType { switch self { case .getNotices: return "/notice" + + case .getLatestNotice: + return "/notice/latest" } } @@ -33,6 +37,9 @@ extension NoticeApi: TargetType { case .getNotices: let parameters = ["timezone": TimeZone.current.identifier] as [String: Any] return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) + + case .getLatestNotice: + return .requestPlain } } diff --git a/SodaLive/Sources/Settings/Notice/NoticeRepository.swift b/SodaLive/Sources/Settings/Notice/NoticeRepository.swift index 6657117..8b24e31 100644 --- a/SodaLive/Sources/Settings/Notice/NoticeRepository.swift +++ b/SodaLive/Sources/Settings/Notice/NoticeRepository.swift @@ -17,5 +17,9 @@ final class NoticeRepository { func getNotices() -> AnyPublisher { return api.requestPublisher(.getNotices) } + + func getLatestNotice() -> AnyPublisher { + return api.requestPublisher(.getLatestNotice) + } }