// // 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 { NavigationView { 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: "3bb9f1")) .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..