100 lines
3.9 KiB
Swift
100 lines
3.9 KiB
Swift
//
|
|
// ContentNewAllView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/09/27.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentNewAllView: View {
|
|
|
|
@StateObject var viewModel = ContentNewAllViewModel()
|
|
|
|
let isFree: Bool
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
VStack(alignment: .leading, spacing: 13.3) {
|
|
DetailNavigationBar(title: isFree ? "최신 무료 콘텐츠" : "최신 콘텐츠")
|
|
|
|
Text("※ 최근 2주간 등록된 새로운 콘텐츠 입니다.")
|
|
.font(.custom(Font.medium.rawValue, size: 14.7))
|
|
.foregroundColor(.graybb)
|
|
.padding(.horizontal, 13.3)
|
|
.padding(.vertical, 8)
|
|
.frame(width: screenSize().width, alignment: .leading)
|
|
.background(Color.gray22)
|
|
|
|
ContentMainContentThemeView(
|
|
themeList: viewModel.themeList,
|
|
selectTheme: {
|
|
viewModel.selectedTheme = $0
|
|
},
|
|
selectedTheme: $viewModel.selectedTheme
|
|
)
|
|
|
|
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)
|
|
}
|
|
.padding(.horizontal, 24)
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
let horizontalPadding: CGFloat = 24
|
|
let gridSpacing: CGFloat = 16
|
|
let itemSize = (screenSize().width - (horizontalPadding * 2) - gridSpacing) / 2
|
|
|
|
LazyVGrid(
|
|
columns: Array(
|
|
repeating: GridItem(
|
|
.flexible(),
|
|
spacing: gridSpacing,
|
|
alignment: .topLeading
|
|
),
|
|
count: 2
|
|
),
|
|
alignment: .leading,
|
|
spacing: gridSpacing
|
|
) {
|
|
ForEach(0..<viewModel.newContentList.count, id: \.self) { index in
|
|
ContentNewAllItemView(width: itemSize, item: viewModel.newContentList[index])
|
|
.onAppear {
|
|
if index == viewModel.newContentList.count - 1 {
|
|
viewModel.getNewContentList()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.isFree = isFree
|
|
viewModel.getThemeList()
|
|
viewModel.getNewContentList()
|
|
}
|
|
}
|
|
.navigationBarHidden(true)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContentNewAllView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ContentNewAllView(isFree: false)
|
|
}
|
|
}
|