//
//  DashBoardView.swift
//  AcaMate
//
//  Created by TAnine on 2/10/25.
//

import SwiftUI

struct DashBoardView<Content: View>: View {
    @StateObject var btnVM = ButtonViewModel()
    @State private var attMoreBtnID = UUID()
    let image: Image
    let title: String
    @ViewBuilder let content: Content
    var moreAction: VOID_TO_VOID?
    
    
    var body: some View {
        VStack(spacing: 0) {
            HStack(spacing: 0){
                image
                    .resizable()
                    .frame(width: 24, height: 24, alignment: .center)
                    .padding([.trailing],4)
                Text("\(title)")
                    .font(.nps(font: .bold, size: 20))
                    .foregroundStyle(Color(.Text.detail))
                Spacer()
                SimpleBtnView(vm: btnVM, id: attMoreBtnID)
            }
            .padding([.bottom],2)
            
            Rectangle()
                .frame(maxWidth: .infinity, maxHeight: 2)
                .foregroundStyle(Color(.Second.normal))
                .padding([.bottom],12)
            
            content
        }
        .padding(24)
        .onAppear {
            btnVM.setSize(for: attMoreBtnID, newWidth: 40, newHeight: 24)
            btnVM.setText(for: attMoreBtnID, newText: "더보기", newFont: .nps(size: 12))
            btnVM.setTextColor(for: attMoreBtnID, newColor: .Text.disabled)
            
            if let action = moreAction {
                btnVM.setAction(for: attMoreBtnID, newAction: action)
            }
        }
    }
}

