//
//  ContentMainCurationViewV2.swift
//  SodaLive
//
//  Created by klaus on 2/21/25.
//

import SwiftUI

struct ContentMainCurationViewV2: View {
    
    let curationList: [GetContentCurationResponse]
    
    var body: some View {
        LazyVStack(spacing: 30) {
            ForEach(0..<curationList.count, id: \.self) { index in
                let curation = curationList[index]
                ContentMainCurationItemViewV2(curation: curation)
            }
        }
    }
}

struct ContentMainCurationItemViewV2: View {
    let curation: GetContentCurationResponse
    
    var body: some View {
        VStack(alignment: .leading, spacing: 13.3) {
            Text(curation.title)
                .font(.custom(Font.bold.rawValue, size: 18.3))
                .foregroundColor(.grayee)
                .padding(.horizontal, 13.3)
            
            ScrollView(.horizontal, showsIndicators: false) {
                HStack(spacing: 13.3) {
                    ForEach(0..<curation.items.count, id: \.self) { index in
                        let item = curation.items[index]
                        ContentMainItemView(item: item)
                    }
                }
                .padding(.horizontal, 13.3)
            }
        }
    }
}

#Preview {
    ContentMainCurationViewV2(
        curationList: [
            GetContentCurationResponse(
                title: "test1",
                items: [
                    GetAudioContentMainItem(
                        contentId: 1,
                        coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        title: "ㅓ처랴햐햫햐햐",
                        creatorId: 8,
                        creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        creatorNickname: "유저1",
                        price: 10,
                        duration: "00:00:30"
                    ),
                    GetAudioContentMainItem(
                        contentId: 2,
                        coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        title: "ㅓ처랴햐햫햐햐",
                        creatorId: 8,
                        creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        creatorNickname: "유저2",
                        price: 10,
                        duration: "00:00:30"
                    ),
                    GetAudioContentMainItem(
                        contentId: 3,
                        coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        title: "ㅓ처랴햐햫햐햐",
                        creatorId: 8,
                        creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                        creatorNickname: "유저3",
                        price: 10,
                        duration: "00:00:30"
                    )
                ]
            )
        ]
    )
}