시리즈 콘텐츠 리스트
- 정렬(최신순, 등록순) 추가
This commit is contained in:
		| @@ -20,6 +20,37 @@ struct SeriesContentAllView: View { | ||||
|                 VStack(spacing: 0) { | ||||
|                     DetailNavigationBar(title: "\(seriesTitle) - 전체회차 듣기") | ||||
|                      | ||||
|                     HStack(spacing: 13.3) { | ||||
|                         Spacer() | ||||
|                          | ||||
|                         Text("최신순") | ||||
|                             .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                             .foregroundColor( | ||||
|                                 Color.graye2 | ||||
|                                     .opacity(viewModel.sortType == .NEWEST ? 1 : 0.5) | ||||
|                             ) | ||||
|                             .onTapGesture { | ||||
|                                 if viewModel.sortType != .NEWEST { | ||||
|                                     viewModel.sortType = .NEWEST | ||||
|                                 } | ||||
|                             } | ||||
|                          | ||||
|                         Text("등록순") | ||||
|                             .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                             .foregroundColor( | ||||
|                                 Color.graye2 | ||||
|                                     .opacity(viewModel.sortType == .OLDEST ? 1 : 0.5) | ||||
|                             ) | ||||
|                             .onTapGesture { | ||||
|                                 if viewModel.sortType != .OLDEST { | ||||
|                                     viewModel.sortType = .OLDEST | ||||
|                                 } | ||||
|                             } | ||||
|                     } | ||||
|                     .padding(.vertical, 13.3) | ||||
|                     .padding(.horizontal, 20) | ||||
|                     .background(Color.gray16) | ||||
|                      | ||||
|                     ScrollView(.vertical, showsIndicators: false) { | ||||
|                         VStack(spacing: 12) { | ||||
|                             ForEach(0..<viewModel.seriesContentList.count, id: \.self) { index in | ||||
|   | ||||
| @@ -19,14 +19,24 @@ final class SeriesContentAllViewModel: ObservableObject { | ||||
|     @Published var isShowPopup = false | ||||
|     @Published var seriesContentList = [GetSeriesContentListItem]() | ||||
|      | ||||
|     @Published var sortType: SeriesListAllViewModel.SeriesSortType = .NEWEST { | ||||
|         didSet { | ||||
|             page = 1 | ||||
|             isLast = false | ||||
|             getSeriesContentList() | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     var page = 1 | ||||
|     var isLast = false | ||||
|     private let pageSize = 10 | ||||
|      | ||||
|     func getSeriesContentList() { | ||||
|         if !isLoading && !isLast { | ||||
|             isLoading = true | ||||
|              | ||||
|             repository | ||||
|                 .getSeriesContentList(seriesId: seriesId, page: page, size: pageSize) | ||||
|                 .getSeriesContentList(seriesId: seriesId, page: page, size: pageSize, sortType: sortType) | ||||
|                 .sink { result in | ||||
|                     switch result { | ||||
|                     case .finished: | ||||
|   | ||||
| @@ -11,7 +11,7 @@ import Moya | ||||
| 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 getSeriesContentList(seriesId: Int, page: Int, size: Int, sortType: SeriesListAllViewModel.SeriesSortType) | ||||
|     case getRecommendSeriesList | ||||
| } | ||||
|  | ||||
| @@ -28,7 +28,7 @@ extension SeriesApi: TargetType { | ||||
|         case .getSeriesDetail(let seriesId): | ||||
|             return "/audio-content/series/\(seriesId)" | ||||
|              | ||||
|         case .getSeriesContentList(let seriesId, _, _): | ||||
|         case .getSeriesContentList(let seriesId, _, _, _): | ||||
|             return "/audio-content/series/\(seriesId)/content" | ||||
|              | ||||
|         case .getRecommendSeriesList: | ||||
| @@ -58,10 +58,11 @@ extension SeriesApi: TargetType { | ||||
|         case .getSeriesDetail, .getRecommendSeriesList: | ||||
|             return .requestPlain | ||||
|              | ||||
|         case .getSeriesContentList(_, let page, let size): | ||||
|         case .getSeriesContentList(_, let page, let size, let sortType): | ||||
|             let parameters = [ | ||||
|                 "page": page - 1, | ||||
|                 "size": size | ||||
|                 "size": size, | ||||
|                 "sortType": sortType | ||||
|             ] as [String : Any] | ||||
|              | ||||
|             return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||||
|   | ||||
| @@ -13,7 +13,7 @@ final class SeriesListAllViewModel: ObservableObject { | ||||
|     private var subscription = Set<AnyCancellable>() | ||||
|      | ||||
|     enum SeriesSortType: String { | ||||
|         case NEWEST, POPULAR | ||||
|         case NEWEST, OLDEST | ||||
|     } | ||||
|      | ||||
|     var creatorId: Int = 0 | ||||
|   | ||||
| @@ -21,8 +21,8 @@ class SeriesRepository { | ||||
|         return api.requestPublisher(.getSeriesDetail(seriesId: seriesId)) | ||||
|     } | ||||
|      | ||||
|     func getSeriesContentList(seriesId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> { | ||||
|         return api.requestPublisher(.getSeriesContentList(seriesId: seriesId, page: page, size: size)) | ||||
|     func getSeriesContentList(seriesId: Int, page: Int, size: Int, sortType: SeriesListAllViewModel.SeriesSortType) -> AnyPublisher<Response, MoyaError> { | ||||
|         return api.requestPublisher(.getSeriesContentList(seriesId: seriesId, page: page, size: size, sortType: sortType)) | ||||
|     } | ||||
|      | ||||
|     func getRecommendSeriesList() -> AnyPublisher<Response, MoyaError> { | ||||
|   | ||||
| @@ -14,6 +14,7 @@ extension Color { | ||||
|     static let button = Color(hex: "3bb9f1") | ||||
|     static let bg = Color(hex: "13181B") | ||||
|     static let gray11 = Color(hex: "111111") | ||||
|     static let gray16 = Color(hex: "161616") | ||||
|     static let gray22 = Color(hex: "222222") | ||||
|     static let gray23 = Color(hex: "232323") | ||||
|     static let gray30 = Color(hex: "303030") | ||||
| @@ -27,6 +28,7 @@ extension Color { | ||||
|     static let graybb = Color(hex: "bbbbbb") | ||||
|     static let grayd2 = Color(hex: "d2d2d2") | ||||
|     static let grayd8 = Color(hex: "d8d8d8") | ||||
|     static let graye2 = Color(hex: "e2e2e2") | ||||
|     static let grayee = Color(hex: "eeeeee") | ||||
|      | ||||
|     static let mainRed = Color(hex: "ff5c49") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung