From a5b954ada2d47a7a909e7b8efadd02fb68282b18 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Sun, 20 Aug 2023 20:36:17 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=B1=84=EB=84=90=20-=20=EC=BD=98=ED=85=90=EC=B8=A0=20?= =?UTF-8?q?=EC=98=81=EC=97=AD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppStep.swift | 2 + .../Sources/Content/ContentListView.swift | 177 ++++++++++++++++++ SodaLive/Sources/ContentView.swift | 3 + .../Profile/GetCreatorProfileResponse.swift | 1 + .../Profile/UserProfileContentView.swift | 12 +- .../Explorer/Profile/UserProfileView.swift | 11 ++ 6 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 SodaLive/Sources/Content/ContentListView.swift diff --git a/SodaLive/Sources/App/AppStep.swift b/SodaLive/Sources/App/AppStep.swift index 2e4fa05..6cd0155 100644 --- a/SodaLive/Sources/App/AppStep.swift +++ b/SodaLive/Sources/App/AppStep.swift @@ -58,6 +58,8 @@ enum AppStep { case modifyContent(contentId: Int) + case contentListAll(userId: Int) + case contentDetail(contentId: Int) case liveReservationComplete(response: MakeLiveReservationResponse) diff --git a/SodaLive/Sources/Content/ContentListView.swift b/SodaLive/Sources/Content/ContentListView.swift new file mode 100644 index 0000000..89e8914 --- /dev/null +++ b/SodaLive/Sources/Content/ContentListView.swift @@ -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.. 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,