121 lines
5.0 KiB
Swift
121 lines
5.0 KiB
Swift
//
|
|
// ContentAllByThemeView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2/14/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentAllByThemeView: View {
|
|
@StateObject var viewModel = ContentAllByThemeViewModel()
|
|
|
|
let themeId: Int
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
DetailNavigationBar(title: viewModel.theme)
|
|
|
|
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)
|
|
|
|
let horizontalPadding: CGFloat = 16
|
|
let gridSpacing: CGFloat = 16
|
|
let itemSize = (screenSize().width - (horizontalPadding * 2) - gridSpacing) / 2
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
LazyVGrid(
|
|
columns: Array(
|
|
repeating: GridItem(
|
|
.flexible(),
|
|
spacing: gridSpacing,
|
|
alignment: .topLeading
|
|
),
|
|
count: 2
|
|
),
|
|
alignment: .leading,
|
|
spacing: gridSpacing
|
|
) {
|
|
ForEach(0..<viewModel.contentList.count, id: \.self) { index in
|
|
ContentNewAllItemView(width: itemSize, item: viewModel.contentList[index])
|
|
.onAppear {
|
|
if index == viewModel.contentList.count - 1 {
|
|
viewModel.getContentList()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.themeId = themeId
|
|
viewModel.getContentList()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|