//
//  SectionCommunityPostView.swift
//  SodaLive
//
//  Created by klaus on 2023/12/21.
//

import SwiftUI

struct SectionCommunityPostView: View {
    
    let items: [GetCommunityPostListResponse]
    
    var body: some View {
        ScrollView(.horizontal, showsIndicators: false) {
            HStack(spacing: 13.3) {
                ForEach(0..<items.count, id: \.self) { index in
                    let item = items[index]
                    CreatorCommunityItemView(item: item)
                        .frame(width: 320)
                        .onTapGesture {
                            AppState.shared
                                .setAppStep(step: .creatorCommunityAll(creatorId: item.creatorId))
                        }
                }
            }
        }
    }
}

struct SectionCommunityPostView_Previews: PreviewProvider {
    static var previews: some View {
        SectionCommunityPostView(items: [
            GetCommunityPostListResponse(
                postId: 1,
                creatorId: 1,
                creatorNickname: "민하나",
                creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                audioUrl: nil,
                content: "라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!",
                price: 10,
                date: "3일전",
                isCommentAvailable: false,
                isAdult: false,
                isLike: true,
                existOrdered: false,
                likeCount: 10,
                commentCount: 0,
                firstComment: nil
            ),
            GetCommunityPostListResponse(
                postId: 2,
                creatorId: 2,
                creatorNickname: "닉네임2",
                creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
                audioUrl: nil,
                content: "너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!",
                price: 10,
                date: "3일전",
                isCommentAvailable: false,
                isAdult: false,
                isLike: true,
                existOrdered: false,
                likeCount: 20,
                commentCount: 0,
                firstComment: nil
            )
        ])
    }
}