From bcba83a8a7f94e9f03a4c49cf6c628c9f614cfa2 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 7 May 2024 17:49:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20-=20=EC=B6=94=EC=B2=9C=20=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=A6=88=20UI=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Main/ContentMainView.swift | 20 +++------ ...ContentMainNewContentCreatorItemView.swift | 45 ------------------- .../ContentMainNewContentCreatorView.swift | 43 ------------------ .../ContentMainRecommendSeriesView.swift | 45 +++++++++++++++++++ ...ContentMainRecommendSeriesViewModel.swift} | 26 +++++------ .../Sources/Content/Series/SeriesApi.swift | 8 +++- .../Content/Series/SeriesRepository.swift | 4 ++ .../Series/UserProfileSeriesView.swift | 7 +-- .../UI/Component/SeriesListBigItemView.swift | 27 ++++++++++- 9 files changed, 100 insertions(+), 125 deletions(-) delete mode 100644 SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorItemView.swift delete mode 100644 SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorView.swift create mode 100644 SodaLive/Sources/Content/Main/RecommendSeries/ContentMainRecommendSeriesView.swift rename SodaLive/Sources/Content/Main/{NewContentUploadCreator/ContentMainNewContentCreatorViewModel.swift => RecommendSeries/ContentMainRecommendSeriesViewModel.swift} (56%) diff --git a/SodaLive/Sources/Content/Main/ContentMainView.swift b/SodaLive/Sources/Content/Main/ContentMainView.swift index 34ea44c..07d4fac 100644 --- a/SodaLive/Sources/Content/Main/ContentMainView.swift +++ b/SodaLive/Sources/Content/Main/ContentMainView.swift @@ -6,7 +6,6 @@ // import SwiftUI -import RefreshableScrollView struct ContentMainView: View { @@ -16,12 +15,7 @@ struct ContentMainView: View { ZStack(alignment: .bottomTrailing) { Color.black.ignoresSafeArea() - RefreshableScrollView( - refreshing: $viewModel.isLoading, - action: { - viewModel.refresh() - } - ) { + ScrollView(.vertical, showsIndicators: false) { VStack(alignment: .leading, spacing: 0) { Text("콘텐츠 마켓") .font(.custom(Font.bold.rawValue, size: 21.3)) @@ -30,9 +24,7 @@ struct ContentMainView: View { .padding(.horizontal, 13.3) if !viewModel.isLoading { - ContentMainNewContentCreatorView() - .padding(.bottom, 26.7) - .padding(.horizontal, 13.3) + ContentMainRecommendSeriesView() ContentMainBannerView() .padding(.bottom, 26.7) @@ -124,10 +116,10 @@ struct ContentMainView: View { AppState.shared.setAppStep(step: .createContent) } } - - if viewModel.isLoading { - LoadingView() - } + } + + if viewModel.isLoading { + LoadingView() } } } diff --git a/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorItemView.swift b/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorItemView.swift deleted file mode 100644 index ebca9cd..0000000 --- a/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorItemView.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// ContentMainNewContentCreatorItemView.swift -// SodaLive -// -// Created by klaus on 2023/08/11. -// - -import SwiftUI -import Kingfisher - -struct ContentMainNewContentCreatorItemView: View { - - let item: GetNewContentUploadCreator - - var body: some View { - VStack(spacing: 8) { - KFImage(URL(string: item.creatorProfileImageUrl)) - .resizable() - .scaledToFill() - .frame(width: screenSize().width * 0.18, height: screenSize().width * 0.18, alignment: .top) - .clipShape(Circle()) - - Text(item.creatorNickname) - .font(.custom(Font.medium.rawValue, size: 11.3)) - .foregroundColor(Color(hex: "bbbbbb")) - .frame(width: screenSize().width * 0.18) - .lineLimit(1) - } - .onTapGesture { - AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId)) - } - } -} - -struct ContentMainNewContentCreatorItemView_Previews: PreviewProvider { - static var previews: some View { - ContentMainNewContentCreatorItemView( - item: GetNewContentUploadCreator( - creatorId: 2, - creatorNickname: "수다친구112", - creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png" - ) - ) - } -} diff --git a/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorView.swift b/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorView.swift deleted file mode 100644 index 40cfc38..0000000 --- a/SodaLive/Sources/Content/Main/NewContentUploadCreator/ContentMainNewContentCreatorView.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// ContentMainNewContentCreatorView.swift -// SodaLive -// -// Created by klaus on 2023/08/11. -// - -import SwiftUI - -struct ContentMainNewContentCreatorView: View { - - @StateObject private var viewModel = ContentMainNewContentCreatorViewModel() - - var body: some View { - ZStack { - if !viewModel.newContentUploadCreatorList.isEmpty { - ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing: 21.3) { - ForEach(0..() @Published var errorMessage = "" @Published var isShowPopup = false @Published var isLoading = false - @Published var newContentUploadCreatorList = [GetNewContentUploadCreator]() + @Published var seriesList = [SeriesListItem]() - func getNewContentUploadCreatorList() { - isLoading = true - - repository.getNewContentUploadCreatorList() + func getRecommendSeriesList() { + repository.getRecommendSeriesList() .sink { result in switch result { case .finished: @@ -36,23 +34,23 @@ final class ContentMainNewContentCreatorViewModel: ObservableObject { do { let jsonDecoder = JSONDecoder() - let decoded = try jsonDecoder.decode(ApiResponse<[GetNewContentUploadCreator]>.self, from: responseData) + let decoded = try jsonDecoder.decode(ApiResponse<[SeriesListItem]>.self, from: responseData) self.isLoading = false if let data = decoded.data, decoded.success { - self.newContentUploadCreatorList.removeAll() - self.newContentUploadCreatorList.append(contentsOf: data) + self.seriesList.removeAll() + self.seriesList.append(contentsOf: data) } else { if let message = decoded.message { self.errorMessage = message } else { - self.errorMessage = "크리에이터 리스트를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + self.errorMessage = "추천 시리즈를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." } self.isShowPopup = true } } catch { - self.errorMessage = "크리에이터 리스트를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + self.errorMessage = "추천 시리즈를 불러오지 못했습니다. 다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." self.isShowPopup = true self.isLoading = false } diff --git a/SodaLive/Sources/Content/Series/SeriesApi.swift b/SodaLive/Sources/Content/Series/SeriesApi.swift index 8e205bc..eeac0d0 100644 --- a/SodaLive/Sources/Content/Series/SeriesApi.swift +++ b/SodaLive/Sources/Content/Series/SeriesApi.swift @@ -12,6 +12,7 @@ enum SeriesApi { case getSeriesList(creatorId: Int, sortType: SeriesListAllViewModel.SeriesSortType, page: Int, size: Int) case getSeriesDetail(seriesId: Int) case getSeriesContentList(seriesId: Int, page: Int, size: Int) + case getRecommendSeriesList } extension SeriesApi: TargetType { @@ -29,12 +30,15 @@ extension SeriesApi: TargetType { case .getSeriesContentList(let seriesId, _, _): return "/audio-content/series/\(seriesId)/content" + + case .getRecommendSeriesList: + return "/audio-content/series/recommend" } } var method: Moya.Method { switch self { - case .getSeriesList, .getSeriesDetail, .getSeriesContentList: + case .getSeriesList, .getSeriesDetail, .getSeriesContentList, .getRecommendSeriesList: return .get } } @@ -51,7 +55,7 @@ extension SeriesApi: TargetType { return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) - case .getSeriesDetail: + case .getSeriesDetail, .getRecommendSeriesList: return .requestPlain case .getSeriesContentList(_, let page, let size): diff --git a/SodaLive/Sources/Content/Series/SeriesRepository.swift b/SodaLive/Sources/Content/Series/SeriesRepository.swift index 46a8694..e976df1 100644 --- a/SodaLive/Sources/Content/Series/SeriesRepository.swift +++ b/SodaLive/Sources/Content/Series/SeriesRepository.swift @@ -24,4 +24,8 @@ class SeriesRepository { func getSeriesContentList(seriesId: Int, page: Int, size: Int) -> AnyPublisher { return api.requestPublisher(.getSeriesContentList(seriesId: seriesId, page: page, size: size)) } + + func getRecommendSeriesList() -> AnyPublisher { + return api.requestPublisher(.getRecommendSeriesList) + } } diff --git a/SodaLive/Sources/Explorer/Profile/Series/UserProfileSeriesView.swift b/SodaLive/Sources/Explorer/Profile/Series/UserProfileSeriesView.swift index 4a5ffc4..b8badfc 100644 --- a/SodaLive/Sources/Explorer/Profile/Series/UserProfileSeriesView.swift +++ b/SodaLive/Sources/Explorer/Profile/Series/UserProfileSeriesView.swift @@ -33,12 +33,7 @@ struct UserProfileSeriesView: View { HStack(alignment: .top, spacing: 13.3) { ForEach(0..