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

import SwiftUI

struct ContentMainNewContentCreatorView: View {
    
    @StateObject private var viewModel = ContentMainNewContentCreatorViewModel()
    
    var body: some View {
        ZStack {
            if !viewModel.newContentUploadCreatorList.isEmpty {
                ScrollView(.horizontal, showsIndicators: false) {
                    HStack(spacing: 21.3) {
                        ForEach(0..<viewModel.newContentUploadCreatorList.count, id: \.self) { index in
                            let item = viewModel.newContentUploadCreatorList[index]
                            ContentMainNewContentCreatorItemView(item: item)
                        }
                    }
                }
            }
            
            if viewModel.isLoading {
                ActivityIndicatorView()
                    .frame(width: 100, height: 100)
            }
        }
        .frame(maxWidth: .infinity)
        .onAppear {
            viewModel.getNewContentUploadCreatorList()
        }
    }
}

struct ContentMainNewContentCreatorView_Previews: PreviewProvider {
    static var previews: some View {
        ContentMainNewContentCreatorView()
    }
}