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

import SwiftUI

struct UserProfileActivitySummaryView: View {
    
    let item: GetCreatorActivitySummary
    
    var body: some View {
        HStack(spacing: 0) {
            ActivitySummaryItemView(
                title: "라이브\n횟수",
                count: String(format: "%d", item.liveCount)
            )
            
            ActivitySummaryDividerView()
            
            ActivitySummaryItemView(
                title: "라이브\n시간",
                count: String(format: "%d", item.liveTime)
            )
            
            ActivitySummaryDividerView()
            
            ActivitySummaryItemView(
                title: "라이브\n참여자",
                count: String(format: "%d", item.liveContributorCount)
            )
            
            ActivitySummaryDividerView()
            
            ActivitySummaryItemView(
                title: "등록\n콘텐츠",
                count: String(format: "%d", item.contentCount)
            )
        }
        .padding(.vertical, 13.3)
        .background(Color.gray22)
        .cornerRadius(8)
        .overlay(
            RoundedRectangle(cornerRadius: 8)
                .stroke(Color.button, lineWidth: 1)
        )
    }
    
    @ViewBuilder
    func ActivitySummaryItemView(title: String, count: String) -> some View {
        HStack(spacing: 0) {
            Spacer()
            VStack(spacing: 8) {
                Text(title)
                    .font(.custom(Font.medium.rawValue, size: 12))
                    .foregroundColor(Color.gray90)
                    .multilineTextAlignment(.center)
                
                Text(count)
                    .font(.custom(Font.bold.rawValue, size: 13.3))
                    .foregroundColor(Color.grayee)
            }
            Spacer()
        }
    }
    
    @ViewBuilder
    func ActivitySummaryDividerView() -> some View {
        Rectangle()
            .frame(width: 1, height: 33.3)
            .foregroundColor(Color.button)
    }
}

struct UserProfileActivitySummaryView_Previews: PreviewProvider {
    static var previews: some View {
        UserProfileActivitySummaryView(
            item: GetCreatorActivitySummary(
                liveCount: 1000,
                liveTime: 1000,
                liveContributorCount: 5000,
                contentCount: 30
            )
        )
    }
}
