From 27df89d78e958f162ce0124abe60c8078796bd08 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 3 Nov 2023 14:45:51 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=EA=B8=B0=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=20=EC=A0=84=EC=B2=B4=20=EB=B3=B4=EA=B8=B0=20-=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/All/ContentRankingAllView.swift | 9 ++++ .../All/ContentRankingAllViewModel.swift | 47 ++++++++++++++++++- SodaLive/Sources/Content/ContentApi.swift | 10 +++- .../Sources/Content/ContentRepository.swift | 4 ++ 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/SodaLive/Sources/Content/All/ContentRankingAllView.swift b/SodaLive/Sources/Content/All/ContentRankingAllView.swift index 5b103f2..8f95869 100644 --- a/SodaLive/Sources/Content/All/ContentRankingAllView.swift +++ b/SodaLive/Sources/Content/All/ContentRankingAllView.swift @@ -31,6 +31,14 @@ struct ContentRankingAllView: View { .background(Color(hex: "222222")) .padding(.top, 13.3) + ContentMainRankingSortView( + sorts: viewModel.contentRankingSortList, + selectSort: { viewModel.selectedContentRankingSort = $0 }, + selectedSort: $viewModel.selectedContentRankingSort + ) + .frame(width: screenSize().width - 26.7) + .padding(.vertical, 16.7) + ScrollView(.vertical, showsIndicators: false) { VStack(spacing: 20) { ForEach(0...self, from: responseData) + + if let data = decoded.data, decoded.success { + self.contentRankingSortList.removeAll() + self.contentRankingSortList.append(contentsOf: data) + } else { + if let message = decoded.message { + self.errorMessage = message + } else { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + } + + self.isShowPopup = true + } + } catch { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + self.isShowPopup = true + } + } + .store(in: &subscription) + } } diff --git a/SodaLive/Sources/Content/ContentApi.swift b/SodaLive/Sources/Content/ContentApi.swift index a5ff4af..fb831b9 100644 --- a/SodaLive/Sources/Content/ContentApi.swift +++ b/SodaLive/Sources/Content/ContentApi.swift @@ -30,6 +30,7 @@ enum ContentApi { case getNewContentAllOfTheme(theme: String, page: Int, size: Int) case getAudioContentListByCurationId(curationId: Int, page: Int, size: Int, sort: ContentCurationViewModel.Sort) case getContentRanking(page: Int, size: Int, sortType: String) + case getContentRankingSortType } extension ContentApi: TargetType { @@ -101,6 +102,9 @@ extension ContentApi: TargetType { case .getContentRanking: return "/audio-content/ranking" + + case .getContentRankingSortType: + return "/audio-content/ranking-sort-type" } } @@ -108,7 +112,8 @@ extension ContentApi: TargetType { switch self { case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList, .getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme, - .getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking: + .getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking, + .getContentRankingSortType: return .get case .likeContent, .modifyAudioContent, .modifyComment: @@ -228,6 +233,9 @@ extension ContentApi: TargetType { ] as [String : Any] return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) + + case .getContentRankingSortType: + return .requestPlain } } diff --git a/SodaLive/Sources/Content/ContentRepository.swift b/SodaLive/Sources/Content/ContentRepository.swift index 9cfb605..48349ab 100644 --- a/SodaLive/Sources/Content/ContentRepository.swift +++ b/SodaLive/Sources/Content/ContentRepository.swift @@ -93,6 +93,10 @@ final class ContentRepository { return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort)) } + func getContentRankingSortType() -> AnyPublisher { + return api.requestPublisher(.getContentRankingSortType) + } + func getContentRanking(page: Int, size: Int, sortType: String = "매출") -> AnyPublisher { return api.requestPublisher(.getContentRanking(page: page, size: size, sortType: sortType)) }