//
//  ContentMainNewContentView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/11.
//

import SwiftUI

struct ContentMainNewContentView: View {
    
    let themes: [String]
    let items: [GetAudioContentMainItem]
    
    let selectTheme: (String) -> Void
    @Binding var selectedTheme: String
    
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            HStack(spacing: 0) {
                Text("새로운 콘텐츠")
                    .font(.custom(Font.bold.rawValue, size: 18.3))
                    .foregroundColor(Color(hex: "eeeeee"))
                
                Spacer()
                
                Image("ic_forward")
                    .resizable()
                    .frame(width: 20, height: 20)
                    .onTapGesture {
                        AppState.shared.setAppStep(step: .newContentAll)
                    }
            }
            
            ContentMainNewContentThemeView(themes: themes, selectTheme: selectTheme, selectedTheme: $selectedTheme)
                .padding(.vertical, 16.7)
            
            ScrollView(.horizontal, showsIndicators: false) {
                HStack(alignment: .top, spacing: 13.3) {
                    ForEach(0..<items.count, id: \.self) {
                        ContentMainItemView(item: items[$0])
                    }
                }
            }
        }
    }
}

struct ContentMainNewContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentMainNewContentView(
            themes: ["전체", "테마1", "테마2"],
            items: [
                GetAudioContentMainItem(
                    contentId: 1,
                    coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                    title: "테스트",
                    creatorId: 7,
                    creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                    creatorNickname: "유저1"
                )
            ],
            selectTheme: { _ in },
            selectedTheme: .constant("전체")
        )
    }
}