92 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  ContentNewAllView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/09/27.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct ContentNewAllView: View {
 | 
						|
    
 | 
						|
    @StateObject var viewModel = ContentNewAllViewModel()
 | 
						|
    
 | 
						|
    let columns = [
 | 
						|
        GridItem(.flexible(), alignment: .top),
 | 
						|
        GridItem(.flexible(), alignment: .top),
 | 
						|
        GridItem(.flexible(), alignment: .top)
 | 
						|
    ]
 | 
						|
    
 | 
						|
    let isFree: Bool
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        NavigationView {
 | 
						|
            BaseView(isLoading: $viewModel.isLoading) {
 | 
						|
                VStack(alignment: .leading, spacing: 13.3) {
 | 
						|
                    DetailNavigationBar(title: isFree ? "새로운 무료 콘텐츠" : "새로운 단편")
 | 
						|
                    
 | 
						|
                    Text("※ 최근 2주간 등록된 \(isFree ? "새로운 콘텐츠" : "새로운 단편") 입니다.")
 | 
						|
                        .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)
 | 
						|
                    
 | 
						|
                    ContentMainNewContentThemeView(
 | 
						|
                        themes: viewModel.themeList,
 | 
						|
                        selectTheme: {
 | 
						|
                            viewModel.selectedTheme = $0
 | 
						|
                        },
 | 
						|
                        selectedTheme: $viewModel.selectedTheme
 | 
						|
                    )
 | 
						|
                    .padding(.horizontal, 20)
 | 
						|
                    
 | 
						|
                    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, 13.3)
 | 
						|
                    
 | 
						|
                    ScrollView(.vertical, showsIndicators: false) {
 | 
						|
                        LazyVGrid(columns: columns, spacing: 32) {
 | 
						|
                            ForEach(0..<viewModel.newContentList.count, id: \.self) { index in
 | 
						|
                                ContentNewAllItemView(item: viewModel.newContentList[index])
 | 
						|
                                    .onAppear {
 | 
						|
                                        if index == viewModel.newContentList.count - 1 {
 | 
						|
                                            viewModel.getNewContentList()
 | 
						|
                                        }
 | 
						|
                                    }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        .padding(.horizontal, 13.3)
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                .onAppear {
 | 
						|
                    viewModel.isFree = isFree
 | 
						|
                    viewModel.getThemeList()
 | 
						|
                    viewModel.getNewContentList()
 | 
						|
                }
 | 
						|
            }
 | 
						|
            .navigationBarHidden(true)
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct ContentNewAllView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        ContentNewAllView(isFree: false)
 | 
						|
    }
 | 
						|
}
 |