크리에이터 채널 - 콘텐츠 영역 추가
This commit is contained in:
		| @@ -58,6 +58,8 @@ enum AppStep { | ||||
|      | ||||
|     case modifyContent(contentId: Int) | ||||
|      | ||||
|     case contentListAll(userId: Int) | ||||
|      | ||||
|     case contentDetail(contentId: Int) | ||||
|      | ||||
|     case liveReservationComplete(response: MakeLiveReservationResponse) | ||||
|   | ||||
							
								
								
									
										177
									
								
								SodaLive/Sources/Content/ContentListView.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								SodaLive/Sources/Content/ContentListView.swift
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,177 @@ | ||||
| // | ||||
| //  ContentListView.swift | ||||
| //  SodaLive | ||||
| // | ||||
| //  Created by klaus on 2023/08/20. | ||||
| // | ||||
|  | ||||
| import SwiftUI | ||||
|  | ||||
| struct ContentListView: View { | ||||
|      | ||||
|     let userId: Int | ||||
|     @StateObject var viewModel = ContentListViewModel() | ||||
|      | ||||
|     var body: some View { | ||||
|         BaseView(isLoading: $viewModel.isLoading) { | ||||
|             VStack(spacing: 0) { | ||||
|                 HStack(spacing: 0) { | ||||
|                     Button { | ||||
|                         AppState.shared.back() | ||||
|                     } label: { | ||||
|                         Image("ic_back") | ||||
|                             .resizable() | ||||
|                             .frame(width: 20, height: 20) | ||||
|                          | ||||
|                         Text("콘텐츠 전체보기") | ||||
|                             .font(.custom(Font.bold.rawValue, size: 18.3)) | ||||
|                             .foregroundColor(Color(hex: "eeeeee")) | ||||
|                     } | ||||
|                      | ||||
|                     Spacer() | ||||
|                 } | ||||
|                 .padding(.horizontal, 13.3) | ||||
|                 .frame(height: 50) | ||||
|                 .background(Color.black) | ||||
|                  | ||||
|                 if userId == UserDefaults.int(forKey: .userId) { | ||||
|                     Text("새로운 콘텐츠 등록하기") | ||||
|                         .font(.custom(Font.bold.rawValue, size: 15)) | ||||
|                         .foregroundColor(Color(hex: "eeeeee")) | ||||
|                         .padding(.vertical, 17) | ||||
|                         .frame(maxWidth: .infinity) | ||||
|                         .background(Color(hex: "9970ff")) | ||||
|                         .cornerRadius(5.3) | ||||
|                         .padding(.top, 13.3) | ||||
|                         .padding(.horizontal, 13.3) | ||||
|                         .onTapGesture { AppState.shared.setAppStep(step: .createContent) } | ||||
|                 } | ||||
|                  | ||||
|                 HStack(spacing: 13.3) { | ||||
|                     Spacer() | ||||
|                      | ||||
|                     Text("최신순") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor( | ||||
|                             Color(hex: "e2e2e2") | ||||
|                                 .opacity(viewModel.sort == .NEWEST ? 1 : 0.5) | ||||
|                         ) | ||||
|                         .onTapGesture { | ||||
|                             if viewModel.sort != .NEWEST { | ||||
|                                 viewModel.sort = .NEWEST | ||||
|                             } | ||||
|                         } | ||||
|                      | ||||
|                     Text("높은 가격순") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor( | ||||
|                             Color(hex: "e2e2e2") | ||||
|                                 .opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5) | ||||
|                         ) | ||||
|                         .onTapGesture { | ||||
|                             if viewModel.sort != .PRICE_HIGH { | ||||
|                                 viewModel.sort = .PRICE_HIGH | ||||
|                             } | ||||
|                         } | ||||
|                      | ||||
|                     Text("낮은 가격순") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor( | ||||
|                             Color(hex: "e2e2e2") | ||||
|                                 .opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5) | ||||
|                         ) | ||||
|                         .onTapGesture { | ||||
|                             if viewModel.sort != .PRICE_LOW { | ||||
|                                 viewModel.sort = .PRICE_LOW | ||||
|                             } | ||||
|                         } | ||||
|                 } | ||||
|                 .padding(.vertical, 13.3) | ||||
|                 .padding(.horizontal, 20) | ||||
|                 .background(Color(hex: "161616")) | ||||
|                 .padding(.top, 13.3) | ||||
|                  | ||||
|                 HStack(spacing: 0) { | ||||
|                     Text("전체") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor(Color(hex: "e2e2e2")) | ||||
|                      | ||||
|                     Text("\(viewModel.totalCount)") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor(Color(hex: "ff5c49")) | ||||
|                         .padding(.leading, 8) | ||||
|                      | ||||
|                     Text("개") | ||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                         .foregroundColor(Color(hex: "e2e2e2")) | ||||
|                         .padding(.leading, 2) | ||||
|                      | ||||
|                     Spacer() | ||||
|                 } | ||||
|                 .padding(.vertical, 13.3) | ||||
|                 .padding(.horizontal, 20) | ||||
|                  | ||||
|                 ScrollViewReader { reader in | ||||
|                     ScrollView(.vertical, showsIndicators: false) { | ||||
|                         LazyVStack(spacing: 10.7) { | ||||
|                             ScrollerToTop(reader: reader, scrollOnChange: $viewModel.scrollToTop) | ||||
|                              | ||||
|                             ForEach(0..<viewModel.audioContentList.count, id: \.self) { index in | ||||
|                                 let audioContent = viewModel.audioContentList[index] | ||||
|                                 ContentListItemView(item: audioContent) | ||||
|                                     .contentShape(Rectangle()) | ||||
|                                     .onTapGesture { | ||||
|                                         AppState | ||||
|                                             .shared | ||||
|                                             .setAppStep( | ||||
|                                                 step: .contentDetail(contentId: audioContent.contentId) | ||||
|                                             ) | ||||
|                                     } | ||||
|                                     .onAppear { | ||||
|                                         if index == viewModel.audioContentList.count - 1 { | ||||
|                                             viewModel.getAudioContentList() | ||||
|                                         } | ||||
|                                     } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 .padding(.top, 13.3) | ||||
|             } | ||||
|             .onAppear { | ||||
|                 viewModel.userId = userId | ||||
|                 viewModel.getAudioContentList() | ||||
|             } | ||||
|             .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) { | ||||
|                 HStack { | ||||
|                     Spacer() | ||||
|                     Text(viewModel.errorMessage) | ||||
|                         .padding(.vertical, 13.3) | ||||
|                         .frame(width: screenSize().width - 66.7, alignment: .center) | ||||
|                         .font(.custom(Font.medium.rawValue, size: 12)) | ||||
|                         .background(Color(hex: "9970ff")) | ||||
|                         .foregroundColor(Color.white) | ||||
|                         .multilineTextAlignment(.leading) | ||||
|                         .cornerRadius(20) | ||||
|                         .padding(.bottom, 66.7) | ||||
|                     Spacer() | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct ScrollerToTop: View { | ||||
|     let reader: ScrollViewProxy | ||||
|     @Binding var scrollOnChange: Bool | ||||
|      | ||||
|     var body: some View { | ||||
|         EmptyView() | ||||
|             .id("topScrollPoint") | ||||
|             .onChange(of: scrollOnChange) { _ in | ||||
|                 withAnimation { | ||||
|                     reader.scrollTo("topScrollPoint", anchor: .bottom) | ||||
|                 } | ||||
|             } | ||||
|     } | ||||
| } | ||||
| @@ -101,6 +101,9 @@ struct ContentView: View { | ||||
|             case .modifyContent(let contentId): | ||||
|                 ContentModifyView(contentId: contentId) | ||||
|                  | ||||
|             case .contentListAll(let userId): | ||||
|                 ContentListView(userId: userId) | ||||
|                  | ||||
|             case .contentDetail(let contentId): | ||||
|                 ContentDetailView(contentId: contentId) | ||||
|                  | ||||
|   | ||||
| @@ -12,6 +12,7 @@ struct GetCreatorProfileResponse: Decodable { | ||||
|     let userDonationRanking: [UserDonationRankingResponse] | ||||
|     let similarCreatorList: [SimilarCreatorResponse] | ||||
|     let liveRoomList: [LiveRoomResponse] | ||||
|     let contentList: [GetAudioContentListItem] | ||||
|     let notice: String | ||||
|     let cheers: GetCheersResponse | ||||
|     let activitySummary: GetCreatorActivitySummary | ||||
|   | ||||
| @@ -24,7 +24,9 @@ struct UserProfileContentView: View { | ||||
|                 Text("전체보기") | ||||
|                     .font(.custom(Font.medium.rawValue, size: 12)) | ||||
|                     .foregroundColor(Color(hex: "bbbbbb")) | ||||
|                     .onTapGesture {} | ||||
|                     .onTapGesture { | ||||
|                         AppState.shared.setAppStep(step: .contentListAll(userId: userId)) | ||||
|                     } | ||||
|             } | ||||
|              | ||||
|             if userId == UserDefaults.int(forKey: .userId) { | ||||
| @@ -44,7 +46,13 @@ struct UserProfileContentView: View { | ||||
|                     let item = items[index] | ||||
|                     ContentListItemView(item: item) | ||||
|                         .contentShape(Rectangle()) | ||||
|                         .onTapGesture {} | ||||
|                         .onTapGesture { | ||||
|                             AppState | ||||
|                                 .shared | ||||
|                                 .setAppStep( | ||||
|                                     step: .contentDetail(contentId: item.contentId) | ||||
|                                 ) | ||||
|                         } | ||||
|                 } | ||||
|             } | ||||
|             .padding(.top, 21) | ||||
|   | ||||
| @@ -88,6 +88,17 @@ struct UserProfileView: View { | ||||
|                                     } | ||||
|                                 } | ||||
|                                  | ||||
|                                 if creatorProfile.contentList.count > 0 || | ||||
|                                     userId == UserDefaults.int(forKey: .userId) | ||||
|                                 { | ||||
|                                     UserProfileContentView( | ||||
|                                         userId: userId, | ||||
|                                         items: creatorProfile.contentList | ||||
|                                     ) | ||||
|                                     .padding(.top, 46.7) | ||||
|                                     .padding(.horizontal, 13.3) | ||||
|                                 } | ||||
|                                  | ||||
|                                 if creatorProfile.liveRoomList.count > 0 { | ||||
|                                     UserProfileLiveView( | ||||
|                                         userId: userId, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung